From 00795b3a836aa7617373341a29391f74910f4fd7 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 4 Dec 2010 16:33:16 +0000 Subject: [PATCH] Updated CanvasRenderer and some examples to handle the `Texture( image, mapping)` approach. --- build/Three.js | 182 +++---- build/ThreeDebug.js | 206 ++++---- build/ThreeExtras.js | 280 +++++----- examples/canvasrenderer_sandbox.html | 13 +- examples/geometry_earth.html | 4 +- examples/geometry_panorama.html | 2 +- examples/geometry_panorama_fisheye.html | 2 +- examples/geometry_terrain.html | 2 +- examples/materials.html | 6 +- examples/materials_reflection.html | 2 +- examples/materials_video.html | 4 +- src/materials/MeshShaderMaterial.js | 10 +- src/materials/{textures => }/Texture.js | 0 src/materials/textures/TextureCube.js | 21 - src/renderers/CanvasRenderer.js | 669 ++++++++++++------------ utils/build.py | 39 +- 16 files changed, 729 insertions(+), 713 deletions(-) rename src/materials/{textures => }/Texture.js (100%) delete mode 100644 src/materials/textures/TextureCube.js diff --git a/build/Three.js b/build/Three.js index 5c1f0631a8..4a7053da78 100755 --- a/build/Three.js +++ b/build/Three.js @@ -12,44 +12,44 @@ THREE.Vector4=function(a,b,d,g){this.x=a||0;this.y=b||0;this.z=d||0;this.w=g||1} THREE.Vector4.prototype={set:function(a,b,d,g){this.x=a;this.y=b;this.z=d;this.w=g;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},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,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,d,g=a.objects,j=[];a=0;for(b=g.length;a0&&M>0&&k+M<1}var d,g,j,o,m,p,l,c,E,G, -w,F=a.geometry,O=F.vertices,J=[];d=0;for(g=F.faces.length;d= -0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){p=true;j=g=d=b=0;a()};this.isEmpty=function(){return p};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+g+", top: "+d+", bottom: "+j+", width: "+o+", height: "+m+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,g=a.objects,j=[];a=0;for(b=g.length;a0&&K>0&&k+K<1}var d,g,j,n,m,l,o,c,F,D, +v,x=a.geometry,H=x.vertices,G=[];d=0;for(g=x.faces.length;d= +0&&Math.min(j,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){l=true;j=g=d=b=0;a()};this.isEmpty=function(){return l};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+g+", top: "+d+", bottom: "+j+", width: "+n+", height: "+m+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; THREE.Matrix4=function(){}; THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,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},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},lookAt:function(a,b,d){var g=new THREE.Vector3,j=new THREE.Vector3,o=new THREE.Vector3;o.sub(a,b).normalize();g.cross(d,o).normalize();j.cross(o,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=o.x;this.n32=o.y;this.n33=o.z;this.n34=-o.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,g=a.z,j=1/(this.n41*b+this.n42* +a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(a,b,d){var g=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();g.cross(d,n).normalize();j.cross(n,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=n.x;this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,g=a.z,j=1/(this.n41*b+this.n42* d+this.n43*g+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*g+this.n14)*j;a.y=(this.n21*b+this.n22*d+this.n23*g+this.n24)*j;a.z=(this.n31*b+this.n32*d+this.n33*g+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,d=a.y,g=a.z,j=a.w;a.x=this.n11*b+this.n12*d+this.n13*g+this.n14*j;a.y=this.n21*b+this.n22*d+this.n23*g+this.n24*j;a.z=this.n31*b+this.n32*d+this.n33*g+this.n34*j;a.w=this.n41*b+this.n42*d+this.n43*g+this.n44*j;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11* -a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,g=a.n12,j=a.n13,o=a.n14,m=a.n21,p=a.n22,l=a.n23,c=a.n24,E=a.n31,G=a.n32,w=a.n33,F=a.n34,O=a.n41,J=a.n42,M=a.n43,r=a.n44,S=b.n11,z=b.n12,f=b.n13,k=b.n14,e=b.n21,n=b.n22,i=b.n23,h=b.n24,q=b.n31,t=b.n32,K=b.n33,A=b.n34,H=b.n41,P=b.n42,u=b.n43, -N=b.n44;this.n11=d*S+g*e+j*q+o*H;this.n12=d*z+g*n+j*t+o*P;this.n13=d*f+g*i+j*K+o*u;this.n14=d*k+g*h+j*A+o*N;this.n21=m*S+p*e+l*q+c*H;this.n22=m*z+p*n+l*t+c*P;this.n23=m*f+p*i+l*K+c*u;this.n24=m*k+p*h+l*A+c*N;this.n31=E*S+G*e+w*q+F*H;this.n32=E*z+G*n+w*t+F*P;this.n33=E*f+G*i+w*K+F*u;this.n34=E*k+G*h+w*A+F*N;this.n41=O*S+J*e+M*q+r*H;this.n42=O*z+J*n+M*t+r*P;this.n43=O*f+J*i+M*K+r*u;this.n44=O*k+J*h+M*A+r*N},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,j=this.n14,o=this.n21,m=this.n22, -p=this.n23,l=this.n24,c=this.n31,E=this.n32,G=this.n33,w=this.n34,F=this.n41,O=this.n42,J=this.n43,M=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+j*a.n44;this.n21=o*a.n11+m*a.n21+p*a.n31+l*a.n41;this.n22=o*a.n12+m*a.n22+p*a.n32+l*a.n42;this.n23=o*a.n13+m*a.n23+p*a.n33+l*a.n43;this.n24=o*a.n14+m*a.n24+p*a.n34+l*a.n44;this.n31=c*a.n11+E*a.n21+G*a.n31+w*a.n41;this.n32=c*a.n12+E*a.n22+ -G*a.n32+w*a.n42;this.n33=c*a.n13+E*a.n23+G*a.n33+w*a.n43;this.n34=c*a.n14+E*a.n24+G*a.n34+w*a.n44;this.n41=F*a.n11+O*a.n21+J*a.n31+M*a.n41;this.n42=F*a.n12+O*a.n22+J*a.n32+M*a.n42;this.n43=F*a.n13+O*a.n23+J*a.n33+M*a.n43;this.n44=F*a.n14+O*a.n24+J*a.n34+M*a.n44},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},determinant:function(){return this.n14* +a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,g=a.n12,j=a.n13,n=a.n14,m=a.n21,l=a.n22,o=a.n23,c=a.n24,F=a.n31,D=a.n32,v=a.n33,x=a.n34,H=a.n41,G=a.n42,K=a.n43,N=a.n44,O=b.n11,u=b.n12,f=b.n13,k=b.n14,e=b.n21,p=b.n22,h=b.n23,i=b.n24,r=b.n31,q=b.n32,L=b.n33,A=b.n34,M=b.n41,Q=b.n42,t=b.n43, +R=b.n44;this.n11=d*O+g*e+j*r+n*M;this.n12=d*u+g*p+j*q+n*Q;this.n13=d*f+g*h+j*L+n*t;this.n14=d*k+g*i+j*A+n*R;this.n21=m*O+l*e+o*r+c*M;this.n22=m*u+l*p+o*q+c*Q;this.n23=m*f+l*h+o*L+c*t;this.n24=m*k+l*i+o*A+c*R;this.n31=F*O+D*e+v*r+x*M;this.n32=F*u+D*p+v*q+x*Q;this.n33=F*f+D*h+v*L+x*t;this.n34=F*k+D*i+v*A+x*R;this.n41=H*O+G*e+K*r+N*M;this.n42=H*u+G*p+K*q+N*Q;this.n43=H*f+G*h+K*L+N*t;this.n44=H*k+G*i+K*A+N*R},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,j=this.n14,n=this.n21,m=this.n22, +l=this.n23,o=this.n24,c=this.n31,F=this.n32,D=this.n33,v=this.n34,x=this.n41,H=this.n42,G=this.n43,K=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+j*a.n44;this.n21=n*a.n11+m*a.n21+l*a.n31+o*a.n41;this.n22=n*a.n12+m*a.n22+l*a.n32+o*a.n42;this.n23=n*a.n13+m*a.n23+l*a.n33+o*a.n43;this.n24=n*a.n14+m*a.n24+l*a.n34+o*a.n44;this.n31=c*a.n11+F*a.n21+D*a.n31+v*a.n41;this.n32=c*a.n12+F*a.n22+ +D*a.n32+v*a.n42;this.n33=c*a.n13+F*a.n23+D*a.n33+v*a.n43;this.n34=c*a.n14+F*a.n24+D*a.n34+v*a.n44;this.n41=x*a.n11+H*a.n21+G*a.n31+K*a.n41;this.n42=x*a.n12+H*a.n22+G*a.n32+K*a.n42;this.n43=x*a.n13+H*a.n23+G*a.n33+K*a.n43;this.n44=x*a.n14+H*a.n24+G*a.n34+K*a.n44},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},determinant:function(){return this.n14* this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14* this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,g){var j=b[d];b[d]=b[g];b[g]=j}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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]}, 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,b,d){var g=new THREE.Matrix4;g.n14=a;g.n24=b;g.n34=d;return g};THREE.Matrix4.scaleMatrix=function(a,b,d){var g=new THREE.Matrix4;g.n11=a;g.n22=b;g.n33=d;return g}; THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,g=Math.cos(b),j=Math.sin(b),o=1-g,m=a.x,p=a.y,l=a.z;d.n11=o*m*m+g;d.n12=o*m*p-j*l;d.n13=o*m*l+j*p;d.n21=o*m*p+j*l;d.n22=o*p*p+g;d.n23=o*p*l-j*m;d.n31=o*m*l-j*p;d.n32=o*p*l+j*m;d.n33=o*l*l+g;return d}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,g=Math.cos(b),j=Math.sin(b),n=1-g,m=a.x,l=a.y,o=a.z;d.n11=n*m*m+g;d.n12=n*m*l-j*o;d.n13=n*m*o+j*l;d.n21=n*m*l+j*o;d.n22=n*l*l+g;d.n23=n*l*o-j*m;d.n31=n*m*o-j*l;d.n32=n*l*o+j*m;d.n33=n*o*o+g;return d}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],g=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],o=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],p=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],E=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*o+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*g;a.m[2]=b*j;a.m[3]=b*o;a.m[4]=b*m;a.m[5]=b*p;a.m[6]=b*l;a.m[7]=b*c;a.m[8]=b*E;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,g,j,o){var m,p,l;m=new THREE.Matrix4;p=2*j/(b-a);l=2*j/(g-d);a=(b+a)/(b-a);d=(g+d)/(g-d);g=-(o+j)/(o-j);j=-2*o*j/(o-j);m.n11=p;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=l;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=g;m.n34=j;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,g){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,g)}; -THREE.Matrix4.makeOrtho=function(a,b,d,g,j,o){var m,p,l,c;m=new THREE.Matrix4;p=b-a;l=d-g;c=o-j;a=(b+a)/p;d=(d+g)/l;j=(o+j)/c;m.n11=2/p;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/l;m.n23=0;m.n24=-d;m.n31=0;m.n32=0;m.n33=-2/c;m.n34=-j;m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],g=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],n=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],F=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*g;a.m[2]=b*j;a.m[3]=b*n;a.m[4]=b*m;a.m[5]=b*l;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*F;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,g,j,n){var m,l,o;m=new THREE.Matrix4;l=2*j/(b-a);o=2*j/(g-d);a=(b+a)/(b-a);d=(g+d)/(g-d);g=-(n+j)/(n-j);j=-2*n*j/(n-j);m.n11=l;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=o;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=g;m.n34=j;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,g){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,g)}; +THREE.Matrix4.makeOrtho=function(a,b,d,g,j,n){var m,l,o,c;m=new THREE.Matrix4;l=b-a;o=d-g;c=n-j;a=(b+a)/l;d=(d+g)/o;j=(n+j)/c;m.n11=2/l;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/o;m.n23=0;m.n24=-d;m.n31=0;m.n32=0;m.n33=-2/c;m.n34=-j;m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m}; THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,b,d,g,j){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.material=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,d,g,j,o){this.a=a;this.b=b;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=o instanceof Array?o:[o]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.Face4=function(a,b,d,g,j,n){this.a=a;this.b=b;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=n instanceof Array?n:[n]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||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.geometryChunks={}}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){this.bbox={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 a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y; -if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(E){var G=[];b=0;for(d=E.length;b65535){c[p].counter+=1;l=c[p].hash+"_"+c[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],material:m,vertices:0}}this.geometryChunks[l].faces.push(g);this.geometryChunks[l].vertices+=o}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(F){var D=[];b=0;for(d=F.length;b65535){c[l].counter+=1;o=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:m,vertices:0}}this.geometryChunks[o].faces.push(g);this.geometryChunks[o].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,d,g){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,g);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.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,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; @@ -81,89 +81,89 @@ a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undef this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;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.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);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}this.toString=function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; -THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,g){this.image=a;this.loaded=false;this.mapping=b!==undefined?b:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=g!==undefined?g:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; -THREE.UVMapping=0;THREE.ReflectionMapping=1;THREE.RefractionMapping=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,b){this.image=a;this.mapping=b?b:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (
image: "+this.image+"
mapping: "+this.mapping+"
)"}}; +THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=g!==undefined?g:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; +THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){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.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.Projector=function(){function a(S,z){var f=0,k=1,e=S.z+S.w,n=z.z+z.w,i=-S.z+S.w,h=-z.z+z.w;if(e>=0&&n>=0&&i>=0&&h>=0)return true;else if(e<0&&n<0||i<0&&h<0)return false;else{if(e<0)f=Math.max(f,e/(e-n));else if(n<0)k=Math.min(k,e/(e-n));if(i<0)f=Math.max(f,i/(i-h));else if(h<0)k=Math.min(k,i/(i-h));if(k0&&s.z<1}N=t.geometry.faces;e=0;for(n=N.length;e0&&w.z<1){c=G[E]=G[E]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=t.rotation.z;c.scale.x=t.scale.x*Math.abs(c.x-(w.x+z.projectionMatrix.n11)/(w.w+z.projectionMatrix.n14));c.scale.y=t.scale.y*Math.abs(c.y-(w.y+z.projectionMatrix.n22)/(w.w+z.projectionMatrix.n24));c.material=t.material;b.push(c);E++}}}b.sort(function(Q,C){return C.z-Q.z});return b};this.unprojectVector=function(S,z){var f=new THREE.Matrix4; -f.multiply(THREE.Matrix4.makeInvert(z.matrix),THREE.Matrix4.makeInvert(z.projectionMatrix));f.multiplyVector3(S);return S}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,j,o;this.domElement=document.createElement("div");this.setSize=function(m,p){d=m;g=p;j=d/2;o=g/2};this.render=function(m,p){var l,c,E,G,w,F,O,J;a=b.projectScene(m,p);l=0;for(c=a.length;l0){D.r+=$.r*L;D.g+=$.g*L;D.b+=$.b*L}}else if(L instanceof THREE.PointLight){aa.sub(L.position,Y);aa.normalize();L=U.dot(aa)*T;if(L>0){D.r+=$.r*L;D.g+=$.g*L;D.b+=$.b*L}}}}function b(I,Y,U,D,v,L){if(v.opacity!=0){o(v.opacity);m(v.blending);K=I.positionScreen.x;A=I.positionScreen.y;H=Y.positionScreen.x; -P=Y.positionScreen.y;u=U.positionScreen.x;N=U.positionScreen.y;var $=K,T=A,X=H,ba=P,Z=u,ca=N;r.beginPath();r.moveTo($,T);r.lineTo(X,ba);r.lineTo(Z,ca);r.lineTo($,T);r.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map&&v.map.loaded)j(K,A,H,P,u,N,v.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);else if(v.env_map&&v.env_map.loaded){if(v.env_map.mapping==THREE.ReflectionMapping){aa.copy(D.vertexNormalsWorld[0]);V=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+ -aa.z*camera.matrix.n13)*0.5+0.5;ja=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(D.vertexNormalsWorld[1]);za=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Aa=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(D.vertexNormalsWorld[2]);Ba=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Ca=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)* -0.5+0.5;j(K,A,H,P,u,N,v.env_map.image,V,ja,za,Aa,Ba,Ca)}}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){j(K,A,H,P,u,N,v.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);m(THREE.SubtractiveBlending)}if(va)if(!v.wireframe&&v.shading==THREE.SmoothShading&&D.vertexNormalsWorld.length==3){y.r=x.r=Q.r=ga.r;y.g=x.g=Q.g=ga.g;y.b=x.b=Q.b=ga.b;a(L,D.v1.positionWorld, -D.vertexNormalsWorld[0],y);a(L,D.v2.positionWorld,D.vertexNormalsWorld[1],x);a(L,D.v3.positionWorld,D.vertexNormalsWorld[2],Q);C.r=(x.r+Q.r)*0.5;C.g=(x.g+Q.g)*0.5;C.b=(x.b+Q.b)*0.5;R=p(y,x,Q,C);j(K,A,H,P,u,N,R,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(L,D.centroidWorld,D.normalWorld,ha);s.r=v.color.r*ha.r;s.g=v.color.g*ha.g;s.b=v.color.b*ha.b;s.updateStyleString();v.wireframe?d(s.__styleString,v.wireframe_linewidth):g(s.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth): -g(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){B=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;y.r=y.g=y.b=1-B/(W-I.positionScreen.z*ea);x.r=x.g=x.b=1-B/(W-Y.positionScreen.z*ea);Q.r=Q.g=Q.b=1-B/(W-U.positionScreen.z*ea);C.r=(x.r+Q.r)*0.5;C.g=(x.g+Q.g)*0.5;C.b=(x.b+Q.b)*0.5;R=p(y,x,Q,C);j(K,A,H,P,u,N,R,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){s.r=l(D.normalWorld.x);s.g=l(D.normalWorld.y);s.b=l(D.normalWorld.z);s.updateStyleString();v.wireframe?d(s.__styleString, -v.wireframe_linewidth):g(s.__styleString)}}}function d(I,Y){if(f!=I)r.strokeStyle=f=I;if(e!=Y)r.lineWidth=e=Y;r.stroke();da.inflate(Y*2)}function g(I){if(k!=I)r.fillStyle=k=I;r.fill()}function j(I,Y,U,D,v,L,$,T,X,ba,Z,ca,la){var ka,fa;ka=$.width-1;fa=$.height-1;T*=ka;X*=fa;ba*=ka;Z*=fa;ca*=ka;la*=fa;U-=I;D-=Y;v-=I;L-=Y;ba-=T;Z-=X;ca-=T;la-=X;fa=1/(ba*la-ca*Z);ka=(la*U-Z*v)*fa;Z=(la*D-Z*L)*fa;U=(ba*v-ca*U)*fa;D=(ba*L-ca*D)*fa;I=I-ka*T-U*X;Y=Y-Z*T-D*X;r.save();r.transform(ka,Z,U,D,I,Y);r.clip();r.drawImage($, -0,0);r.restore()}function o(I){if(S!=I)r.globalAlpha=S=I}function m(I){if(z!=I){switch(I){case THREE.NormalBlending:r.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:r.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:r.globalCompositeOperation="darker"}z=I}}function p(I,Y,U,D){ia[0]=i(0,n(255,~~(I.r*255)));ia[1]=i(0,n(255,~~(I.g*255)));ia[2]=i(0,n(255,~~(I.b*255)));ia[4]=i(0,n(255,~~(Y.r*255)));ia[5]=i(0,n(255,~~(Y.g*255)));ia[6]=i(0,n(255,~~(Y.b*255))); -ia[8]=i(0,n(255,~~(U.r*255)));ia[9]=i(0,n(255,~~(U.g*255)));ia[10]=i(0,n(255,~~(U.b*255)));ia[12]=i(0,n(255,~~(D.r*255)));ia[13]=i(0,n(255,~~(D.g*255)));ia[14]=i(0,n(255,~~(D.b*255)));ra.putImageData(wa,0,0);ua.drawImage(sa,0,0);return ta}function l(I){return I<0?n((1+I)*0.5,0.5):0.5+n(I*0.5,0.5)}function c(I,Y){var U=Y.x-I.x,D=Y.y-I.y,v=1/Math.sqrt(U*U+D*D);U*=v;D*=v;Y.x+=U;Y.y+=D;I.x-=U;I.y-=D}var E=null,G=new THREE.Projector,w=document.createElement("canvas"),F,O,J,M,r=w.getContext("2d"),S=1,z= -0,f=null,k=null,e=1,n=Math.min,i=Math.max,h,q,t,K,A,H,P,u,N,s=new THREE.Color,y=new THREE.Color,x=new THREE.Color,Q=new THREE.Color,C=new THREE.Color,B,W,ea,R,V,ja,za,Aa,Ba,Ca,pa=new THREE.Rectangle,ma=new THREE.Rectangle,da=new THREE.Rectangle,va=false,ha=new THREE.Color,ga=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,Da=Math.PI*2,aa=new THREE.Vector3,sa,ra,wa,ia,ta,ua,qa=16;sa=document.createElement("canvas");sa.width=sa.height=2;ra=sa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0, -0,2,2);wa=ra.getImageData(0,0,2,2);ia=wa.data;ta=document.createElement("canvas");ta.width=ta.height=qa;ua=ta.getContext("2d");ua.translate(-qa/2,-qa/2);ua.scale(qa,qa);qa--;this.domElement=w;this.autoClear=true;this.setSize=function(I,Y){F=I;O=Y;J=F/2;M=O/2;w.width=F;w.height=O;pa.set(-J,-M,J,M)};this.clear=function(){if(!ma.isEmpty()){ma.inflate(1);ma.minSelf(pa);r.clearRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());ma.empty()}};this.render=function(I,Y){var U,D,v,L,$,T,X,ba;r.setTransform(1, -0,0,-1,J,M);this.autoClear&&this.clear();E=G.projectScene(I,Y);if(va=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);U=0;for(D=$.length;U>1;ya=fa.height>>1;la=X.scale.x*J;ka=X.scale.y*M;ba=la*xa;ca=ka*ya;da.set(T.x-ba,T.y-ca,T.x+ba,T.y+ca);if(pa.instersects(da)){r.save();r.translate(T.x,T.y);r.rotate(-X.rotation);r.scale(la,-ka);r.translate(-xa,-ya);r.drawImage(fa,0,0); -r.restore()}}}else if(Z instanceof THREE.ParticleCircleMaterial){if(va){ha.r=ga.r+na.r+oa.r;ha.g=ga.g+na.g+oa.g;ha.b=ga.b+na.b+oa.b;s.r=Z.color.r*ha.r;s.g=Z.color.g*ha.g;s.b=Z.color.b*ha.b;s.updateStyleString()}else s.__styleString=Z.color.__styleString;ba=X.scale.x*J;ca=X.scale.y*M;da.set(T.x-ba,T.y-ca,T.x+ba,T.y+ca);if(pa.instersects(da)){Z=s.__styleString;if(k!=Z)r.fillStyle=k=Z;r.save();r.translate(T.x,T.y);r.rotate(-X.rotation);r.scale(ba,ca);r.beginPath();r.arc(0,0,1,0,Da,true);r.closePath(); -r.fill();r.restore()}}}}}else if(v instanceof THREE.RenderableLine){h=v.v1;q=v.v2;h.positionScreen.x*=J;h.positionScreen.y*=M;q.positionScreen.x*=J;q.positionScreen.y*=M;da.addPoint(h.positionScreen.x,h.positionScreen.y);da.addPoint(q.positionScreen.x,q.positionScreen.y);if(pa.instersects(da)){L=0;for($=v.material.length;L<$;){X=h;ba=q;T=v.material[L++];if(T.opacity!=0){o(T.opacity);m(T.blending);r.beginPath();r.moveTo(X.positionScreen.x,X.positionScreen.y);r.lineTo(ba.positionScreen.x,ba.positionScreen.y); -r.closePath();if(T instanceof THREE.LineBasicMaterial){s.__styleString=T.color.__styleString;X=T.linewidth;if(e!=X)r.lineWidth=e=X;X=s.__styleString;if(f!=X)r.strokeStyle=f=X;r.stroke();da.inflate(T.linewidth*2)}}}}}else if(v instanceof THREE.RenderableFace3){h=v.v1;q=v.v2;t=v.v3;h.positionScreen.x*=J;h.positionScreen.y*=M;q.positionScreen.x*=J;q.positionScreen.y*=M;t.positionScreen.x*=J;t.positionScreen.y*=M;if(v.overdraw){c(h.positionScreen,q.positionScreen);c(q.positionScreen,t.positionScreen); -c(t.positionScreen,h.positionScreen)}da.addPoint(h.positionScreen.x,h.positionScreen.y);da.addPoint(q.positionScreen.x,q.positionScreen.y);da.addPoint(t.positionScreen.x,t.positionScreen.y);if(pa.instersects(da)){L=0;for($=v.meshMaterial.length;L<$;){ba=v.meshMaterial[L++];if(ba instanceof THREE.MeshFaceMaterial){T=0;for(X=v.faceMaterial.length;T0){x.r+=B.color.r*W;x.g+=B.color.g*W;x.b+=B.color.b*W}}else if(B instanceof THREE.PointLight){h.sub(B.position,y.centroidWorld);h.normalize();W=y.normalWorld.dot(h)*B.intensity;if(W>0){x.r+=B.color.r*W;x.g+=B.color.g*W;x.b+=B.color.b*W}}}}function b(s,y,x,Q,C,B){A=g(H++);A.setAttribute("d","M "+s.positionScreen.x+ -" "+s.positionScreen.y+" L "+y.positionScreen.x+" "+y.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)z.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(S){f.r=k.r;f.g=k.g;f.b=k.b;a(B,Q,f);z.r=C.color.r*f.r;z.g=C.color.g*f.g;z.b=C.color.b*f.b;z.updateStyleString()}else z.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){i=1-C.__2near/(C.__farPlusNear-Q.z*C.__farMinusNear); -z.setRGB(i,i,i)}else C instanceof THREE.MeshNormalMaterial&&z.setRGB(j(Q.normalWorld.x),j(Q.normalWorld.y),j(Q.normalWorld.z));C.wireframe?A.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):A.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+C.opacity);p.appendChild(A)}function d(s,y,x,Q,C,B,W){A=g(H++);A.setAttribute("d", -"M "+s.positionScreen.x+" "+s.positionScreen.y+" L "+y.positionScreen.x+" "+y.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)z.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(S){f.r=k.r;f.g=k.g;f.b=k.b;a(W,C,f);z.r=B.color.r*f.r;z.g=B.color.g*f.g;z.b=B.color.b*f.b;z.updateStyleString()}else z.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){i= -1-B.__2near/(B.__farPlusNear-C.z*B.__farMinusNear);z.setRGB(i,i,i)}else B instanceof THREE.MeshNormalMaterial&&z.setRGB(j(C.normalWorld.x),j(C.normalWorld.y),j(C.normalWorld.z));B.wireframe?A.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):A.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+B.opacity);p.appendChild(A)} -function g(s){if(q[s]==null){q[s]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&q[s].setAttribute("shape-rendering","crispEdges");return q[s]}return q[s]}function j(s){return s<0?Math.min((1+s)*0.5,0.5):0.5+Math.min(s*0.5,0.5)}var o=null,m=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,E,G,w,F,O,J,M=new THREE.Rectangle,r=new THREE.Rectangle,S=false,z=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),e=new THREE.Color(0), -n=new THREE.Color(0),i,h=new THREE.Vector3,q=[],t=[],K=[],A,H,P,u,N=1;this.domElement=p;this.autoClear=true;this.setQuality=function(s){switch(s){case "high":N=1;break;case "low":N=0}};this.setSize=function(s,y){l=s;c=y;E=l/2;G=c/2;p.setAttribute("viewBox",-E+" "+-G+" "+l+" "+c);p.setAttribute("width",l);p.setAttribute("height",c);M.set(-E,-G,E,G)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};this.render=function(s,y){var x,Q,C,B,W,ea,R,V;this.autoClear&&this.clear(); -o=m.projectScene(s,y);u=P=H=0;if(S=s.lights.length>0){R=s.lights;k.setRGB(0,0,0);e.setRGB(0,0,0);n.setRGB(0,0,0);x=0;for(Q=R.length;x=0&&p>=0&&h>=0&&i>=0)return true;else if(e<0&&p<0||h<0&&i<0)return false;else{if(e<0)f=Math.max(f,e/(e-p));else if(p<0)k=Math.min(k,e/(e-p));if(h<0)f=Math.max(f,h/(h-i));else if(i<0)k=Math.min(k,h/(h-i));if(k0&&y.z<1}R=q.geometry.faces;e=0;for(p=R.length;e0&&v.z<1){c=D[F]=D[F]||new THREE.RenderableParticle;c.x=v.x/v.w;c.y=v.y/v.w;c.z=v.z;c.rotation=q.rotation.z;c.scale.x=q.scale.x*Math.abs(c.x-(v.x+u.projectionMatrix.n11)/(v.w+u.projectionMatrix.n14));c.scale.y=q.scale.y*Math.abs(c.y-(v.y+u.projectionMatrix.n22)/(v.w+u.projectionMatrix.n24));c.material=q.material;b.push(c);F++}}}b.sort(function(W,I){return I.z-W.z});return b};this.unprojectVector=function(O,u){var f=new THREE.Matrix4; +f.multiply(THREE.Matrix4.makeInvert(u.matrix),THREE.Matrix4.makeInvert(u.projectionMatrix));f.multiplyVector3(O);return O}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,j,n;this.domElement=document.createElement("div");this.setSize=function(m,l){d=m;g=l;j=d/2;n=g/2};this.render=function(m,l){var o,c,F,D,v,x,H,G;a=b.projectScene(m,l);o=0;for(c=a.length;o0){s.r+=ba.r*V;s.g+=ba.g*V;s.b+=ba.b*V}}else if(V instanceof THREE.PointLight){Y.sub(V.position,T);Y.normalize();V=J.dot(Y)*da;if(V>0){s.r+=ba.r*V;s.g+=ba.g*V;s.b+=ba.b*V}}}}function Na(w,T,J){if(J.opacity!=0){Da(J.opacity);ya(J.blending);var s,C,V,ba,da,ea;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){ba=J.map;da=ba.width>>1;ea=ba.height>>1;C=T.scale.x*n;V=T.scale.y*m;J=C*da;s=V*ea;X.set(w.x-J, +w.y-s,w.x+J,w.y+s);if(B.instersects(X)){l.save();l.translate(w.x,w.y);l.rotate(-T.rotation);l.scale(C,-V);l.translate(-da,-ea);l.drawImage(ba,0,0);l.restore()}}}else if(J instanceof THREE.ParticleCircleMaterial){if(S){P.r=Z.r+ja.r+ka.r;P.g=Z.g+ja.g+ka.g;P.b=Z.b+ja.b+ka.b;h.r=J.color.r*P.r;h.g=J.color.g*P.g;h.b=J.color.b*P.b;h.updateStyleString()}else h.__styleString=J.color.__styleString;J=T.scale.x*n;s=T.scale.y*m;X.set(w.x-J,w.y-s,w.x+J,w.y+s);if(B.instersects(X)){C=h.__styleString;if(D!=C)l.fillStyle= +D=C;l.save();l.translate(w.x,w.y);l.rotate(-T.rotation);l.scale(J,s);l.beginPath();l.arc(0,0,1,0,La,true);l.closePath();l.fill();l.restore()}}}}function Oa(w,T,J,s){if(s.opacity!=0){Da(s.opacity);ya(s.blending);l.beginPath();l.moveTo(w.positionScreen.x,w.positionScreen.y);l.lineTo(T.positionScreen.x,T.positionScreen.y);l.closePath();if(s instanceof THREE.LineBasicMaterial){h.__styleString=s.color.__styleString;w=s.linewidth;if(v!=w)l.lineWidth=v=w;w=h.__styleString;if(F!=w)l.strokeStyle=F=w;l.stroke(); +X.inflate(s.linewidth*2)}}}function Ha(w,T,J,s,C,V){if(C.opacity!=0){Da(C.opacity);ya(C.blending);O=w.positionScreen.x;u=w.positionScreen.y;f=T.positionScreen.x;k=T.positionScreen.y;e=J.positionScreen.x;p=J.positionScreen.y;l.beginPath();l.moveTo(O,u);l.lineTo(f,k);l.lineTo(e,p);l.lineTo(O,u);l.closePath();if(C instanceof THREE.MeshBasicMaterial)if(C.map&&!C.wireframe)C.map.mapping instanceof THREE.UVMapping&&ra(O,u,f,k,e,p,C.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(C.env_map){if(C.env_map.mapping instanceof THREE.SphericalReflectionMapping){Y.copy(s.vertexNormalsWorld[0]);R=(Y.x*aa.matrix.n11+Y.y*aa.matrix.n12+Y.z*aa.matrix.n13)*0.5+0.5;y=-(Y.x*aa.matrix.n21+Y.y*aa.matrix.n22+Y.z*aa.matrix.n23)*0.5+0.5;Y.copy(s.vertexNormalsWorld[1]);z=(Y.x*aa.matrix.n11+Y.y*aa.matrix.n12+Y.z*aa.matrix.n13)*0.5+0.5;E=-(Y.x*aa.matrix.n21+Y.y*aa.matrix.n22+Y.z*aa.matrix.n23)*0.5+0.5;Y.copy(s.vertexNormalsWorld[2]);W=(Y.x*aa.matrix.n11+Y.y*aa.matrix.n12+Y.z*aa.matrix.n13)* +0.5+0.5;I=-(Y.x*aa.matrix.n21+Y.y*aa.matrix.n22+Y.z*aa.matrix.n23)*0.5+0.5;ra(O,u,f,k,e,p,C.env_map.image,R,y,z,E,W,I)}}else C.wireframe?za(C.color.__styleString,C.wireframe_linewidth):Aa(C.color.__styleString);else if(C instanceof THREE.MeshLambertMaterial){if(C.map&&!C.wireframe){C.map.mapping instanceof THREE.UVMapping&&ra(O,u,f,k,e,p,C.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);ya(THREE.SubtractiveBlending)}if(S)if(!C.wireframe&&C.shading==THREE.SmoothShading&& +s.vertexNormalsWorld.length==3){i.r=r.r=q.r=Z.r;i.g=r.g=q.g=Z.g;i.b=r.b=q.b=Z.b;xa(V,s.v1.positionWorld,s.vertexNormalsWorld[0],i);xa(V,s.v2.positionWorld,s.vertexNormalsWorld[1],r);xa(V,s.v3.positionWorld,s.vertexNormalsWorld[2],q);L.r=(r.r+q.r)*0.5;L.g=(r.g+q.g)*0.5;L.b=(r.b+q.b)*0.5;t=Ia(i,r,q,L);ra(O,u,f,k,e,p,t,0,0,1,0,0,1)}else{P.r=Z.r;P.g=Z.g;P.b=Z.b;xa(V,s.centroidWorld,s.normalWorld,P);h.r=C.color.r*P.r;h.g=C.color.g*P.g;h.b=C.color.b*P.b;h.updateStyleString();C.wireframe?za(h.__styleString, +C.wireframe_linewidth):Aa(h.__styleString)}else C.wireframe?za(C.color.__styleString,C.wireframe_linewidth):Aa(C.color.__styleString)}else if(C instanceof THREE.MeshDepthMaterial){A=C.__2near;M=C.__farPlusNear;Q=C.__farMinusNear;i.r=i.g=i.b=1-A/(M-w.positionScreen.z*Q);r.r=r.g=r.b=1-A/(M-T.positionScreen.z*Q);q.r=q.g=q.b=1-A/(M-J.positionScreen.z*Q);L.r=(r.r+q.r)*0.5;L.g=(r.g+q.g)*0.5;L.b=(r.b+q.b)*0.5;t=Ia(i,r,q,L);ra(O,u,f,k,e,p,t,0,0,1,0,0,1)}else if(C instanceof THREE.MeshNormalMaterial){h.r= +Ea(s.normalWorld.x);h.g=Ea(s.normalWorld.y);h.b=Ea(s.normalWorld.z);h.updateStyleString();C.wireframe?za(h.__styleString,C.wireframe_linewidth):Aa(h.__styleString)}}}function za(w,T){if(F!=w)l.strokeStyle=F=w;if(v!=T)l.lineWidth=v=T;l.stroke();X.inflate(T*2)}function Aa(w){if(D!=w)l.fillStyle=D=w;l.fill()}function ra(w,T,J,s,C,V,ba,da,ea,sa,ia,ta,ua){var la,ha;la=ba.width-1;ha=ba.height-1;da*=la;ea*=ha;sa*=la;ia*=ha;ta*=la;ua*=ha;J-=w;s-=T;C-=w;V-=T;sa-=da;ia-=ea;ta-=da;ua-=ea;ha=1/(sa*ua-ta*ia); +la=(ua*J-ia*C)*ha;ia=(ua*s-ia*V)*ha;J=(sa*C-ta*J)*ha;s=(sa*V-ta*s)*ha;w=w-la*da-J*ea;T=T-ia*da-s*ea;l.save();l.transform(la,ia,J,s,w,T);l.clip();l.drawImage(ba,0,0);l.restore()}function Da(w){if(o!=w)l.globalAlpha=o=w}function ya(w){if(c!=w){switch(w){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=w}}function Ia(w,T,J,s){ca[0]=H(0,x(255, +~~(w.r*255)));ca[1]=H(0,x(255,~~(w.g*255)));ca[2]=H(0,x(255,~~(w.b*255)));ca[4]=H(0,x(255,~~(T.r*255)));ca[5]=H(0,x(255,~~(T.g*255)));ca[6]=H(0,x(255,~~(T.b*255)));ca[8]=H(0,x(255,~~(J.r*255)));ca[9]=H(0,x(255,~~(J.g*255)));ca[10]=H(0,x(255,~~(J.b*255)));ca[12]=H(0,x(255,~~(s.r*255)));ca[13]=H(0,x(255,~~(s.g*255)));ca[14]=H(0,x(255,~~(s.b*255)));pa.putImageData(Ca,0,0);wa.drawImage(oa,0,0);return qa}function Ea(w){return w<0?x((1+w)*0.5,0.5):0.5+x(w*0.5,0.5)}function Fa(w,T){var J=T.x-w.x,s=T.y-w.y, +C=1/Math.sqrt(J*J+s*s);J*=C;s*=C;T.x+=J;T.y+=s;w.x-=J;w.y-=s}var Ba,Ja,$,fa,na,Ga,Ka,va;l.setTransform(1,0,0,-1,n,m);this.autoClear&&this.clear();a=b.projectScene(ga,aa);(S=ga.lights.length>0)&&Ma(ga);Ba=0;for(Ja=a.length;Ba0){E.r+=B.color.r*U;E.g+=B.color.g*U;E.b+=B.color.b*U}}else if(B instanceof THREE.PointLight){i.sub(B.position,z.centroidWorld);i.normalize();U=z.normalWorld.dot(i)*B.intensity;if(U>0){E.r+=B.color.r*U;E.g+=B.color.g*U;E.b+=B.color.b*U}}}}function b(y,z,E,W,I,B){A=g(M++);A.setAttribute("d","M "+y.positionScreen.x+ +" "+y.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)u.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(O){f.r=k.r;f.g=k.g;f.b=k.b;a(B,W,f);u.r=I.color.r*f.r;u.g=I.color.g*f.g;u.b=I.color.b*f.b;u.updateStyleString()}else u.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){h=1-I.__2near/(I.__farPlusNear-W.z*I.__farMinusNear); +u.setRGB(h,h,h)}else I instanceof THREE.MeshNormalMaterial&&u.setRGB(j(W.normalWorld.x),j(W.normalWorld.y),j(W.normalWorld.z));I.wireframe?A.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):A.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+I.opacity);l.appendChild(A)}function d(y,z,E,W,I,B,U){A=g(M++);A.setAttribute("d", +"M "+y.positionScreen.x+" "+y.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)u.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(O){f.r=k.r;f.g=k.g;f.b=k.b;a(U,I,f);u.r=B.color.r*f.r;u.g=B.color.g*f.g;u.b=B.color.b*f.b;u.updateStyleString()}else u.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){h= +1-B.__2near/(B.__farPlusNear-I.z*B.__farMinusNear);u.setRGB(h,h,h)}else B instanceof THREE.MeshNormalMaterial&&u.setRGB(j(I.normalWorld.x),j(I.normalWorld.y),j(I.normalWorld.z));B.wireframe?A.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):A.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+B.opacity);l.appendChild(A)} +function g(y){if(r[y]==null){r[y]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&r[y].setAttribute("shape-rendering","crispEdges");return r[y]}return r[y]}function j(y){return y<0?Math.min((1+y)*0.5,0.5):0.5+Math.min(y*0.5,0.5)}var n=null,m=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,F,D,v,x,H,G,K=new THREE.Rectangle,N=new THREE.Rectangle,O=false,u=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),e=new THREE.Color(0), +p=new THREE.Color(0),h,i=new THREE.Vector3,r=[],q=[],L=[],A,M,Q,t,R=1;this.domElement=l;this.autoClear=true;this.setQuality=function(y){switch(y){case "high":R=1;break;case "low":R=0}};this.setSize=function(y,z){o=y;c=z;F=o/2;D=c/2;l.setAttribute("viewBox",-F+" "+-D+" "+o+" "+c);l.setAttribute("width",o);l.setAttribute("height",c);K.set(-F,-D,F,D)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(y,z){var E,W,I,B,U,X,S,P;this.autoClear&&this.clear(); +n=m.projectScene(y,z);t=Q=M=0;if(O=y.lights.length>0){S=y.lights;k.setRGB(0,0,0);e.setRGB(0,0,0);p.setRGB(0,0,0);E=0;for(W=S.length;E=0&&c.enableVertexAttribArray(f.attributes[i])}}function m(f,k){var e;if(f=="fragment")e=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")e=c.createShader(c.VERTEX_SHADER);c.shaderSource(e,k);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(e)); -return null}return e}function p(f){switch(f){case THREE.Repeat:return c.REPEAT;case THREE.ClampToEdge:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return c.MIRRORED_REPEAT}return 0}var l=document.createElement("canvas"),c,E,G,w=new THREE.Matrix4,F,O=new Float32Array(16),J=new Float32Array(16),M=new Float32Array(16),r=new Float32Array(9),S=new Float32Array(16);a=function(f,k){if(f){var e,n,i,h=pointLights=maxDirLights=maxPointLights=0;e=0;for(n=f.lights.length;e=0&&c.enableVertexAttribArray(f.attributes[h])}}function m(f,k){var e;if(f=="fragment")e=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")e=c.createShader(c.VERTEX_SHADER);c.shaderSource(e,k);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(e)); +return null}return e}function l(f){switch(f){case THREE.Repeat:return c.REPEAT;case THREE.ClampToEdge:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return c.MIRRORED_REPEAT}return 0}var o=document.createElement("canvas"),c,F,D,v=new THREE.Matrix4,x,H=new Float32Array(16),G=new Float32Array(16),K=new Float32Array(16),N=new Float32Array(9),O=new Float32Array(16);a=function(f,k){if(f){var e,p,h,i=pointLights=maxDirLights=maxPointLights=0;e=0;for(p=f.lights.length;e= 0.0 )": "",k?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",k?"pointDiffuse += mColor * pointDiffuseWeight;":"",k?"pointSpecular += mSpecular * pointSpecularWeight;":"",k?"}":"",f?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",f?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",f?"vec3 dirVector = normalize( lDirection.xyz );":"",f?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": "",f?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",f?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",f?"float dirSpecularWeight = 0.0;":"",f?"if ( dirDotNormalHalf >= 0.0 )":"",f?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",f?"dirDiffuse += mColor * dirDiffuseWeight;":"",f?"dirSpecular += mSpecular * dirSpecularWeight;":"",f?"}":"","vec4 totalLight = mAmbient;",f?"totalLight += dirDiffuse + dirSpecular;":"",k?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n"); -e=b(n,e);c.useProgram(e);j(e,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);f&&j(e,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);k&&j(e,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(e.uniforms.enableMap,0);c.uniform1i(e.uniforms.tMap,0);c.uniform1i(e.uniforms.enableCubeMap,0);c.uniform1i(e.uniforms.tCube,1);c.uniform1i(e.uniforms.mixEnvMap,0);c.uniform1i(e.uniforms.useRefract,0);o(e,["position","normal","uv"]);return e}(a.directional,a.point);this.setSize=function(f,k){l.width=f;l.height=k;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,k){var e,n,i,h,q,t=[], -K=[],A=[];h=[];q=[];c.uniform1i(f.uniforms.enableLighting,k.length);e=0;for(n=k.length;e0){x.__webGLUVBuffer=c.createBuffer(); -c.bindBuffer(c.ARRAY_BUFFER,x.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(s),c.STATIC_DRAW)}x.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);x.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(P),c.STATIC_DRAW);x.__webGLFaceCount=H.length;x.__webGLLineCount=P.length}};this.renderBuffer= -function(f,k,e,n){var i,h,q,t,K,A,H,P,u;if(e instanceof THREE.MeshShaderMaterial){if(!e.program){e.program=b(e.fragment_shader,e.vertex_shader);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in e.uniforms)H.push(u);j(e.program,H);o(e.program,["position","normal","uv"])}u=e.program}else u=G;if(u!=E){c.useProgram(u);E=u}u==G&&this.setupLights(u,k);this.loadCamera(u,f);this.loadMatrices(u);if(e instanceof THREE.MeshShaderMaterial){q=e.wireframe; -t=e.wireframe_linewidth;f=u;k=e.uniforms;var N;for(i in k){P=k[i].type;H=k[i].value;N=f.uniforms[i];if(P=="i")c.uniform1i(N,H);else if(P=="f")c.uniform1f(N,H);else if(P=="t"){c.uniform1i(N,H);P=k[i].texture;if(P instanceof THREE.TextureCube)d(P,H);else P instanceof THREE.Texture&&g(P,H)}}}if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){i=e.color;h=e.opacity;q=e.wireframe;t=e.wireframe_linewidth;K=e.map;A=e.env_map;k=e.combine== -THREE.Mix;f=e.reflectivity;P=e.env_map&&e.env_map.mapping==THREE.RefractionMapping;H=e.refraction_ratio;c.uniform4f(u.uniforms.mColor,i.r*h,i.g*h,i.b*h,h);c.uniform1i(u.uniforms.mixEnvMap,k);c.uniform1f(u.uniforms.mReflectivity,f);c.uniform1i(u.uniforms.useRefract,P);c.uniform1f(u.uniforms.mRefractionRatio,H)}if(e instanceof THREE.MeshNormalMaterial){h=e.opacity;c.uniform1f(u.uniforms.mOpacity,h);c.uniform1i(u.uniforms.material,4)}else if(e instanceof THREE.MeshDepthMaterial){h=e.opacity;q=e.wireframe; -t=e.wireframe_linewidth;c.uniform1f(u.uniforms.mOpacity,h);c.uniform1f(u.uniforms.m2Near,e.__2near);c.uniform1f(u.uniforms.mFarPlusNear,e.__farPlusNear);c.uniform1f(u.uniforms.mFarMinusNear,e.__farMinusNear);c.uniform1i(u.uniforms.material,3)}else if(e instanceof THREE.MeshPhongMaterial){i=e.ambient;f=e.specular;e=e.shininess;c.uniform4f(u.uniforms.mAmbient,i.r,i.g,i.b,h);c.uniform4f(u.uniforms.mSpecular,f.r,f.g,f.b,h);c.uniform1f(u.uniforms.mShininess,e);c.uniform1i(u.uniforms.material,2)}else if(e instanceof -THREE.MeshLambertMaterial)c.uniform1i(u.uniforms.material,1);else if(e instanceof THREE.MeshBasicMaterial)c.uniform1i(u.uniforms.material,0);else if(e instanceof THREE.MeshCubeMaterial){c.uniform1i(u.uniforms.material,5);A=e.env_map}if(K){g(K,0);c.uniform1i(u.uniforms.tMap,0);c.uniform1i(u.uniforms.enableMap,1)}else c.uniform1i(u.uniforms.enableMap,0);if(A){d(A,1);c.uniform1i(u.uniforms.tCube,1);c.uniform1i(u.uniforms.enableCubeMap,1)}else c.uniform1i(u.uniforms.enableCubeMap,0);h=u.attributes;c.bindBuffer(c.ARRAY_BUFFER, -n.__webGLVertexBuffer);c.vertexAttribPointer(h.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(h.normal,3,c.FLOAT,false,0,0);if(h.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.enableVertexAttribArray(h.uv);c.vertexAttribPointer(h.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(h.uv);if(q){c.lineWidth(t);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT, -0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,k,e,n,i,h){var q,t,K,A,H;K=0;for(A=e.material.length;K=0;e--){n=f.__webGLObjects[e].object;k==n&&f.__webGLObjects.splice(e,1)}};this.setupMatrices=function(f,k){f.autoUpdateMatrix&&f.updateMatrix();w.multiply(k.matrix,f.matrix);O.set(k.matrix.flatten());J.set(w.flatten());M.set(k.projectionMatrix.flatten());F=THREE.Matrix4.makeInvert3x3(w).transpose(); -r.set(F.m);S.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,O);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,J);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,r);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,S)};this.loadCamera=function(f,k){c.uniform3f(f.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); +e=b(p,e);c.useProgram(e);j(e,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);f&&j(e,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);k&&j(e,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(e.uniforms.enableMap,0);c.uniform1i(e.uniforms.tMap,0);c.uniform1i(e.uniforms.enableCubeMap,0);c.uniform1i(e.uniforms.tCube,1);c.uniform1i(e.uniforms.mixEnvMap,0);c.uniform1i(e.uniforms.useRefract,0);n(e,["position","normal","uv"]);return e}(a.directional,a.point);this.setSize=function(f,k){o.width=f;o.height=k;c.viewport(0,0,o.width,o.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,k){var e,p,h,i,r,q=[], +L=[],A=[];i=[];r=[];c.uniform1i(f.uniforms.enableLighting,k.length);e=0;for(p=k.length;e0){E.__webGLUVBuffer=c.createBuffer(); +c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(y),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(M),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);E.__webGLFaceCount=M.length;E.__webGLLineCount=Q.length}};this.renderBuffer= +function(f,k,e,p){var h,i,r,q,L,A,M,Q,t;if(e instanceof THREE.MeshShaderMaterial){if(!e.program){e.program=b(e.fragment_shader,e.vertex_shader);M=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in e.uniforms)M.push(t);j(e.program,M);n(e.program,["position","normal","uv"])}t=e.program}else t=D;if(t!=F){c.useProgram(t);F=t}t==D&&this.setupLights(t,k);this.loadCamera(t,f);this.loadMatrices(t);if(e instanceof THREE.MeshShaderMaterial){r=e.wireframe; +q=e.wireframe_linewidth;f=t;k=e.uniforms;var R;for(h in k){Q=k[h].type;M=k[h].value;R=f.uniforms[h];if(Q=="i")c.uniform1i(R,M);else if(Q=="f")c.uniform1f(R,M);else if(Q=="t"){c.uniform1i(R,M);Q=k[h].texture;if(Q instanceof THREE.TextureCube)d(Q,M);else Q instanceof THREE.Texture&&g(Q,M)}}}if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){h=e.color;i=e.opacity;r=e.wireframe;q=e.wireframe_linewidth;L=e.map;A=e.env_map;k=e.combine== +THREE.Mix;f=e.reflectivity;Q=e.env_map&&e.env_map.mapping==THREE.RefractionMapping;M=e.refraction_ratio;c.uniform4f(t.uniforms.mColor,h.r*i,h.g*i,h.b*i,i);c.uniform1i(t.uniforms.mixEnvMap,k);c.uniform1f(t.uniforms.mReflectivity,f);c.uniform1i(t.uniforms.useRefract,Q);c.uniform1f(t.uniforms.mRefractionRatio,M)}if(e instanceof THREE.MeshNormalMaterial){i=e.opacity;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1i(t.uniforms.material,4)}else if(e instanceof THREE.MeshDepthMaterial){i=e.opacity;r=e.wireframe; +q=e.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1f(t.uniforms.m2Near,e.__2near);c.uniform1f(t.uniforms.mFarPlusNear,e.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,e.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(e instanceof THREE.MeshPhongMaterial){h=e.ambient;f=e.specular;e=e.shininess;c.uniform4f(t.uniforms.mAmbient,h.r,h.g,h.b,i);c.uniform4f(t.uniforms.mSpecular,f.r,f.g,f.b,i);c.uniform1f(t.uniforms.mShininess,e);c.uniform1i(t.uniforms.material,2)}else if(e instanceof +THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(e instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(e instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);A=e.env_map}if(L){g(L,0);c.uniform1i(t.uniforms.tMap,0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(A){d(A,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);i=t.attributes;c.bindBuffer(c.ARRAY_BUFFER, +p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0);if(i.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(r){c.lineWidth(q);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT, +0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,k,e,p,h,i){var r,q,L,A,M;L=0;for(A=e.material.length;L=0;e--){p=f.__webGLObjects[e].object;k==p&&f.__webGLObjects.splice(e,1)}};this.setupMatrices=function(f,k){f.autoUpdateMatrix&&f.updateMatrix();v.multiply(k.matrix,f.matrix);H.set(k.matrix.flatten());G.set(v.flatten());K.set(k.projectionMatrix.flatten());x=THREE.Matrix4.makeInvert3x3(v).transpose(); +N.set(x.m);O.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,H);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,G);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,N);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,O)};this.loadCamera=function(f,k){c.uniform3f(f.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,k){if(f){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}}; 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.faceMaterial=this.meshMaterial=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.material=null}; THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index b0e45271dd..dcb27b2420 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -12,44 +12,44 @@ THREE.Vector4=function(a,b,d,g){this.x=a||0;this.y=b||0;this.z=d||0;this.w=g||1} THREE.Vector4.prototype={set:function(a,b,d,g){this.x=a;this.y=b;this.z=d;this.w=g;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},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,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,d,g=a.objects,j=[];a=0;for(b=g.length;a0&&M>0&&k+M<1}var d,g,j,p,m,q,l,c,E,G, -w,F=a.geometry,P=F.vertices,J=[];d=0;for(g=F.faces.length;d= -0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){q=true;j=g=d=b=0;a()};this.isEmpty=function(){return q};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+g+", top: "+d+", bottom: "+j+", width: "+p+", height: "+m+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,g=a.objects,j=[];a=0;for(b=g.length;a0&&K>0&&l+K<1}var d,g,j,n,m,k,o,c,F,D, +w,x=a.geometry,H=x.vertices,G=[];d=0;for(g=x.faces.length;d= +0&&Math.min(j,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){k=true;j=g=d=b=0;a()};this.isEmpty=function(){return k};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+g+", top: "+d+", bottom: "+j+", width: "+n+", height: "+m+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; THREE.Matrix4=function(){}; THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,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},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},lookAt:function(a,b,d){var g=new THREE.Vector3,j=new THREE.Vector3,p=new THREE.Vector3;p.sub(a,b).normalize();g.cross(d,p).normalize();j.cross(p,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=p.x;this.n32=p.y;this.n33=p.z;this.n34=-p.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,g=a.z,j=1/(this.n41*b+this.n42* +a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(a,b,d){var g=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();g.cross(d,n).normalize();j.cross(n,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=n.x;this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,g=a.z,j=1/(this.n41*b+this.n42* d+this.n43*g+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*g+this.n14)*j;a.y=(this.n21*b+this.n22*d+this.n23*g+this.n24)*j;a.z=(this.n31*b+this.n32*d+this.n33*g+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,d=a.y,g=a.z,j=a.w;a.x=this.n11*b+this.n12*d+this.n13*g+this.n14*j;a.y=this.n21*b+this.n22*d+this.n23*g+this.n24*j;a.z=this.n31*b+this.n32*d+this.n33*g+this.n34*j;a.w=this.n41*b+this.n42*d+this.n43*g+this.n44*j;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11* -a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,g=a.n12,j=a.n13,p=a.n14,m=a.n21,q=a.n22,l=a.n23,c=a.n24,E=a.n31,G=a.n32,w=a.n33,F=a.n34,P=a.n41,J=a.n42,M=a.n43,o=a.n44,T=b.n11,z=b.n12,f=b.n13,k=b.n14,e=b.n21,n=b.n22,i=b.n23,h=b.n24,r=b.n31,t=b.n32,K=b.n33,A=b.n34,H=b.n41,Q=b.n42,u=b.n43, -O=b.n44;this.n11=d*T+g*e+j*r+p*H;this.n12=d*z+g*n+j*t+p*Q;this.n13=d*f+g*i+j*K+p*u;this.n14=d*k+g*h+j*A+p*O;this.n21=m*T+q*e+l*r+c*H;this.n22=m*z+q*n+l*t+c*Q;this.n23=m*f+q*i+l*K+c*u;this.n24=m*k+q*h+l*A+c*O;this.n31=E*T+G*e+w*r+F*H;this.n32=E*z+G*n+w*t+F*Q;this.n33=E*f+G*i+w*K+F*u;this.n34=E*k+G*h+w*A+F*O;this.n41=P*T+J*e+M*r+o*H;this.n42=P*z+J*n+M*t+o*Q;this.n43=P*f+J*i+M*K+o*u;this.n44=P*k+J*h+M*A+o*O},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,j=this.n14,p=this.n21,m=this.n22, -q=this.n23,l=this.n24,c=this.n31,E=this.n32,G=this.n33,w=this.n34,F=this.n41,P=this.n42,J=this.n43,M=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+j*a.n44;this.n21=p*a.n11+m*a.n21+q*a.n31+l*a.n41;this.n22=p*a.n12+m*a.n22+q*a.n32+l*a.n42;this.n23=p*a.n13+m*a.n23+q*a.n33+l*a.n43;this.n24=p*a.n14+m*a.n24+q*a.n34+l*a.n44;this.n31=c*a.n11+E*a.n21+G*a.n31+w*a.n41;this.n32=c*a.n12+E*a.n22+ -G*a.n32+w*a.n42;this.n33=c*a.n13+E*a.n23+G*a.n33+w*a.n43;this.n34=c*a.n14+E*a.n24+G*a.n34+w*a.n44;this.n41=F*a.n11+P*a.n21+J*a.n31+M*a.n41;this.n42=F*a.n12+P*a.n22+J*a.n32+M*a.n42;this.n43=F*a.n13+P*a.n23+J*a.n33+M*a.n43;this.n44=F*a.n14+P*a.n24+J*a.n34+M*a.n44},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},determinant:function(){return this.n14* +a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,g=a.n12,j=a.n13,n=a.n14,m=a.n21,k=a.n22,o=a.n23,c=a.n24,F=a.n31,D=a.n32,w=a.n33,x=a.n34,H=a.n41,G=a.n42,K=a.n43,N=a.n44,O=b.n11,v=b.n12,f=b.n13,l=b.n14,e=b.n21,p=b.n22,h=b.n23,i=b.n24,r=b.n31,q=b.n32,L=b.n33,B=b.n34,M=b.n41,Q=b.n42,t=b.n43, +R=b.n44;this.n11=d*O+g*e+j*r+n*M;this.n12=d*v+g*p+j*q+n*Q;this.n13=d*f+g*h+j*L+n*t;this.n14=d*l+g*i+j*B+n*R;this.n21=m*O+k*e+o*r+c*M;this.n22=m*v+k*p+o*q+c*Q;this.n23=m*f+k*h+o*L+c*t;this.n24=m*l+k*i+o*B+c*R;this.n31=F*O+D*e+w*r+x*M;this.n32=F*v+D*p+w*q+x*Q;this.n33=F*f+D*h+w*L+x*t;this.n34=F*l+D*i+w*B+x*R;this.n41=H*O+G*e+K*r+N*M;this.n42=H*v+G*p+K*q+N*Q;this.n43=H*f+G*h+K*L+N*t;this.n44=H*l+G*i+K*B+N*R},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,j=this.n14,n=this.n21,m=this.n22, +k=this.n23,o=this.n24,c=this.n31,F=this.n32,D=this.n33,w=this.n34,x=this.n41,H=this.n42,G=this.n43,K=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+j*a.n44;this.n21=n*a.n11+m*a.n21+k*a.n31+o*a.n41;this.n22=n*a.n12+m*a.n22+k*a.n32+o*a.n42;this.n23=n*a.n13+m*a.n23+k*a.n33+o*a.n43;this.n24=n*a.n14+m*a.n24+k*a.n34+o*a.n44;this.n31=c*a.n11+F*a.n21+D*a.n31+w*a.n41;this.n32=c*a.n12+F*a.n22+ +D*a.n32+w*a.n42;this.n33=c*a.n13+F*a.n23+D*a.n33+w*a.n43;this.n34=c*a.n14+F*a.n24+D*a.n34+w*a.n44;this.n41=x*a.n11+H*a.n21+G*a.n31+K*a.n41;this.n42=x*a.n12+H*a.n22+G*a.n32+K*a.n42;this.n43=x*a.n13+H*a.n23+G*a.n33+K*a.n43;this.n44=x*a.n14+H*a.n24+G*a.n34+K*a.n44},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},determinant:function(){return this.n14* this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14* this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,g){var j=b[d];b[d]=b[g];b[g]=j}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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]}, 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,b,d){var g=new THREE.Matrix4;g.n14=a;g.n24=b;g.n34=d;return g};THREE.Matrix4.scaleMatrix=function(a,b,d){var g=new THREE.Matrix4;g.n11=a;g.n22=b;g.n33=d;return g}; THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,g=Math.cos(b),j=Math.sin(b),p=1-g,m=a.x,q=a.y,l=a.z;d.n11=p*m*m+g;d.n12=p*m*q-j*l;d.n13=p*m*l+j*q;d.n21=p*m*q+j*l;d.n22=p*q*q+g;d.n23=p*q*l-j*m;d.n31=p*m*l-j*q;d.n32=p*q*l+j*m;d.n33=p*l*l+g;return d}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,g=Math.cos(b),j=Math.sin(b),n=1-g,m=a.x,k=a.y,o=a.z;d.n11=n*m*m+g;d.n12=n*m*k-j*o;d.n13=n*m*o+j*k;d.n21=n*m*k+j*o;d.n22=n*k*k+g;d.n23=n*k*o-j*m;d.n31=n*m*o-j*k;d.n32=n*k*o+j*m;d.n33=n*o*o+g;return d}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],g=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],p=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],q=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],E=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*p+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*g;a.m[2]=b*j;a.m[3]=b*p;a.m[4]=b*m;a.m[5]=b*q;a.m[6]=b*l;a.m[7]=b*c;a.m[8]=b*E;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,g,j,p){var m,q,l;m=new THREE.Matrix4;q=2*j/(b-a);l=2*j/(g-d);a=(b+a)/(b-a);d=(g+d)/(g-d);g=-(p+j)/(p-j);j=-2*p*j/(p-j);m.n11=q;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=l;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=g;m.n34=j;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,g){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,g)}; -THREE.Matrix4.makeOrtho=function(a,b,d,g,j,p){var m,q,l,c;m=new THREE.Matrix4;q=b-a;l=d-g;c=p-j;a=(b+a)/q;d=(d+g)/l;j=(p+j)/c;m.n11=2/q;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/l;m.n23=0;m.n24=-d;m.n31=0;m.n32=0;m.n33=-2/c;m.n34=-j;m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],g=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],n=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],F=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*g;a.m[2]=b*j;a.m[3]=b*n;a.m[4]=b*m;a.m[5]=b*k;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*F;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,g,j,n){var m,k,o;m=new THREE.Matrix4;k=2*j/(b-a);o=2*j/(g-d);a=(b+a)/(b-a);d=(g+d)/(g-d);g=-(n+j)/(n-j);j=-2*n*j/(n-j);m.n11=k;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=o;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=g;m.n34=j;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,g){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,g)}; +THREE.Matrix4.makeOrtho=function(a,b,d,g,j,n){var m,k,o,c;m=new THREE.Matrix4;k=b-a;o=d-g;c=n-j;a=(b+a)/k;d=(d+g)/o;j=(n+j)/c;m.n11=2/k;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/o;m.n23=0;m.n24=-d;m.n31=0;m.n32=0;m.n33=-2/c;m.n34=-j;m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m}; THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,b,d,g,j){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.material=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,d,g,j,p){this.a=a;this.b=b;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=p instanceof Array?p:[p]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.Face4=function(a,b,d,g,j,n){this.a=a;this.b=b;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=n instanceof Array?n:[n]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||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.geometryChunks={}}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){this.bbox={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 a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y; -if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(E){var G=[];b=0;for(d=E.length;b65535){c[q].counter+=1;l=c[q].hash+"_"+c[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],material:m,vertices:0}}this.geometryChunks[l].faces.push(g);this.geometryChunks[l].vertices+=p}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(F){var D=[];b=0;for(d=F.length;b65535){c[k].counter+=1;o=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:m,vertices:0}}this.geometryChunks[o].faces.push(g);this.geometryChunks[o].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,d,g){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,g);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.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,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; @@ -81,90 +81,90 @@ a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undef this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;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.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);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}this.toString=function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; -THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,g){this.image=a;this.loaded=false;this.mapping=b!==undefined?b:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=g!==undefined?g:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; -THREE.UVMapping=0;THREE.ReflectionMapping=1;THREE.RefractionMapping=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,b){this.image=a;this.mapping=b?b:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (
image: "+this.image+"
mapping: "+this.mapping+"
)"}}; +THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=g!==undefined?g:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; +THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){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.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.Projector=function(){function a(T,z){var f=0,k=1,e=T.z+T.w,n=z.z+z.w,i=-T.z+T.w,h=-z.z+z.w;if(e>=0&&n>=0&&i>=0&&h>=0)return true;else if(e<0&&n<0||i<0&&h<0)return false;else{if(e<0)f=Math.max(f,e/(e-n));else if(n<0)k=Math.min(k,e/(e-n));if(i<0)f=Math.max(f,i/(i-h));else if(h<0)k=Math.min(k,i/(i-h));if(k0&&s.z<1}O=t.geometry.faces;e=0;for(n=O.length;e0&&w.z<1){c=G[E]=G[E]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=t.rotation.z;c.scale.x=t.scale.x*Math.abs(c.x-(w.x+z.projectionMatrix.n11)/(w.w+z.projectionMatrix.n14));c.scale.y=t.scale.y*Math.abs(c.y-(w.y+z.projectionMatrix.n22)/(w.w+z.projectionMatrix.n24));c.material=t.material;b.push(c);E++}}}b.sort(function(R,C){return C.z-R.z});return b};this.unprojectVector=function(T,z){var f=new THREE.Matrix4; -f.multiply(THREE.Matrix4.makeInvert(z.matrix),THREE.Matrix4.makeInvert(z.projectionMatrix));f.multiplyVector3(T);return T}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,j,p;this.domElement=document.createElement("div");this.setSize=function(m,q){d=m;g=q;j=d/2;p=g/2};this.render=function(m,q){var l,c,E,G,w,F,P,J;a=b.projectScene(m,q);l=0;for(c=a.length;l0){D.r+=$.r*L;D.g+=$.g*L;D.b+=$.b*L}}else if(L instanceof THREE.PointLight){aa.sub(L.position,Y);aa.normalize();L=U.dot(aa)*N;if(L>0){D.r+=$.r*L;D.g+=$.g*L;D.b+=$.b*L}}}}function b(I,Y,U,D,v,L){if(v.opacity!=0){p(v.opacity);m(v.blending);K=I.positionScreen.x;A=I.positionScreen.y;H=Y.positionScreen.x; -Q=Y.positionScreen.y;u=U.positionScreen.x;O=U.positionScreen.y;var $=K,N=A,X=H,ba=Q,Z=u,ca=O;o.beginPath();o.moveTo($,N);o.lineTo(X,ba);o.lineTo(Z,ca);o.lineTo($,N);o.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map&&v.map.loaded)j(K,A,H,Q,u,O,v.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);else if(v.env_map&&v.env_map.loaded){if(v.env_map.mapping==THREE.ReflectionMapping){aa.copy(D.vertexNormalsWorld[0]);V=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+ -aa.z*camera.matrix.n13)*0.5+0.5;ka=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(D.vertexNormalsWorld[1]);za=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Aa=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(D.vertexNormalsWorld[2]);Ba=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Ca=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)* -0.5+0.5;j(K,A,H,Q,u,O,v.env_map.image,V,ka,za,Aa,Ba,Ca)}}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){j(K,A,H,Q,u,O,v.map.image,D.uvs[0].u,D.uvs[0].v,D.uvs[1].u,D.uvs[1].v,D.uvs[2].u,D.uvs[2].v);m(THREE.SubtractiveBlending)}if(va)if(!v.wireframe&&v.shading==THREE.SmoothShading&&D.vertexNormalsWorld.length==3){y.r=x.r=R.r=ga.r;y.g=x.g=R.g=ga.g;y.b=x.b=R.b=ga.b;a(L,D.v1.positionWorld, -D.vertexNormalsWorld[0],y);a(L,D.v2.positionWorld,D.vertexNormalsWorld[1],x);a(L,D.v3.positionWorld,D.vertexNormalsWorld[2],R);C.r=(x.r+R.r)*0.5;C.g=(x.g+R.g)*0.5;C.b=(x.b+R.b)*0.5;S=q(y,x,R,C);j(K,A,H,Q,u,O,S,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(L,D.centroidWorld,D.normalWorld,ha);s.r=v.color.r*ha.r;s.g=v.color.g*ha.g;s.b=v.color.b*ha.b;s.updateStyleString();v.wireframe?d(s.__styleString,v.wireframe_linewidth):g(s.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth): -g(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){B=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;y.r=y.g=y.b=1-B/(W-I.positionScreen.z*ea);x.r=x.g=x.b=1-B/(W-Y.positionScreen.z*ea);R.r=R.g=R.b=1-B/(W-U.positionScreen.z*ea);C.r=(x.r+R.r)*0.5;C.g=(x.g+R.g)*0.5;C.b=(x.b+R.b)*0.5;S=q(y,x,R,C);j(K,A,H,Q,u,O,S,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){s.r=l(D.normalWorld.x);s.g=l(D.normalWorld.y);s.b=l(D.normalWorld.z);s.updateStyleString();v.wireframe?d(s.__styleString, -v.wireframe_linewidth):g(s.__styleString)}}}function d(I,Y){if(f!=I)o.strokeStyle=f=I;if(e!=Y)o.lineWidth=e=Y;o.stroke();da.inflate(Y*2)}function g(I){if(k!=I)o.fillStyle=k=I;o.fill()}function j(I,Y,U,D,v,L,$,N,X,ba,Z,ca,na){var la,fa;la=$.width-1;fa=$.height-1;N*=la;X*=fa;ba*=la;Z*=fa;ca*=la;na*=fa;U-=I;D-=Y;v-=I;L-=Y;ba-=N;Z-=X;ca-=N;na-=X;fa=1/(ba*na-ca*Z);la=(na*U-Z*v)*fa;Z=(na*D-Z*L)*fa;U=(ba*v-ca*U)*fa;D=(ba*L-ca*D)*fa;I=I-la*N-U*X;Y=Y-Z*N-D*X;o.save();o.transform(la,Z,U,D,I,Y);o.clip();o.drawImage($, -0,0);o.restore()}function p(I){if(T!=I)o.globalAlpha=T=I}function m(I){if(z!=I){switch(I){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}z=I}}function q(I,Y,U,D){ia[0]=i(0,n(255,~~(I.r*255)));ia[1]=i(0,n(255,~~(I.g*255)));ia[2]=i(0,n(255,~~(I.b*255)));ia[4]=i(0,n(255,~~(Y.r*255)));ia[5]=i(0,n(255,~~(Y.g*255)));ia[6]=i(0,n(255,~~(Y.b*255))); -ia[8]=i(0,n(255,~~(U.r*255)));ia[9]=i(0,n(255,~~(U.g*255)));ia[10]=i(0,n(255,~~(U.b*255)));ia[12]=i(0,n(255,~~(D.r*255)));ia[13]=i(0,n(255,~~(D.g*255)));ia[14]=i(0,n(255,~~(D.b*255)));ra.putImageData(wa,0,0);ua.drawImage(sa,0,0);return ta}function l(I){return I<0?n((1+I)*0.5,0.5):0.5+n(I*0.5,0.5)}function c(I,Y){var U=Y.x-I.x,D=Y.y-I.y,v=1/Math.sqrt(U*U+D*D);U*=v;D*=v;Y.x+=U;Y.y+=D;I.x-=U;I.y-=D}var E=null,G=new THREE.Projector,w=document.createElement("canvas"),F,P,J,M,o=w.getContext("2d"),T=1,z= -0,f=null,k=null,e=1,n=Math.min,i=Math.max,h,r,t,K,A,H,Q,u,O,s=new THREE.Color,y=new THREE.Color,x=new THREE.Color,R=new THREE.Color,C=new THREE.Color,B,W,ea,S,V,ka,za,Aa,Ba,Ca,ma=new THREE.Rectangle,ja=new THREE.Rectangle,da=new THREE.Rectangle,va=false,ha=new THREE.Color,ga=new THREE.Color,oa=new THREE.Color,pa=new THREE.Color,Da=Math.PI*2,aa=new THREE.Vector3,sa,ra,wa,ia,ta,ua,qa=16;sa=document.createElement("canvas");sa.width=sa.height=2;ra=sa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0, -0,2,2);wa=ra.getImageData(0,0,2,2);ia=wa.data;ta=document.createElement("canvas");ta.width=ta.height=qa;ua=ta.getContext("2d");ua.translate(-qa/2,-qa/2);ua.scale(qa,qa);qa--;this.domElement=w;this.autoClear=true;this.setSize=function(I,Y){F=I;P=Y;J=F/2;M=P/2;w.width=F;w.height=P;ma.set(-J,-M,J,M)};this.clear=function(){if(!ja.isEmpty()){ja.inflate(1);ja.minSelf(ma);o.clearRect(ja.getX(),ja.getY(),ja.getWidth(),ja.getHeight());ja.empty()}};this.render=function(I,Y){var U,D,v,L,$,N,X,ba;o.setTransform(1, -0,0,-1,J,M);this.autoClear&&this.clear();E=G.projectScene(I,Y);o.fillStyle="rgba(0, 255, 255, 0.5)";o.fillRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());if(va=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);oa.setRGB(0,0,0);pa.setRGB(0,0,0);U=0;for(D=$.length;U>1;ya=fa.height>>1;na=X.scale.x*J;la=X.scale.y*M;ba=na*xa;ca=la*ya;da.set(N.x-ba,N.y-ca,N.x+ba,N.y+ca);if(!ma.instersects(da))break a;o.save(); -o.translate(N.x,N.y);o.rotate(-X.rotation);o.scale(na,-la);o.translate(-xa,-ya);o.drawImage(fa,0,0);o.restore()}o.beginPath();o.moveTo(N.x-10,N.y);o.lineTo(N.x+10,N.y);o.moveTo(N.x,N.y-10);o.lineTo(N.x,N.y+10);o.closePath();o.strokeStyle="rgb(255,255,0)";o.stroke()}else if(Z instanceof THREE.ParticleCircleMaterial){if(va){ha.r=ga.r+oa.r+pa.r;ha.g=ga.g+oa.g+pa.g;ha.b=ga.b+oa.b+pa.b;s.r=Z.color.r*ha.r;s.g=Z.color.g*ha.g;s.b=Z.color.b*ha.b;s.updateStyleString()}else s.__styleString=Z.color.__styleString; -ba=X.scale.x*J;ca=X.scale.y*M;da.set(N.x-ba,N.y-ca,N.x+ba,N.y+ca);if(ma.instersects(da)){Z=s.__styleString;if(k!=Z)o.fillStyle=k=Z;o.save();o.translate(N.x,N.y);o.rotate(-X.rotation);o.scale(ba,ca);o.beginPath();o.arc(0,0,1,0,Da,true);o.closePath();o.fill();o.restore()}}}}}else if(v instanceof THREE.RenderableLine){h=v.v1;r=v.v2;h.positionScreen.x*=J;h.positionScreen.y*=M;r.positionScreen.x*=J;r.positionScreen.y*=M;da.addPoint(h.positionScreen.x,h.positionScreen.y);da.addPoint(r.positionScreen.x, -r.positionScreen.y);if(ma.instersects(da)){L=0;for($=v.material.length;L<$;){X=h;ba=r;N=v.material[L++];if(N.opacity!=0){p(N.opacity);m(N.blending);o.beginPath();o.moveTo(X.positionScreen.x,X.positionScreen.y);o.lineTo(ba.positionScreen.x,ba.positionScreen.y);o.closePath();if(N instanceof THREE.LineBasicMaterial){s.__styleString=N.color.__styleString;X=N.linewidth;if(e!=X)o.lineWidth=e=X;X=s.__styleString;if(f!=X)o.strokeStyle=f=X;o.stroke();da.inflate(N.linewidth*2)}}}}}else if(v instanceof THREE.RenderableFace3){h= -v.v1;r=v.v2;t=v.v3;h.positionScreen.x*=J;h.positionScreen.y*=M;r.positionScreen.x*=J;r.positionScreen.y*=M;t.positionScreen.x*=J;t.positionScreen.y*=M;if(v.overdraw){c(h.positionScreen,r.positionScreen);c(r.positionScreen,t.positionScreen);c(t.positionScreen,h.positionScreen)}da.addPoint(h.positionScreen.x,h.positionScreen.y);da.addPoint(r.positionScreen.x,r.positionScreen.y);da.addPoint(t.positionScreen.x,t.positionScreen.y);if(ma.instersects(da)){L=0;for($=v.meshMaterial.length;L<$;){ba=v.meshMaterial[L++]; -if(ba instanceof THREE.MeshFaceMaterial){N=0;for(X=v.faceMaterial.length;N0){x.r+=B.color.r*W;x.g+=B.color.g*W;x.b+=B.color.b*W}}else if(B instanceof THREE.PointLight){h.sub(B.position,y.centroidWorld);h.normalize();W=y.normalWorld.dot(h)*B.intensity;if(W>0){x.r+=B.color.r*W;x.g+=B.color.g*W;x.b+=B.color.b*W}}}}function b(s,y,x,R,C,B){A=g(H++);A.setAttribute("d","M "+s.positionScreen.x+ -" "+s.positionScreen.y+" L "+y.positionScreen.x+" "+y.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)z.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(T){f.r=k.r;f.g=k.g;f.b=k.b;a(B,R,f);z.r=C.color.r*f.r;z.g=C.color.g*f.g;z.b=C.color.b*f.b;z.updateStyleString()}else z.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){i=1-C.__2near/(C.__farPlusNear-R.z*C.__farMinusNear); -z.setRGB(i,i,i)}else C instanceof THREE.MeshNormalMaterial&&z.setRGB(j(R.normalWorld.x),j(R.normalWorld.y),j(R.normalWorld.z));C.wireframe?A.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):A.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+C.opacity);q.appendChild(A)}function d(s,y,x,R,C,B,W){A=g(H++);A.setAttribute("d", -"M "+s.positionScreen.x+" "+s.positionScreen.y+" L "+y.positionScreen.x+" "+y.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)z.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(T){f.r=k.r;f.g=k.g;f.b=k.b;a(W,C,f);z.r=B.color.r*f.r;z.g=B.color.g*f.g;z.b=B.color.b*f.b;z.updateStyleString()}else z.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){i= -1-B.__2near/(B.__farPlusNear-C.z*B.__farMinusNear);z.setRGB(i,i,i)}else B instanceof THREE.MeshNormalMaterial&&z.setRGB(j(C.normalWorld.x),j(C.normalWorld.y),j(C.normalWorld.z));B.wireframe?A.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):A.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+B.opacity);q.appendChild(A)} -function g(s){if(r[s]==null){r[s]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&r[s].setAttribute("shape-rendering","crispEdges");return r[s]}return r[s]}function j(s){return s<0?Math.min((1+s)*0.5,0.5):0.5+Math.min(s*0.5,0.5)}var p=null,m=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,E,G,w,F,P,J,M=new THREE.Rectangle,o=new THREE.Rectangle,T=false,z=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),e=new THREE.Color(0), -n=new THREE.Color(0),i,h=new THREE.Vector3,r=[],t=[],K=[],A,H,Q,u,O=1;this.domElement=q;this.autoClear=true;this.setQuality=function(s){switch(s){case "high":O=1;break;case "low":O=0}};this.setSize=function(s,y){l=s;c=y;E=l/2;G=c/2;q.setAttribute("viewBox",-E+" "+-G+" "+l+" "+c);q.setAttribute("width",l);q.setAttribute("height",c);M.set(-E,-G,E,G)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(s,y){var x,R,C,B,W,ea,S,V;this.autoClear&&this.clear(); -p=m.projectScene(s,y);u=Q=H=0;if(T=s.lights.length>0){S=s.lights;k.setRGB(0,0,0);e.setRGB(0,0,0);n.setRGB(0,0,0);x=0;for(R=S.length;x=0&&c.enableVertexAttribArray(f.attributes[i])}}function m(f,k){var e;if(f=="fragment")e=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")e=c.createShader(c.VERTEX_SHADER);c.shaderSource(e,k);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(e)); -return null}return e}function q(f){switch(f){case THREE.Repeat:return c.REPEAT;case THREE.ClampToEdge:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return c.MIRRORED_REPEAT}return 0}var l=document.createElement("canvas"),c,E,G,w=new THREE.Matrix4,F,P=new Float32Array(16),J=new Float32Array(16),M=new Float32Array(16),o=new Float32Array(9),T=new Float32Array(16);a=function(f,k){if(f){var e,n,i,h=pointLights=maxDirLights=maxPointLights=0;e=0;for(n=f.lights.length;e= 0.0 )": -"",k?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",k?"pointDiffuse += mColor * pointDiffuseWeight;":"",k?"pointSpecular += mSpecular * pointSpecularWeight;":"",k?"}":"",f?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",f?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",f?"vec3 dirVector = normalize( lDirection.xyz );":"",f?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",f?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",f?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",f?"float dirSpecularWeight = 0.0;":"",f?"if ( dirDotNormalHalf >= 0.0 )":"",f?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",f?"dirDiffuse += mColor * dirDiffuseWeight;":"",f?"dirSpecular += mSpecular * dirSpecularWeight;":"",f?"}":"","vec4 totalLight = mAmbient;",f?"totalLight += dirDiffuse + dirSpecular;":"",k?"totalLight += pointDiffuse + pointSpecular;": +THREE.Projector=function(){function a(O,v){var f=0,l=1,e=O.z+O.w,p=v.z+v.w,h=-O.z+O.w,i=-v.z+v.w;if(e>=0&&p>=0&&h>=0&&i>=0)return true;else if(e<0&&p<0||h<0&&i<0)return false;else{if(e<0)f=Math.max(f,e/(e-p));else if(p<0)l=Math.min(l,e/(e-p));if(h<0)f=Math.max(f,h/(h-i));else if(i<0)l=Math.min(l,h/(h-i));if(l0&&y.z<1}R=q.geometry.faces;e=0;for(p=R.length;e0&&w.z<1){c=D[F]=D[F]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=q.rotation.z;c.scale.x=q.scale.x*Math.abs(c.x-(w.x+v.projectionMatrix.n11)/(w.w+v.projectionMatrix.n14));c.scale.y=q.scale.y*Math.abs(c.y-(w.y+v.projectionMatrix.n22)/(w.w+v.projectionMatrix.n24));c.material=q.material;b.push(c);F++}}}b.sort(function(W,I){return I.z-W.z});return b};this.unprojectVector=function(O,v){var f=new THREE.Matrix4; +f.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));f.multiplyVector3(O);return O}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,j,n;this.domElement=document.createElement("div");this.setSize=function(m,k){d=m;g=k;j=d/2;n=g/2};this.render=function(m,k){var o,c,F,D,w,x,H,G;a=b.projectScene(m,k);o=0;for(c=a.length;o0){s.r+=ba.r*V;s.g+=ba.g*V;s.b+=ba.b*V}}else if(V instanceof THREE.PointLight){Y.sub(V.position,U);Y.normalize();V=J.dot(Y)*da;if(V>0){s.r+=ba.r*V;s.g+=ba.g*V;s.b+=ba.b*V}}}}function Na(u,U,J){if(J.opacity!=0){Da(J.opacity);ya(J.blending);var s,C,V,ba,da,ea;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){ba=J.map;da=ba.width>>1;ea=ba.height>>1;C=U.scale.x*n;V=U.scale.y*m;J=C*da;s=V*ea;X.set(u.x-J, +u.y-s,u.x+J,u.y+s);if(!z.instersects(X))return;k.save();k.translate(u.x,u.y);k.rotate(-U.rotation);k.scale(C,-V);k.translate(-da,-ea);k.drawImage(ba,0,0);k.restore()}k.beginPath();k.moveTo(u.x-10,u.y);k.lineTo(u.x+10,u.y);k.moveTo(u.x,u.y-10);k.lineTo(u.x,u.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(J instanceof THREE.ParticleCircleMaterial){if(T){P.r=Z.r+ja.r+ka.r;P.g=Z.g+ja.g+ka.g;P.b=Z.b+ja.b+ka.b;h.r=J.color.r*P.r;h.g=J.color.g*P.g;h.b=J.color.b*P.b;h.updateStyleString()}else h.__styleString= +J.color.__styleString;J=U.scale.x*n;s=U.scale.y*m;X.set(u.x-J,u.y-s,u.x+J,u.y+s);if(z.instersects(X)){C=h.__styleString;if(D!=C)k.fillStyle=D=C;k.save();k.translate(u.x,u.y);k.rotate(-U.rotation);k.scale(J,s);k.beginPath();k.arc(0,0,1,0,La,true);k.closePath();k.fill();k.restore()}}}}function Oa(u,U,J,s){if(s.opacity!=0){Da(s.opacity);ya(s.blending);k.beginPath();k.moveTo(u.positionScreen.x,u.positionScreen.y);k.lineTo(U.positionScreen.x,U.positionScreen.y);k.closePath();if(s instanceof THREE.LineBasicMaterial){h.__styleString= +s.color.__styleString;u=s.linewidth;if(w!=u)k.lineWidth=w=u;u=h.__styleString;if(F!=u)k.strokeStyle=F=u;k.stroke();X.inflate(s.linewidth*2)}}}function Ha(u,U,J,s,C,V){if(C.opacity!=0){Da(C.opacity);ya(C.blending);O=u.positionScreen.x;v=u.positionScreen.y;f=U.positionScreen.x;l=U.positionScreen.y;e=J.positionScreen.x;p=J.positionScreen.y;k.beginPath();k.moveTo(O,v);k.lineTo(f,l);k.lineTo(e,p);k.lineTo(O,v);k.closePath();if(C instanceof THREE.MeshBasicMaterial)if(C.map&&!C.wireframe)C.map.mapping instanceof +THREE.UVMapping&&ra(O,v,f,l,e,p,C.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(C.env_map){if(C.env_map.mapping instanceof THREE.SphericalReflectionMapping){Y.copy(s.vertexNormalsWorld[0]);R=(Y.x*aa.matrix.n11+Y.y*aa.matrix.n12+Y.z*aa.matrix.n13)*0.5+0.5;y=-(Y.x*aa.matrix.n21+Y.y*aa.matrix.n22+Y.z*aa.matrix.n23)*0.5+0.5;Y.copy(s.vertexNormalsWorld[1]);A=(Y.x*aa.matrix.n11+Y.y*aa.matrix.n12+Y.z*aa.matrix.n13)*0.5+0.5;E=-(Y.x*aa.matrix.n21+Y.y*aa.matrix.n22+Y.z* +aa.matrix.n23)*0.5+0.5;Y.copy(s.vertexNormalsWorld[2]);W=(Y.x*aa.matrix.n11+Y.y*aa.matrix.n12+Y.z*aa.matrix.n13)*0.5+0.5;I=-(Y.x*aa.matrix.n21+Y.y*aa.matrix.n22+Y.z*aa.matrix.n23)*0.5+0.5;ra(O,v,f,l,e,p,C.env_map.image,R,y,A,E,W,I)}}else C.wireframe?za(C.color.__styleString,C.wireframe_linewidth):Aa(C.color.__styleString);else if(C instanceof THREE.MeshLambertMaterial){if(C.map&&!C.wireframe){C.map.mapping instanceof THREE.UVMapping&&ra(O,v,f,l,e,p,C.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);ya(THREE.SubtractiveBlending)}if(T)if(!C.wireframe&&C.shading==THREE.SmoothShading&&s.vertexNormalsWorld.length==3){i.r=r.r=q.r=Z.r;i.g=r.g=q.g=Z.g;i.b=r.b=q.b=Z.b;xa(V,s.v1.positionWorld,s.vertexNormalsWorld[0],i);xa(V,s.v2.positionWorld,s.vertexNormalsWorld[1],r);xa(V,s.v3.positionWorld,s.vertexNormalsWorld[2],q);L.r=(r.r+q.r)*0.5;L.g=(r.g+q.g)*0.5;L.b=(r.b+q.b)*0.5;t=Ia(i,r,q,L);ra(O,v,f,l,e,p,t,0,0,1,0,0,1)}else{P.r=Z.r;P.g=Z.g;P.b=Z.b;xa(V,s.centroidWorld,s.normalWorld, +P);h.r=C.color.r*P.r;h.g=C.color.g*P.g;h.b=C.color.b*P.b;h.updateStyleString();C.wireframe?za(h.__styleString,C.wireframe_linewidth):Aa(h.__styleString)}else C.wireframe?za(C.color.__styleString,C.wireframe_linewidth):Aa(C.color.__styleString)}else if(C instanceof THREE.MeshDepthMaterial){B=C.__2near;M=C.__farPlusNear;Q=C.__farMinusNear;i.r=i.g=i.b=1-B/(M-u.positionScreen.z*Q);r.r=r.g=r.b=1-B/(M-U.positionScreen.z*Q);q.r=q.g=q.b=1-B/(M-J.positionScreen.z*Q);L.r=(r.r+q.r)*0.5;L.g=(r.g+q.g)*0.5;L.b= +(r.b+q.b)*0.5;t=Ia(i,r,q,L);ra(O,v,f,l,e,p,t,0,0,1,0,0,1)}else if(C instanceof THREE.MeshNormalMaterial){h.r=Ea(s.normalWorld.x);h.g=Ea(s.normalWorld.y);h.b=Ea(s.normalWorld.z);h.updateStyleString();C.wireframe?za(h.__styleString,C.wireframe_linewidth):Aa(h.__styleString)}}}function za(u,U){if(F!=u)k.strokeStyle=F=u;if(w!=U)k.lineWidth=w=U;k.stroke();X.inflate(U*2)}function Aa(u){if(D!=u)k.fillStyle=D=u;k.fill()}function ra(u,U,J,s,C,V,ba,da,ea,sa,ia,ta,ua){var la,ha;la=ba.width-1;ha=ba.height-1; +da*=la;ea*=ha;sa*=la;ia*=ha;ta*=la;ua*=ha;J-=u;s-=U;C-=u;V-=U;sa-=da;ia-=ea;ta-=da;ua-=ea;ha=1/(sa*ua-ta*ia);la=(ua*J-ia*C)*ha;ia=(ua*s-ia*V)*ha;J=(sa*C-ta*J)*ha;s=(sa*V-ta*s)*ha;u=u-la*da-J*ea;U=U-ia*da-s*ea;k.save();k.transform(la,ia,J,s,u,U);k.clip();k.drawImage(ba,0,0);k.restore()}function Da(u){if(o!=u)k.globalAlpha=o=u}function ya(u){if(c!=u){switch(u){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break; +case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}c=u}}function Ia(u,U,J,s){ca[0]=H(0,x(255,~~(u.r*255)));ca[1]=H(0,x(255,~~(u.g*255)));ca[2]=H(0,x(255,~~(u.b*255)));ca[4]=H(0,x(255,~~(U.r*255)));ca[5]=H(0,x(255,~~(U.g*255)));ca[6]=H(0,x(255,~~(U.b*255)));ca[8]=H(0,x(255,~~(J.r*255)));ca[9]=H(0,x(255,~~(J.g*255)));ca[10]=H(0,x(255,~~(J.b*255)));ca[12]=H(0,x(255,~~(s.r*255)));ca[13]=H(0,x(255,~~(s.g*255)));ca[14]=H(0,x(255,~~(s.b*255)));pa.putImageData(Ca,0,0);wa.drawImage(oa,0,0); +return qa}function Ea(u){return u<0?x((1+u)*0.5,0.5):0.5+x(u*0.5,0.5)}function Fa(u,U){var J=U.x-u.x,s=U.y-u.y,C=1/Math.sqrt(J*J+s*s);J*=C;s*=C;U.x+=J;U.y+=s;u.x-=J;u.y-=s}var Ba,Ja,$,fa,na,Ga,Ka,va;k.setTransform(1,0,0,-1,n,m);this.autoClear&&this.clear();a=b.projectScene(ga,aa);k.fillStyle="rgba(0, 255, 255, 0.5)";k.fillRect(z.getX(),z.getY(),z.getWidth(),z.getHeight());(T=ga.lights.length>0)&&Ma(ga);Ba=0;for(Ja=a.length;Ba0){E.r+=z.color.r*S;E.g+=z.color.g*S;E.b+=z.color.b*S}}else if(z instanceof THREE.PointLight){i.sub(z.position,A.centroidWorld);i.normalize();S=A.normalWorld.dot(i)*z.intensity;if(S>0){E.r+=z.color.r*S;E.g+=z.color.g*S;E.b+=z.color.b*S}}}}function b(y,A,E,W,I,z){B=g(M++);B.setAttribute("d","M "+y.positionScreen.x+ +" "+y.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");if(I instanceof THREE.MeshBasicMaterial)v.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshLambertMaterial)if(O){f.r=l.r;f.g=l.g;f.b=l.b;a(z,W,f);v.r=I.color.r*f.r;v.g=I.color.g*f.g;v.b=I.color.b*f.b;v.updateStyleString()}else v.__styleString=I.color.__styleString;else if(I instanceof THREE.MeshDepthMaterial){h=1-I.__2near/(I.__farPlusNear-W.z*I.__farMinusNear); +v.setRGB(h,h,h)}else I instanceof THREE.MeshNormalMaterial&&v.setRGB(j(W.normalWorld.x),j(W.normalWorld.y),j(W.normalWorld.z));I.wireframe?B.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+I.wireframe_linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframe_linecap+"; stroke-linejoin: "+I.wireframe_linejoin):B.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+I.opacity);k.appendChild(B)}function d(y,A,E,W,I,z,S){B=g(M++);B.setAttribute("d", +"M "+y.positionScreen.x+" "+y.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)v.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(O){f.r=l.r;f.g=l.g;f.b=l.b;a(S,I,f);v.r=z.color.r*f.r;v.g=z.color.g*f.g;v.b=z.color.b*f.b;v.updateStyleString()}else v.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){h= +1-z.__2near/(z.__farPlusNear-I.z*z.__farMinusNear);v.setRGB(h,h,h)}else z instanceof THREE.MeshNormalMaterial&&v.setRGB(j(I.normalWorld.x),j(I.normalWorld.y),j(I.normalWorld.z));z.wireframe?B.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):B.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+z.opacity);k.appendChild(B)} +function g(y){if(r[y]==null){r[y]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&r[y].setAttribute("shape-rendering","crispEdges");return r[y]}return r[y]}function j(y){return y<0?Math.min((1+y)*0.5,0.5):0.5+Math.min(y*0.5,0.5)}var n=null,m=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,F,D,w,x,H,G,K=new THREE.Rectangle,N=new THREE.Rectangle,O=false,v=new THREE.Color(16777215),f=new THREE.Color(16777215),l=new THREE.Color(0),e=new THREE.Color(0), +p=new THREE.Color(0),h,i=new THREE.Vector3,r=[],q=[],L=[],B,M,Q,t,R=1;this.domElement=k;this.autoClear=true;this.setQuality=function(y){switch(y){case "high":R=1;break;case "low":R=0}};this.setSize=function(y,A){o=y;c=A;F=o/2;D=c/2;k.setAttribute("viewBox",-F+" "+-D+" "+o+" "+c);k.setAttribute("width",o);k.setAttribute("height",c);K.set(-F,-D,F,D)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(y,A){var E,W,I,z,S,X,T,P;this.autoClear&&this.clear(); +n=m.projectScene(y,A);t=Q=M=0;if(O=y.lights.length>0){T=y.lights;l.setRGB(0,0,0);e.setRGB(0,0,0);p.setRGB(0,0,0);E=0;for(W=T.length;E=0&&c.enableVertexAttribArray(f.attributes[h])}}function m(f,l){var e;if(f=="fragment")e=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")e=c.createShader(c.VERTEX_SHADER);c.shaderSource(e,l);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(e)); +return null}return e}function k(f){switch(f){case THREE.Repeat:return c.REPEAT;case THREE.ClampToEdge:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return c.MIRRORED_REPEAT}return 0}var o=document.createElement("canvas"),c,F,D,w=new THREE.Matrix4,x,H=new Float32Array(16),G=new Float32Array(16),K=new Float32Array(16),N=new Float32Array(9),O=new Float32Array(16);a=function(f,l){if(f){var e,p,h,i=pointLights=maxDirLights=maxPointLights=0;e=0;for(p=f.lights.length;e= 0.0 )": +"",l?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",l?"pointDiffuse += mColor * pointDiffuseWeight;":"",l?"pointSpecular += mSpecular * pointSpecularWeight;":"",l?"}":"",f?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",f?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",f?"vec3 dirVector = normalize( lDirection.xyz );":"",f?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",f?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",f?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",f?"float dirSpecularWeight = 0.0;":"",f?"if ( dirDotNormalHalf >= 0.0 )":"",f?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",f?"dirDiffuse += mColor * dirDiffuseWeight;":"",f?"dirSpecular += mSpecular * dirSpecularWeight;":"",f?"}":"","vec4 totalLight = mAmbient;",f?"totalLight += dirDiffuse + dirSpecular;":"",l?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n"); -e=b(n,e);c.useProgram(e);j(e,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);f&&j(e,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);k&&j(e,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(e.uniforms.enableMap,0);c.uniform1i(e.uniforms.tMap,0);c.uniform1i(e.uniforms.enableCubeMap,0);c.uniform1i(e.uniforms.tCube,1);c.uniform1i(e.uniforms.mixEnvMap,0);c.uniform1i(e.uniforms.useRefract,0);p(e,["position","normal","uv"]);return e}(a.directional,a.point);this.setSize=function(f,k){l.width=f;l.height=k;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,k){var e,n,i,h,r,t=[], -K=[],A=[];h=[];r=[];c.uniform1i(f.uniforms.enableLighting,k.length);e=0;for(n=k.length;e0){x.__webGLUVBuffer=c.createBuffer(); -c.bindBuffer(c.ARRAY_BUFFER,x.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(s),c.STATIC_DRAW)}x.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);x.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);x.__webGLFaceCount=H.length;x.__webGLLineCount=Q.length}};this.renderBuffer= -function(f,k,e,n){var i,h,r,t,K,A,H,Q,u;if(e instanceof THREE.MeshShaderMaterial){if(!e.program){e.program=b(e.fragment_shader,e.vertex_shader);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in e.uniforms)H.push(u);j(e.program,H);p(e.program,["position","normal","uv"])}u=e.program}else u=G;if(u!=E){c.useProgram(u);E=u}u==G&&this.setupLights(u,k);this.loadCamera(u,f);this.loadMatrices(u);if(e instanceof THREE.MeshShaderMaterial){r=e.wireframe; -t=e.wireframe_linewidth;f=u;k=e.uniforms;var O;for(i in k){Q=k[i].type;H=k[i].value;O=f.uniforms[i];if(Q=="i")c.uniform1i(O,H);else if(Q=="f")c.uniform1f(O,H);else if(Q=="t"){c.uniform1i(O,H);Q=k[i].texture;if(Q instanceof THREE.TextureCube)d(Q,H);else Q instanceof THREE.Texture&&g(Q,H)}}}if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){i=e.color;h=e.opacity;r=e.wireframe;t=e.wireframe_linewidth;K=e.map;A=e.env_map;k=e.combine== -THREE.Mix;f=e.reflectivity;Q=e.env_map&&e.env_map.mapping==THREE.RefractionMapping;H=e.refraction_ratio;c.uniform4f(u.uniforms.mColor,i.r*h,i.g*h,i.b*h,h);c.uniform1i(u.uniforms.mixEnvMap,k);c.uniform1f(u.uniforms.mReflectivity,f);c.uniform1i(u.uniforms.useRefract,Q);c.uniform1f(u.uniforms.mRefractionRatio,H)}if(e instanceof THREE.MeshNormalMaterial){h=e.opacity;c.uniform1f(u.uniforms.mOpacity,h);c.uniform1i(u.uniforms.material,4)}else if(e instanceof THREE.MeshDepthMaterial){h=e.opacity;r=e.wireframe; -t=e.wireframe_linewidth;c.uniform1f(u.uniforms.mOpacity,h);c.uniform1f(u.uniforms.m2Near,e.__2near);c.uniform1f(u.uniforms.mFarPlusNear,e.__farPlusNear);c.uniform1f(u.uniforms.mFarMinusNear,e.__farMinusNear);c.uniform1i(u.uniforms.material,3)}else if(e instanceof THREE.MeshPhongMaterial){i=e.ambient;f=e.specular;e=e.shininess;c.uniform4f(u.uniforms.mAmbient,i.r,i.g,i.b,h);c.uniform4f(u.uniforms.mSpecular,f.r,f.g,f.b,h);c.uniform1f(u.uniforms.mShininess,e);c.uniform1i(u.uniforms.material,2)}else if(e instanceof -THREE.MeshLambertMaterial)c.uniform1i(u.uniforms.material,1);else if(e instanceof THREE.MeshBasicMaterial)c.uniform1i(u.uniforms.material,0);else if(e instanceof THREE.MeshCubeMaterial){c.uniform1i(u.uniforms.material,5);A=e.env_map}if(K){g(K,0);c.uniform1i(u.uniforms.tMap,0);c.uniform1i(u.uniforms.enableMap,1)}else c.uniform1i(u.uniforms.enableMap,0);if(A){d(A,1);c.uniform1i(u.uniforms.tCube,1);c.uniform1i(u.uniforms.enableCubeMap,1)}else c.uniform1i(u.uniforms.enableCubeMap,0);h=u.attributes;c.bindBuffer(c.ARRAY_BUFFER, -n.__webGLVertexBuffer);c.vertexAttribPointer(h.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(h.normal,3,c.FLOAT,false,0,0);if(h.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.enableVertexAttribArray(h.uv);c.vertexAttribPointer(h.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(h.uv);if(r){c.lineWidth(t);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT, -0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,k,e,n,i,h){var r,t,K,A,H;K=0;for(A=e.material.length;K=0;e--){n=f.__webGLObjects[e].object;k==n&&f.__webGLObjects.splice(e,1)}};this.setupMatrices=function(f,k){f.autoUpdateMatrix&&f.updateMatrix();w.multiply(k.matrix,f.matrix);P.set(k.matrix.flatten());J.set(w.flatten());M.set(k.projectionMatrix.flatten());F=THREE.Matrix4.makeInvert3x3(w).transpose(); -o.set(F.m);T.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,P);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,J);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,o);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,T)};this.loadCamera=function(f,k){c.uniform3f(f.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); -c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,k){if(f){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}}; +e=b(p,e);c.useProgram(e);j(e,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);f&&j(e,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&j(e,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(e.uniforms.enableMap,0);c.uniform1i(e.uniforms.tMap,0);c.uniform1i(e.uniforms.enableCubeMap,0);c.uniform1i(e.uniforms.tCube,1);c.uniform1i(e.uniforms.mixEnvMap,0);c.uniform1i(e.uniforms.useRefract,0);n(e,["position","normal","uv"]);return e}(a.directional,a.point);this.setSize=function(f,l){o.width=f;o.height=l;c.viewport(0,0,o.width,o.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,l){var e,p,h,i,r,q=[], +L=[],B=[];i=[];r=[];c.uniform1i(f.uniforms.enableLighting,l.length);e=0;for(p=l.length;e0){E.__webGLUVBuffer=c.createBuffer(); +c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(y),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(M),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);E.__webGLFaceCount=M.length;E.__webGLLineCount=Q.length}};this.renderBuffer= +function(f,l,e,p){var h,i,r,q,L,B,M,Q,t;if(e instanceof THREE.MeshShaderMaterial){if(!e.program){e.program=b(e.fragment_shader,e.vertex_shader);M=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in e.uniforms)M.push(t);j(e.program,M);n(e.program,["position","normal","uv"])}t=e.program}else t=D;if(t!=F){c.useProgram(t);F=t}t==D&&this.setupLights(t,l);this.loadCamera(t,f);this.loadMatrices(t);if(e instanceof THREE.MeshShaderMaterial){r=e.wireframe; +q=e.wireframe_linewidth;f=t;l=e.uniforms;var R;for(h in l){Q=l[h].type;M=l[h].value;R=f.uniforms[h];if(Q=="i")c.uniform1i(R,M);else if(Q=="f")c.uniform1f(R,M);else if(Q=="t"){c.uniform1i(R,M);Q=l[h].texture;if(Q instanceof THREE.TextureCube)d(Q,M);else Q instanceof THREE.Texture&&g(Q,M)}}}if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){h=e.color;i=e.opacity;r=e.wireframe;q=e.wireframe_linewidth;L=e.map;B=e.env_map;l=e.combine== +THREE.Mix;f=e.reflectivity;Q=e.env_map&&e.env_map.mapping==THREE.RefractionMapping;M=e.refraction_ratio;c.uniform4f(t.uniforms.mColor,h.r*i,h.g*i,h.b*i,i);c.uniform1i(t.uniforms.mixEnvMap,l);c.uniform1f(t.uniforms.mReflectivity,f);c.uniform1i(t.uniforms.useRefract,Q);c.uniform1f(t.uniforms.mRefractionRatio,M)}if(e instanceof THREE.MeshNormalMaterial){i=e.opacity;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1i(t.uniforms.material,4)}else if(e instanceof THREE.MeshDepthMaterial){i=e.opacity;r=e.wireframe; +q=e.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1f(t.uniforms.m2Near,e.__2near);c.uniform1f(t.uniforms.mFarPlusNear,e.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,e.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(e instanceof THREE.MeshPhongMaterial){h=e.ambient;f=e.specular;e=e.shininess;c.uniform4f(t.uniforms.mAmbient,h.r,h.g,h.b,i);c.uniform4f(t.uniforms.mSpecular,f.r,f.g,f.b,i);c.uniform1f(t.uniforms.mShininess,e);c.uniform1i(t.uniforms.material,2)}else if(e instanceof +THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(e instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(e instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);B=e.env_map}if(L){g(L,0);c.uniform1i(t.uniforms.tMap,0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(B){d(B,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);i=t.attributes;c.bindBuffer(c.ARRAY_BUFFER, +p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0);if(i.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(r){c.lineWidth(q);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT, +0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,l,e,p,h,i){var r,q,L,B,M;L=0;for(B=e.material.length;L=0;e--){p=f.__webGLObjects[e].object;l==p&&f.__webGLObjects.splice(e,1)}};this.setupMatrices=function(f,l){f.autoUpdateMatrix&&f.updateMatrix();w.multiply(l.matrix,f.matrix);H.set(l.matrix.flatten());G.set(w.flatten());K.set(l.projectionMatrix.flatten());x=THREE.Matrix4.makeInvert3x3(w).transpose(); +N.set(x.m);O.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,H);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,G);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,N);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,O)};this.loadCamera=function(f,l){c.uniform3f(f.uniforms.cameraPosition,l.position.x,l.position.y,l.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); +c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,l){if(f){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}}; 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.faceMaterial=this.meshMaterial=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.material=null}; THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 197bcc2488..7183167952 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -12,44 +12,44 @@ THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},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,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},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,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,f=[];a=0;for(b=e.length;a0&&L>0&&n+L<1}var d,e,f,j,k,g,p,c,t,F, -r,w=a.geometry,v=w.vertices,y=[];d=0;for(e=w.faces.length;d= -0&&Math.min(f,p.getBottom())-Math.max(d,p.getTop())>=0};this.empty=function(){g=true;f=e=d=b=0;a()};this.isEmpty=function(){return g};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+j+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a0&&I>0&&m+I<1}var d,e,g,j,k,f,p,c,v,C, +r,t=a.geometry,u=t.vertices,w=[];d=0;for(e=t.faces.length;d= +0&&Math.min(g,p.getBottom())-Math.max(d,p.getTop())>=0};this.empty=function(){f=true;g=e=d=b=0;a()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+g+", width: "+j+", height: "+k+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; THREE.Matrix4=function(){}; THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,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},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},lookAt:function(a,b,d){var e=new THREE.Vector3,f=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();f.cross(j,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=j.x;this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,f=1/(this.n41*b+this.n42* -d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11* -a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,f=a.n13,j=a.n14,k=a.n21,g=a.n22,p=a.n23,c=a.n24,t=a.n31,F=a.n32,r=a.n33,w=a.n34,v=a.n41,y=a.n42,L=a.n43,u=a.n44,A=b.n11,o=b.n12,i=b.n13,n=b.n14,h=b.n21,x=b.n22,m=b.n23,l=b.n24,B=b.n31,C=b.n32,Q=b.n33,J=b.n34,P=b.n41,S=b.n42,E=b.n43, -T=b.n44;this.n11=d*A+e*h+f*B+j*P;this.n12=d*o+e*x+f*C+j*S;this.n13=d*i+e*m+f*Q+j*E;this.n14=d*n+e*l+f*J+j*T;this.n21=k*A+g*h+p*B+c*P;this.n22=k*o+g*x+p*C+c*S;this.n23=k*i+g*m+p*Q+c*E;this.n24=k*n+g*l+p*J+c*T;this.n31=t*A+F*h+r*B+w*P;this.n32=t*o+F*x+r*C+w*S;this.n33=t*i+F*m+r*Q+w*E;this.n34=t*n+F*l+r*J+w*T;this.n41=v*A+y*h+L*B+u*P;this.n42=v*o+y*x+L*C+u*S;this.n43=v*i+y*m+L*Q+u*E;this.n44=v*n+y*l+L*J+u*T},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,j=this.n21,k=this.n22, -g=this.n23,p=this.n24,c=this.n31,t=this.n32,F=this.n33,r=this.n34,w=this.n41,v=this.n42,y=this.n43,L=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+f*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+f*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+f*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+f*a.n44;this.n21=j*a.n11+k*a.n21+g*a.n31+p*a.n41;this.n22=j*a.n12+k*a.n22+g*a.n32+p*a.n42;this.n23=j*a.n13+k*a.n23+g*a.n33+p*a.n43;this.n24=j*a.n14+k*a.n24+g*a.n34+p*a.n44;this.n31=c*a.n11+t*a.n21+F*a.n31+r*a.n41;this.n32=c*a.n12+t*a.n22+ -F*a.n32+r*a.n42;this.n33=c*a.n13+t*a.n23+F*a.n33+r*a.n43;this.n34=c*a.n14+t*a.n24+F*a.n34+r*a.n44;this.n41=w*a.n11+v*a.n21+y*a.n31+L*a.n41;this.n42=w*a.n12+v*a.n22+y*a.n32+L*a.n42;this.n43=w*a.n13+v*a.n23+y*a.n33+L*a.n43;this.n44=w*a.n14+v*a.n24+y*a.n34+L*a.n44},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},determinant:function(){return this.n14* +a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(a,b,d){var e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();g.cross(j,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=j.x;this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,g=1/(this.n41*b+this.n42* +d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11* +a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,g=a.n13,j=a.n14,k=a.n21,f=a.n22,p=a.n23,c=a.n24,v=a.n31,C=a.n32,r=a.n33,t=a.n34,u=a.n41,w=a.n42,I=a.n43,E=a.n44,y=b.n11,n=b.n12,i=b.n13,m=b.n14,h=b.n21,z=b.n22,l=b.n23,o=b.n24,B=b.n31,A=b.n32,Q=b.n33,K=b.n34,R=b.n41,T=b.n42,D=b.n43, +V=b.n44;this.n11=d*y+e*h+g*B+j*R;this.n12=d*n+e*z+g*A+j*T;this.n13=d*i+e*l+g*Q+j*D;this.n14=d*m+e*o+g*K+j*V;this.n21=k*y+f*h+p*B+c*R;this.n22=k*n+f*z+p*A+c*T;this.n23=k*i+f*l+p*Q+c*D;this.n24=k*m+f*o+p*K+c*V;this.n31=v*y+C*h+r*B+t*R;this.n32=v*n+C*z+r*A+t*T;this.n33=v*i+C*l+r*Q+t*D;this.n34=v*m+C*o+r*K+t*V;this.n41=u*y+w*h+I*B+E*R;this.n42=u*n+w*z+I*A+E*T;this.n43=u*i+w*l+I*Q+E*D;this.n44=u*m+w*o+I*K+E*V},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,j=this.n21,k=this.n22, +f=this.n23,p=this.n24,c=this.n31,v=this.n32,C=this.n33,r=this.n34,t=this.n41,u=this.n42,w=this.n43,I=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+g*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+g*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+g*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+g*a.n44;this.n21=j*a.n11+k*a.n21+f*a.n31+p*a.n41;this.n22=j*a.n12+k*a.n22+f*a.n32+p*a.n42;this.n23=j*a.n13+k*a.n23+f*a.n33+p*a.n43;this.n24=j*a.n14+k*a.n24+f*a.n34+p*a.n44;this.n31=c*a.n11+v*a.n21+C*a.n31+r*a.n41;this.n32=c*a.n12+v*a.n22+ +C*a.n32+r*a.n42;this.n33=c*a.n13+v*a.n23+C*a.n33+r*a.n43;this.n34=c*a.n14+v*a.n24+C*a.n34+r*a.n44;this.n41=t*a.n11+u*a.n21+w*a.n31+I*a.n41;this.n42=t*a.n12+u*a.n22+w*a.n32+I*a.n42;this.n43=t*a.n13+u*a.n23+w*a.n33+I*a.n43;this.n44=t*a.n14+u*a.n24+w*a.n34+I*a.n44},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},determinant:function(){return this.n14* this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14* -this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var f=b[d];b[d]=b[e];b[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this, +this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var g=b[d];b[d]=b[e];b[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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]}, 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,b,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e}; THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),f=Math.sin(b),j=1-e,k=a.x,g=a.y,p=a.z;d.n11=j*k*k+e;d.n12=j*k*g-f*p;d.n13=j*k*p+f*g;d.n21=j*k*g+f*p;d.n22=j*g*g+e;d.n23=j*g*p-f*k;d.n31=j*k*p-f*g;d.n32=j*g*p+f*k;d.n33=j*p*p+e;return d}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,k=a.x,f=a.y,p=a.z;d.n11=j*k*k+e;d.n12=j*k*f-g*p;d.n13=j*k*p+g*f;d.n21=j*k*f+g*p;d.n22=j*f*f+e;d.n23=j*f*p-g*k;d.n31=j*k*p-g*f;d.n32=j*f*p+g*k;d.n33=j*p*p+e;return d}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],p=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],t=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*p;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*f;a.m[3]=b*j;a.m[4]=b*k;a.m[5]=b*g;a.m[6]=b*p;a.m[7]=b*c;a.m[8]=b*t;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,e,f,j){var k,g,p;k=new THREE.Matrix4;g=2*f/(b-a);p=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+f)/(j-f);f=-2*j*f/(j-f);k.n11=g;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=p;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=e;k.n34=f;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,b,d,e,f,j){var k,g,p,c;k=new THREE.Matrix4;g=b-a;p=d-e;c=j-f;a=(b+a)/g;d=(d+e)/p;f=(j+f)/c;k.n11=2/g;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/p;k.n23=0;k.n24=-d;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-f;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],f=-b[6]*b[0]+b[2]*b[4],p=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],v=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*p;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*k;a.m[5]=b*f;a.m[6]=b*p;a.m[7]=b*c;a.m[8]=b*v;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,e,g,j){var k,f,p;k=new THREE.Matrix4;f=2*g/(b-a);p=2*g/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+g)/(j-g);g=-2*j*g/(j-g);k.n11=f;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=p;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=e;k.n34=g;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,b,d,e,g,j){var k,f,p,c;k=new THREE.Matrix4;f=b-a;p=d-e;c=j-g;a=(b+a)/f;d=(d+e)/p;g=(j+g)/c;k.n11=2/f;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/p;k.n23=0;k.n24=-d;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-g;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k}; THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; -THREE.Face3=function(a,b,d,e,f){this.a=a;this.b=b;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.material=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,d,e,f,j){this.a=a;this.b=b;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.material=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.Face3=function(a,b,d,e,g){this.a=a;this.b=b;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.material=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,d,e,g,j){this.a=a;this.b=b;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.material=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||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.geometryChunks={}}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){this.bbox={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 a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y; -if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var F=[];b=0;for(d=t.length;b65535){c[g].counter+=1;p=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[p]==undefined)this.geometryChunks[p]={faces:[],material:k,vertices:0}}this.geometryChunks[p].faces.push(e);this.geometryChunks[p].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(v){var C=[];b=0;for(d=v.length;b65535){c[f].counter+=1;p=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[p]==undefined)this.geometryChunks[p]={faces:[],material:k,vertices:0}}this.geometryChunks[p].faces.push(e);this.geometryChunks[p].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.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,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; @@ -57,7 +57,7 @@ THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=ne this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0}; THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; THREE.Mesh=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,e,f;a=0;for(b=this.geometry.uvs.length;acolor: "+ 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(15658734);this.env_map=this.map=null;this.combine=THREE.Multiply;this.reflectivity=1;this.refraction_ratio=0.98;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!==undefined)this.map=a.map;if(a.env_map!== @@ -81,129 +81,129 @@ a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undef this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;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.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);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}this.toString=function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; -THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,e){this.image=a;this.loaded=false;this.mapping=b!==undefined?b:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=e!==undefined?e:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; -THREE.UVMapping=0;THREE.ReflectionMapping=1;THREE.RefractionMapping=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,b){this.image=a;this.mapping=b?b:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (
image: "+this.image+"
mapping: "+this.mapping+"
)"}}; +THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,e){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=e!==undefined?e:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; +THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){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.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.Projector=function(){function a(A,o){var i=0,n=1,h=A.z+A.w,x=o.z+o.w,m=-A.z+A.w,l=-o.z+o.w;if(h>=0&&x>=0&&m>=0&&l>=0)return true;else if(h<0&&x<0||m<0&&l<0)return false;else{if(h<0)i=Math.max(i,h/(h-x));else if(x<0)n=Math.min(n,h/(h-x));if(m<0)i=Math.max(i,m/(m-l));else if(l<0)n=Math.min(n,m/(m-l));if(n0&&D.z<1}T=C.geometry.faces;h=0;for(x=T.length;h0&&r.z<1){c=F[t]=F[t]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=C.rotation.z;c.scale.x=C.scale.x*Math.abs(c.x-(r.x+o.projectionMatrix.n11)/(r.w+o.projectionMatrix.n14));c.scale.y=C.scale.y*Math.abs(c.y-(r.y+o.projectionMatrix.n22)/(r.w+o.projectionMatrix.n24));c.material=C.material;b.push(c);t++}}}b.sort(function(V,N){return N.z-V.z});return b};this.unprojectVector=function(A,o){var i=new THREE.Matrix4; -i.multiply(THREE.Matrix4.makeInvert(o.matrix),THREE.Matrix4.makeInvert(o.projectionMatrix));i.multiplyVector3(A);return A}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,j;this.domElement=document.createElement("div");this.setSize=function(k,g){d=k;e=g;f=d/2;j=e/2};this.render=function(k,g){var p,c,t,F,r,w,v,y;a=b.projectScene(k,g);p=0;for(c=a.length;p0){O.r+=ca.r*U;O.g+=ca.g*U;O.b+=ca.b*U}}else if(U instanceof THREE.PointLight){da.sub(U.position,aa);da.normalize();U=Z.dot(da)*X;if(U>0){O.r+=ca.r*U;O.g+=ca.g*U;O.b+=ca.b*U}}}}function b(R,aa,Z,O,G,U){if(G.opacity!=0){j(G.opacity);k(G.blending);Q=R.positionScreen.x;J=R.positionScreen.y;P=aa.positionScreen.x; -S=aa.positionScreen.y;E=Z.positionScreen.x;T=Z.positionScreen.y;var ca=Q,X=J,$=P,ea=S,ba=E,fa=T;u.beginPath();u.moveTo(ca,X);u.lineTo($,ea);u.lineTo(ba,fa);u.lineTo(ca,X);u.closePath();if(G instanceof THREE.MeshBasicMaterial)if(G.map&&G.map.loaded)f(Q,J,P,S,E,T,G.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(G.env_map&&G.env_map.loaded){if(G.env_map.mapping==THREE.ReflectionMapping){da.copy(O.vertexNormalsWorld[0]);z=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+ -da.z*camera.matrix.n13)*0.5+0.5;K=-(da.x*camera.matrix.n21+da.y*camera.matrix.n22+da.z*camera.matrix.n23)*0.5+0.5;da.copy(O.vertexNormalsWorld[1]);W=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+da.z*camera.matrix.n13)*0.5+0.5;ga=-(da.x*camera.matrix.n21+da.y*camera.matrix.n22+da.z*camera.matrix.n23)*0.5+0.5;da.copy(O.vertexNormalsWorld[2]);ma=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+da.z*camera.matrix.n13)*0.5+0.5;ua=-(da.x*camera.matrix.n21+da.y*camera.matrix.n22+da.z*camera.matrix.n23)* -0.5+0.5;f(Q,J,P,S,E,T,G.env_map.image,z,K,W,ga,ma,ua)}}else G.wireframe?d(G.color.__styleString,G.wireframe_linewidth):e(G.color.__styleString);else if(G instanceof THREE.MeshLambertMaterial){if(G.map&&!G.wireframe){f(Q,J,P,S,E,T,G.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);k(THREE.SubtractiveBlending)}if(za)if(!G.wireframe&&G.shading==THREE.SmoothShading&&O.vertexNormalsWorld.length==3){I.r=H.r=V.r=ja.r;I.g=H.g=V.g=ja.g;I.b=H.b=V.b=ja.b;a(U,O.v1.positionWorld,O.vertexNormalsWorld[0], -I);a(U,O.v2.positionWorld,O.vertexNormalsWorld[1],H);a(U,O.v3.positionWorld,O.vertexNormalsWorld[2],V);N.r=(H.r+V.r)*0.5;N.g=(H.g+V.g)*0.5;N.b=(H.b+V.b)*0.5;s=g(I,H,V,N);f(Q,J,P,S,E,T,s,0,0,1,0,0,1)}else{ka.r=ja.r;ka.g=ja.g;ka.b=ja.b;a(U,O.centroidWorld,O.normalWorld,ka);D.r=G.color.r*ka.r;D.g=G.color.g*ka.g;D.b=G.color.b*ka.b;D.updateStyleString();G.wireframe?d(D.__styleString,G.wireframe_linewidth):e(D.__styleString)}else G.wireframe?d(G.color.__styleString,G.wireframe_linewidth):e(G.color.__styleString)}else if(G instanceof -THREE.MeshDepthMaterial){M=G.__2near;Y=G.__farPlusNear;q=G.__farMinusNear;I.r=I.g=I.b=1-M/(Y-R.positionScreen.z*q);H.r=H.g=H.b=1-M/(Y-aa.positionScreen.z*q);V.r=V.g=V.b=1-M/(Y-Z.positionScreen.z*q);N.r=(H.r+V.r)*0.5;N.g=(H.g+V.g)*0.5;N.b=(H.b+V.b)*0.5;s=g(I,H,V,N);f(Q,J,P,S,E,T,s,0,0,1,0,0,1)}else if(G instanceof THREE.MeshNormalMaterial){D.r=p(O.normalWorld.x);D.g=p(O.normalWorld.y);D.b=p(O.normalWorld.z);D.updateStyleString();G.wireframe?d(D.__styleString,G.wireframe_linewidth):e(D.__styleString)}}} -function d(R,aa){if(i!=R)u.strokeStyle=i=R;if(h!=aa)u.lineWidth=h=aa;u.stroke();ha.inflate(aa*2)}function e(R){if(n!=R)u.fillStyle=n=R;u.fill()}function f(R,aa,Z,O,G,U,ca,X,$,ea,ba,fa,oa){var na,ia;na=ca.width-1;ia=ca.height-1;X*=na;$*=ia;ea*=na;ba*=ia;fa*=na;oa*=ia;Z-=R;O-=aa;G-=R;U-=aa;ea-=X;ba-=$;fa-=X;oa-=$;ia=1/(ea*oa-fa*ba);na=(oa*Z-ba*G)*ia;ba=(oa*O-ba*U)*ia;Z=(ea*G-fa*Z)*ia;O=(ea*U-fa*O)*ia;R=R-na*X-Z*$;aa=aa-ba*X-O*$;u.save();u.transform(na,ba,Z,O,R,aa);u.clip();u.drawImage(ca,0,0);u.restore()} -function j(R){if(A!=R)u.globalAlpha=A=R}function k(R){if(o!=R){switch(R){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}o=R}}function g(R,aa,Z,O){la[0]=m(0,x(255,~~(R.r*255)));la[1]=m(0,x(255,~~(R.g*255)));la[2]=m(0,x(255,~~(R.b*255)));la[4]=m(0,x(255,~~(aa.r*255)));la[5]=m(0,x(255,~~(aa.g*255)));la[6]=m(0,x(255,~~(aa.b*255)));la[8]=m(0, -x(255,~~(Z.r*255)));la[9]=m(0,x(255,~~(Z.g*255)));la[10]=m(0,x(255,~~(Z.b*255)));la[12]=m(0,x(255,~~(O.r*255)));la[13]=m(0,x(255,~~(O.g*255)));la[14]=m(0,x(255,~~(O.b*255)));va.putImageData(Aa,0,0);ya.drawImage(wa,0,0);return xa}function p(R){return R<0?x((1+R)*0.5,0.5):0.5+x(R*0.5,0.5)}function c(R,aa){var Z=aa.x-R.x,O=aa.y-R.y,G=1/Math.sqrt(Z*Z+O*O);Z*=G;O*=G;aa.x+=Z;aa.y+=O;R.x-=Z;R.y-=O}var t=null,F=new THREE.Projector,r=document.createElement("canvas"),w,v,y,L,u=r.getContext("2d"),A=1,o=0,i= -null,n=null,h=1,x=Math.min,m=Math.max,l,B,C,Q,J,P,S,E,T,D=new THREE.Color,I=new THREE.Color,H=new THREE.Color,V=new THREE.Color,N=new THREE.Color,M,Y,q,s,z,K,W,ga,ma,ua,pa=new THREE.Rectangle,qa=new THREE.Rectangle,ha=new THREE.Rectangle,za=false,ka=new THREE.Color,ja=new THREE.Color,ra=new THREE.Color,sa=new THREE.Color,Da=Math.PI*2,da=new THREE.Vector3,wa,va,Aa,la,xa,ya,ta=16;wa=document.createElement("canvas");wa.width=wa.height=2;va=wa.getContext("2d");va.fillStyle="rgba(0,0,0,1)";va.fillRect(0, -0,2,2);Aa=va.getImageData(0,0,2,2);la=Aa.data;xa=document.createElement("canvas");xa.width=xa.height=ta;ya=xa.getContext("2d");ya.translate(-ta/2,-ta/2);ya.scale(ta,ta);ta--;this.domElement=r;this.autoClear=true;this.setSize=function(R,aa){w=R;v=aa;y=w/2;L=v/2;r.width=w;r.height=v;pa.set(-y,-L,y,L)};this.clear=function(){if(!qa.isEmpty()){qa.inflate(1);qa.minSelf(pa);u.clearRect(qa.getX(),qa.getY(),qa.getWidth(),qa.getHeight());qa.empty()}};this.render=function(R,aa){var Z,O,G,U,ca,X,$,ea;u.setTransform(1, -0,0,-1,y,L);this.autoClear&&this.clear();t=F.projectScene(R,aa);if(za=R.lights.length>0){ca=R.lights;ja.setRGB(0,0,0);ra.setRGB(0,0,0);sa.setRGB(0,0,0);Z=0;for(O=ca.length;Z>1;Ca=ia.height>>1;oa=$.scale.x*y;na=$.scale.y*L;ea=oa*Ba;fa=na*Ca;ha.set(X.x-ea,X.y-fa,X.x+ea,X.y+fa);if(pa.instersects(ha)){u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(oa,-na);u.translate(-Ba,-Ca);u.drawImage(ia, -0,0);u.restore()}}}else if(ba instanceof THREE.ParticleCircleMaterial){if(za){ka.r=ja.r+ra.r+sa.r;ka.g=ja.g+ra.g+sa.g;ka.b=ja.b+ra.b+sa.b;D.r=ba.color.r*ka.r;D.g=ba.color.g*ka.g;D.b=ba.color.b*ka.b;D.updateStyleString()}else D.__styleString=ba.color.__styleString;ea=$.scale.x*y;fa=$.scale.y*L;ha.set(X.x-ea,X.y-fa,X.x+ea,X.y+fa);if(pa.instersects(ha)){ba=D.__styleString;if(n!=ba)u.fillStyle=n=ba;u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(ea,fa);u.beginPath();u.arc(0,0,1,0,Da,true); -u.closePath();u.fill();u.restore()}}}}}else if(G instanceof THREE.RenderableLine){l=G.v1;B=G.v2;l.positionScreen.x*=y;l.positionScreen.y*=L;B.positionScreen.x*=y;B.positionScreen.y*=L;ha.addPoint(l.positionScreen.x,l.positionScreen.y);ha.addPoint(B.positionScreen.x,B.positionScreen.y);if(pa.instersects(ha)){U=0;for(ca=G.material.length;U0){H.r+=M.color.r*Y;H.g+=M.color.g*Y;H.b+=M.color.b*Y}}else if(M instanceof THREE.PointLight){l.sub(M.position,I.centroidWorld);l.normalize();Y=I.normalWorld.dot(l)*M.intensity;if(Y>0){H.r+=M.color.r*Y;H.g+=M.color.g*Y;H.b+=M.color.b*Y}}}}function b(D,I,H,V,N,M){J=e(P++);J.setAttribute("d","M "+D.positionScreen.x+ -" "+D.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+H.positionScreen.x+","+H.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)o.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(A){i.r=n.r;i.g=n.g;i.b=n.b;a(M,V,i);o.r=N.color.r*i.r;o.g=N.color.g*i.g;o.b=N.color.b*i.b;o.updateStyleString()}else o.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){m=1-N.__2near/(N.__farPlusNear-V.z*N.__farMinusNear); -o.setRGB(m,m,m)}else N instanceof THREE.MeshNormalMaterial&&o.setRGB(f(V.normalWorld.x),f(V.normalWorld.y),f(V.normalWorld.z));N.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+N.opacity);g.appendChild(J)}function d(D,I,H,V,N,M,Y){J=e(P++);J.setAttribute("d", -"M "+D.positionScreen.x+" "+D.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+H.positionScreen.x+","+H.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)o.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(A){i.r=n.r;i.g=n.g;i.b=n.b;a(Y,N,i);o.r=M.color.r*i.r;o.g=M.color.g*i.g;o.b=M.color.b*i.b;o.updateStyleString()}else o.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){m= -1-M.__2near/(M.__farPlusNear-N.z*M.__farMinusNear);o.setRGB(m,m,m)}else M instanceof THREE.MeshNormalMaterial&&o.setRGB(f(N.normalWorld.x),f(N.normalWorld.y),f(N.normalWorld.z));M.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(J)} -function e(D){if(B[D]==null){B[D]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&B[D].setAttribute("shape-rendering","crispEdges");return B[D]}return B[D]}function f(D){return D<0?Math.min((1+D)*0.5,0.5):0.5+Math.min(D*0.5,0.5)}var j=null,k=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,c,t,F,r,w,v,y,L=new THREE.Rectangle,u=new THREE.Rectangle,A=false,o=new THREE.Color(16777215),i=new THREE.Color(16777215),n=new THREE.Color(0),h=new THREE.Color(0), -x=new THREE.Color(0),m,l=new THREE.Vector3,B=[],C=[],Q=[],J,P,S,E,T=1;this.domElement=g;this.autoClear=true;this.setQuality=function(D){switch(D){case "high":T=1;break;case "low":T=0}};this.setSize=function(D,I){p=D;c=I;t=p/2;F=c/2;g.setAttribute("viewBox",-t+" "+-F+" "+p+" "+c);g.setAttribute("width",p);g.setAttribute("height",c);L.set(-t,-F,t,F)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(D,I){var H,V,N,M,Y,q,s,z;this.autoClear&&this.clear(); -j=k.projectScene(D,I);E=S=P=0;if(A=D.lights.length>0){s=D.lights;n.setRGB(0,0,0);h.setRGB(0,0,0);x.setRGB(0,0,0);H=0;for(V=s.length;H=0&&c.enableVertexAttribArray(i.attributes[m])}}function k(i,n){var h;if(i=="fragment")h=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")h=c.createShader(c.VERTEX_SHADER);c.shaderSource(h,n);c.compileShader(h);if(!c.getShaderParameter(h,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(h)); -return null}return h}function g(i){switch(i){case THREE.Repeat:return c.REPEAT;case THREE.ClampToEdge:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return c.MIRRORED_REPEAT}return 0}var p=document.createElement("canvas"),c,t,F,r=new THREE.Matrix4,w,v=new Float32Array(16),y=new Float32Array(16),L=new Float32Array(16),u=new Float32Array(9),A=new Float32Array(16);a=function(i,n){if(i){var h,x,m,l=pointLights=maxDirLights=maxPointLights=0;h=0;for(x=i.lights.length;h= 0.0 )": -"",n?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",n?"pointDiffuse += mColor * pointDiffuseWeight;":"",n?"pointSpecular += mSpecular * pointSpecularWeight;":"",n?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",n?"totalLight += pointDiffuse + pointSpecular;": +THREE.Projector=function(){function a(y,n){var i=0,m=1,h=y.z+y.w,z=n.z+n.w,l=-y.z+y.w,o=-n.z+n.w;if(h>=0&&z>=0&&l>=0&&o>=0)return true;else if(h<0&&z<0||l<0&&o<0)return false;else{if(h<0)i=Math.max(i,h/(h-z));else if(z<0)m=Math.min(m,h/(h-z));if(l<0)i=Math.max(i,l/(l-o));else if(o<0)m=Math.min(m,l/(l-o));if(m0&&J.z<1}V=A.geometry.faces;h=0;for(z=V.length;h0&&r.z<1){c=C[v]=C[v]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=A.rotation.z;c.scale.x=A.scale.x*Math.abs(c.x-(r.x+n.projectionMatrix.n11)/(r.w+n.projectionMatrix.n14));c.scale.y=A.scale.y*Math.abs(c.y-(r.y+n.projectionMatrix.n22)/(r.w+n.projectionMatrix.n24));c.material=A.material;b.push(c);v++}}}b.sort(function(Y,P){return P.z-Y.z});return b};this.unprojectVector=function(y,n){var i=new THREE.Matrix4; +i.multiply(THREE.Matrix4.makeInvert(n.matrix),THREE.Matrix4.makeInvert(n.projectionMatrix));i.multiplyVector3(y);return y}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,j;this.domElement=document.createElement("div");this.setSize=function(k,f){d=k;e=f;g=d/2;j=e/2};this.render=function(k,f){var p,c,v,C,r,t,u,w;a=b.projectScene(k,f);p=0;for(c=a.length;p0){F.r+=da.r*Z;F.g+=da.g*Z;F.b+=da.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,X);$.normalize();Z=S.dot($)*fa;if(Z>0){F.r+=da.r*Z;F.g+=da.g*Z;F.b+=da.b*Z}}}}function Na(H,X,S){if(S.opacity!=0){Ea(S.opacity);za(S.blending);var F,O,Z,da,fa,ga;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){da=S.map;fa=da.width>>1;ga=da.height>>1;O=X.scale.x*j;Z=X.scale.y*k;S=O*fa;F=Z*ga;q.set(H.x-S,H.y-F,H.x+S, +H.y+F);if(M.instersects(q)){f.save();f.translate(H.x,H.y);f.rotate(-X.rotation);f.scale(O,-Z);f.translate(-fa,-ga);f.drawImage(da,0,0);f.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(s){x.r=G.r+U.r+ca.r;x.g=G.g+U.g+ca.g;x.b=G.b+U.b+ca.b;l.r=S.color.r*x.r;l.g=S.color.g*x.g;l.b=S.color.b*x.b;l.updateStyleString()}else l.__styleString=S.color.__styleString;S=X.scale.x*j;F=X.scale.y*k;q.set(H.x-S,H.y-F,H.x+S,H.y+F);if(M.instersects(q)){O=l.__styleString;if(C!=O)f.fillStyle=C=O;f.save(); +f.translate(H.x,H.y);f.rotate(-X.rotation);f.scale(S,F);f.beginPath();f.arc(0,0,1,0,ha,true);f.closePath();f.fill();f.restore()}}}}function Oa(H,X,S,F){if(F.opacity!=0){Ea(F.opacity);za(F.blending);f.beginPath();f.moveTo(H.positionScreen.x,H.positionScreen.y);f.lineTo(X.positionScreen.x,X.positionScreen.y);f.closePath();if(F instanceof THREE.LineBasicMaterial){l.__styleString=F.color.__styleString;H=F.linewidth;if(r!=H)f.lineWidth=r=H;H=l.__styleString;if(v!=H)f.strokeStyle=v=H;f.stroke();q.inflate(F.linewidth* +2)}}}function Ia(H,X,S,F,O,Z){if(O.opacity!=0){Ea(O.opacity);za(O.blending);y=H.positionScreen.x;n=H.positionScreen.y;i=X.positionScreen.x;m=X.positionScreen.y;h=S.positionScreen.x;z=S.positionScreen.y;f.beginPath();f.moveTo(y,n);f.lineTo(i,m);f.lineTo(h,z);f.lineTo(y,n);f.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map&&!O.wireframe)O.map.mapping instanceof THREE.UVMapping&&sa(y,n,i,m,h,z,O.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(O.env_map){if(O.env_map.mapping instanceof +THREE.SphericalReflectionMapping){$.copy(F.vertexNormalsWorld[0]);V=($.x*ba.matrix.n11+$.y*ba.matrix.n12+$.z*ba.matrix.n13)*0.5+0.5;J=-($.x*ba.matrix.n21+$.y*ba.matrix.n22+$.z*ba.matrix.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[1]);L=($.x*ba.matrix.n11+$.y*ba.matrix.n12+$.z*ba.matrix.n13)*0.5+0.5;N=-($.x*ba.matrix.n21+$.y*ba.matrix.n22+$.z*ba.matrix.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[2]);Y=($.x*ba.matrix.n11+$.y*ba.matrix.n12+$.z*ba.matrix.n13)*0.5+0.5;P=-($.x*ba.matrix.n21+$.y*ba.matrix.n22+ +$.z*ba.matrix.n23)*0.5+0.5;sa(y,n,i,m,h,z,O.env_map.image,V,J,L,N,Y,P)}}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof THREE.UVMapping&&sa(y,n,i,m,h,z,O.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);za(THREE.SubtractiveBlending)}if(s)if(!O.wireframe&&O.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){o.r=B.r=A.r=G.r; +o.g=B.g=A.g=G.g;o.b=B.b=A.b=G.b;ya(Z,F.v1.positionWorld,F.vertexNormalsWorld[0],o);ya(Z,F.v2.positionWorld,F.vertexNormalsWorld[1],B);ya(Z,F.v3.positionWorld,F.vertexNormalsWorld[2],A);Q.r=(B.r+A.r)*0.5;Q.g=(B.g+A.g)*0.5;Q.b=(B.b+A.b)*0.5;D=Ja(o,B,A,Q);sa(y,n,i,m,h,z,D,0,0,1,0,0,1)}else{x.r=G.r;x.g=G.g;x.b=G.b;ya(Z,F.centroidWorld,F.normalWorld,x);l.r=O.color.r*x.r;l.g=O.color.g*x.g;l.b=O.color.b*x.b;l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}else O.wireframe? +Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){K=O.__2near;R=O.__farPlusNear;T=O.__farMinusNear;o.r=o.g=o.b=1-K/(R-H.positionScreen.z*T);B.r=B.g=B.b=1-K/(R-X.positionScreen.z*T);A.r=A.g=A.b=1-K/(R-S.positionScreen.z*T);Q.r=(B.r+A.r)*0.5;Q.g=(B.g+A.g)*0.5;Q.b=(B.b+A.b)*0.5;D=Ja(o,B,A,Q);sa(y,n,i,m,h,z,D,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){l.r=Fa(F.normalWorld.x);l.g=Fa(F.normalWorld.y);l.b=Fa(F.normalWorld.z); +l.updateStyleString();O.wireframe?Aa(l.__styleString,O.wireframe_linewidth):Ba(l.__styleString)}}}function Aa(H,X){if(v!=H)f.strokeStyle=v=H;if(r!=X)f.lineWidth=r=X;f.stroke();q.inflate(X*2)}function Ba(H){if(C!=H)f.fillStyle=C=H;f.fill()}function sa(H,X,S,F,O,Z,da,fa,ga,ta,ma,ua,va){var na,ka;na=da.width-1;ka=da.height-1;fa*=na;ga*=ka;ta*=na;ma*=ka;ua*=na;va*=ka;S-=H;F-=X;O-=H;Z-=X;ta-=fa;ma-=ga;ua-=fa;va-=ga;ka=1/(ta*va-ua*ma);na=(va*S-ma*O)*ka;ma=(va*F-ma*Z)*ka;S=(ta*O-ua*S)*ka;F=(ta*Z-ua*F)*ka; +H=H-na*fa-S*ga;X=X-ma*fa-F*ga;f.save();f.transform(na,ma,S,F,H,X);f.clip();f.drawImage(da,0,0);f.restore()}function Ea(H){if(p!=H)f.globalAlpha=p=H}function za(H){if(c!=H){switch(H){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=H}}function Ja(H,X,S,F){ea[0]=u(0,t(255,~~(H.r*255)));ea[1]=u(0,t(255,~~(H.g*255)));ea[2]=u(0,t(255,~~(H.b* +255)));ea[4]=u(0,t(255,~~(X.r*255)));ea[5]=u(0,t(255,~~(X.g*255)));ea[6]=u(0,t(255,~~(X.b*255)));ea[8]=u(0,t(255,~~(S.r*255)));ea[9]=u(0,t(255,~~(S.g*255)));ea[10]=u(0,t(255,~~(S.b*255)));ea[12]=u(0,t(255,~~(F.r*255)));ea[13]=u(0,t(255,~~(F.g*255)));ea[14]=u(0,t(255,~~(F.b*255)));qa.putImageData(Da,0,0);xa.drawImage(la,0,0);return ra}function Fa(H){return H<0?t((1+H)*0.5,0.5):0.5+t(H*0.5,0.5)}function Ga(H,X){var S=X.x-H.x,F=X.y-H.y,O=1/Math.sqrt(S*S+F*F);S*=O;F*=O;X.x+=S;X.y+=F;H.x-=S;H.y-=F}var Ca, +Ka,aa,ia,pa,Ha,La,wa;f.setTransform(1,0,0,-1,j,k);this.autoClear&&this.clear();a=b.projectScene(ja,ba);(s=ja.lights.length>0)&&Ma(ja);Ca=0;for(Ka=a.length;Ca0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}else if(M instanceof THREE.PointLight){o.sub(M.position,L.centroidWorld);o.normalize();W=L.normalWorld.dot(o)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}}}function b(J,L,N,Y,P,M){K=e(R++);K.setAttribute("d","M "+J.positionScreen.x+ +" "+J.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(P instanceof THREE.MeshBasicMaterial)n.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshLambertMaterial)if(y){i.r=m.r;i.g=m.g;i.b=m.b;a(M,Y,i);n.r=P.color.r*i.r;n.g=P.color.g*i.g;n.b=P.color.b*i.b;n.updateStyleString()}else n.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshDepthMaterial){l=1-P.__2near/(P.__farPlusNear-Y.z*P.__farMinusNear); +n.setRGB(l,l,l)}else P instanceof THREE.MeshNormalMaterial&&n.setRGB(g(Y.normalWorld.x),g(Y.normalWorld.y),g(Y.normalWorld.z));P.wireframe?K.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+P.wireframe_linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.wireframe_linecap+"; stroke-linejoin: "+P.wireframe_linejoin):K.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+P.opacity);f.appendChild(K)}function d(J,L,N,Y,P,M,W){K=e(R++);K.setAttribute("d", +"M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(y){i.r=m.r;i.g=m.g;i.b=m.b;a(W,P,i);n.r=M.color.r*i.r;n.g=M.color.g*i.g;n.b=M.color.b*i.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){l= +1-M.__2near/(M.__farPlusNear-P.z*M.__farMinusNear);n.setRGB(l,l,l)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(g(P.normalWorld.x),g(P.normalWorld.y),g(P.normalWorld.z));M.wireframe?K.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):K.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);f.appendChild(K)} +function e(J){if(B[J]==null){B[J]=document.createElementNS("http://www.w3.org/2000/svg","path");V==0&&B[J].setAttribute("shape-rendering","crispEdges");return B[J]}return B[J]}function g(J){return J<0?Math.min((1+J)*0.5,0.5):0.5+Math.min(J*0.5,0.5)}var j=null,k=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,c,v,C,r,t,u,w,I=new THREE.Rectangle,E=new THREE.Rectangle,y=false,n=new THREE.Color(16777215),i=new THREE.Color(16777215),m=new THREE.Color(0),h=new THREE.Color(0), +z=new THREE.Color(0),l,o=new THREE.Vector3,B=[],A=[],Q=[],K,R,T,D,V=1;this.domElement=f;this.autoClear=true;this.setQuality=function(J){switch(J){case "high":V=1;break;case "low":V=0}};this.setSize=function(J,L){p=J;c=L;v=p/2;C=c/2;f.setAttribute("viewBox",-v+" "+-C+" "+p+" "+c);f.setAttribute("width",p);f.setAttribute("height",c);I.set(-v,-C,v,C)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(J,L){var N,Y,P,M,W,q,s,x;this.autoClear&&this.clear(); +j=k.projectScene(J,L);D=T=R=0;if(y=J.lights.length>0){s=J.lights;m.setRGB(0,0,0);h.setRGB(0,0,0);z.setRGB(0,0,0);N=0;for(Y=s.length;N=0&&c.enableVertexAttribArray(i.attributes[l])}}function k(i,m){var h;if(i=="fragment")h=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")h=c.createShader(c.VERTEX_SHADER);c.shaderSource(h,m);c.compileShader(h);if(!c.getShaderParameter(h,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(h)); +return null}return h}function f(i){switch(i){case THREE.Repeat:return c.REPEAT;case THREE.ClampToEdge:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return c.MIRRORED_REPEAT}return 0}var p=document.createElement("canvas"),c,v,C,r=new THREE.Matrix4,t,u=new Float32Array(16),w=new Float32Array(16),I=new Float32Array(16),E=new Float32Array(9),y=new Float32Array(16);a=function(i,m){if(i){var h,z,l,o=pointLights=maxDirLights=maxPointLights=0;h=0;for(z=i.lights.length;h= 0.0 )": +"",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",i?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"vec3 dirVector = normalize( lDirection.xyz );":"",i?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;": "","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n"); -h=b(x,h);c.useProgram(h);f(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);i&&f(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);n&&f(h,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);j(h,["position","normal","uv"]);return h}(a.directional,a.point);this.setSize=function(i,n){p.width=i;p.height=n;c.viewport(0,0,p.width,p.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,n){var h,x,m,l,B,C=[], -Q=[],J=[];l=[];B=[];c.uniform1i(i.uniforms.enableLighting,n.length);h=0;for(x=n.length;h0){H.__webGLUVBuffer=c.createBuffer(); -c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW)}H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(P),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(S),c.STATIC_DRAW);H.__webGLFaceCount=P.length;H.__webGLLineCount=S.length}};this.renderBuffer= -function(i,n,h,x){var m,l,B,C,Q,J,P,S,E;if(h instanceof THREE.MeshShaderMaterial){if(!h.program){h.program=b(h.fragment_shader,h.vertex_shader);P=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in h.uniforms)P.push(E);f(h.program,P);j(h.program,["position","normal","uv"])}E=h.program}else E=F;if(E!=t){c.useProgram(E);t=E}E==F&&this.setupLights(E,n);this.loadCamera(E,i);this.loadMatrices(E);if(h instanceof THREE.MeshShaderMaterial){B=h.wireframe; -C=h.wireframe_linewidth;i=E;n=h.uniforms;var T;for(m in n){S=n[m].type;P=n[m].value;T=i.uniforms[m];if(S=="i")c.uniform1i(T,P);else if(S=="f")c.uniform1f(T,P);else if(S=="t"){c.uniform1i(T,P);S=n[m].texture;if(S instanceof THREE.TextureCube)d(S,P);else S instanceof THREE.Texture&&e(S,P)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){m=h.color;l=h.opacity;B=h.wireframe;C=h.wireframe_linewidth;Q=h.map;J=h.env_map;n=h.combine== -THREE.Mix;i=h.reflectivity;S=h.env_map&&h.env_map.mapping==THREE.RefractionMapping;P=h.refraction_ratio;c.uniform4f(E.uniforms.mColor,m.r*l,m.g*l,m.b*l,l);c.uniform1i(E.uniforms.mixEnvMap,n);c.uniform1f(E.uniforms.mReflectivity,i);c.uniform1i(E.uniforms.useRefract,S);c.uniform1f(E.uniforms.mRefractionRatio,P)}if(h instanceof THREE.MeshNormalMaterial){l=h.opacity;c.uniform1f(E.uniforms.mOpacity,l);c.uniform1i(E.uniforms.material,4)}else if(h instanceof THREE.MeshDepthMaterial){l=h.opacity;B=h.wireframe; -C=h.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,l);c.uniform1f(E.uniforms.m2Near,h.__2near);c.uniform1f(E.uniforms.mFarPlusNear,h.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,h.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(h instanceof THREE.MeshPhongMaterial){m=h.ambient;i=h.specular;h=h.shininess;c.uniform4f(E.uniforms.mAmbient,m.r,m.g,m.b,l);c.uniform4f(E.uniforms.mSpecular,i.r,i.g,i.b,l);c.uniform1f(E.uniforms.mShininess,h);c.uniform1i(E.uniforms.material,2)}else if(h instanceof -THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(h instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(h instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);J=h.env_map}if(Q){e(Q,0);c.uniform1i(E.uniforms.tMap,0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(J){d(J,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);l=E.attributes;c.bindBuffer(c.ARRAY_BUFFER, -x.__webGLVertexBuffer);c.vertexAttribPointer(l.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,x.__webGLNormalBuffer);c.vertexAttribPointer(l.normal,3,c.FLOAT,false,0,0);if(l.uv>=0)if(x.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,x.__webGLUVBuffer);c.enableVertexAttribArray(l.uv);c.vertexAttribPointer(l.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(l.uv);if(B){c.lineWidth(C);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);c.drawElements(c.LINES,x.__webGLLineCount,c.UNSIGNED_SHORT, -0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,x.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,n,h,x,m,l){var B,C,Q,J,P;Q=0;for(J=h.material.length;Q=0;h--){x=i.__webGLObjects[h].object;n==x&&i.__webGLObjects.splice(h,1)}};this.setupMatrices=function(i,n){i.autoUpdateMatrix&&i.updateMatrix();r.multiply(n.matrix,i.matrix);v.set(n.matrix.flatten());y.set(r.flatten());L.set(n.projectionMatrix.flatten());w=THREE.Matrix4.makeInvert3x3(r).transpose(); -u.set(w.m);A.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,y);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,L);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,u);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,A)};this.loadCamera=function(i,n){c.uniform3f(i.uniforms.cameraPosition,n.position.x,n.position.y,n.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); -c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,n){if(i){!n||n=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}}; +h=b(z,h);c.useProgram(h);g(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);i&&g(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&g(h,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);j(h,["position","normal","uv"]);return h}(a.directional,a.point);this.setSize=function(i,m){p.width=i;p.height=m;c.viewport(0,0,p.width,p.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,m){var h,z,l,o,B,A=[], +Q=[],K=[];o=[];B=[];c.uniform1i(i.uniforms.enableLighting,m.length);h=0;for(z=m.length;h0){N.__webGLUVBuffer=c.createBuffer(); +c.bindBuffer(c.ARRAY_BUFFER,N.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(J),c.STATIC_DRAW)}N.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(R),c.STATIC_DRAW);N.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);N.__webGLFaceCount=R.length;N.__webGLLineCount=T.length}};this.renderBuffer= +function(i,m,h,z){var l,o,B,A,Q,K,R,T,D;if(h instanceof THREE.MeshShaderMaterial){if(!h.program){h.program=b(h.fragment_shader,h.vertex_shader);R=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in h.uniforms)R.push(D);g(h.program,R);j(h.program,["position","normal","uv"])}D=h.program}else D=C;if(D!=v){c.useProgram(D);v=D}D==C&&this.setupLights(D,m);this.loadCamera(D,i);this.loadMatrices(D);if(h instanceof THREE.MeshShaderMaterial){B=h.wireframe; +A=h.wireframe_linewidth;i=D;m=h.uniforms;var V;for(l in m){T=m[l].type;R=m[l].value;V=i.uniforms[l];if(T=="i")c.uniform1i(V,R);else if(T=="f")c.uniform1f(V,R);else if(T=="t"){c.uniform1i(V,R);T=m[l].texture;if(T instanceof THREE.TextureCube)d(T,R);else T instanceof THREE.Texture&&e(T,R)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){l=h.color;o=h.opacity;B=h.wireframe;A=h.wireframe_linewidth;Q=h.map;K=h.env_map;m=h.combine== +THREE.Mix;i=h.reflectivity;T=h.env_map&&h.env_map.mapping==THREE.RefractionMapping;R=h.refraction_ratio;c.uniform4f(D.uniforms.mColor,l.r*o,l.g*o,l.b*o,o);c.uniform1i(D.uniforms.mixEnvMap,m);c.uniform1f(D.uniforms.mReflectivity,i);c.uniform1i(D.uniforms.useRefract,T);c.uniform1f(D.uniforms.mRefractionRatio,R)}if(h instanceof THREE.MeshNormalMaterial){o=h.opacity;c.uniform1f(D.uniforms.mOpacity,o);c.uniform1i(D.uniforms.material,4)}else if(h instanceof THREE.MeshDepthMaterial){o=h.opacity;B=h.wireframe; +A=h.wireframe_linewidth;c.uniform1f(D.uniforms.mOpacity,o);c.uniform1f(D.uniforms.m2Near,h.__2near);c.uniform1f(D.uniforms.mFarPlusNear,h.__farPlusNear);c.uniform1f(D.uniforms.mFarMinusNear,h.__farMinusNear);c.uniform1i(D.uniforms.material,3)}else if(h instanceof THREE.MeshPhongMaterial){l=h.ambient;i=h.specular;h=h.shininess;c.uniform4f(D.uniforms.mAmbient,l.r,l.g,l.b,o);c.uniform4f(D.uniforms.mSpecular,i.r,i.g,i.b,o);c.uniform1f(D.uniforms.mShininess,h);c.uniform1i(D.uniforms.material,2)}else if(h instanceof +THREE.MeshLambertMaterial)c.uniform1i(D.uniforms.material,1);else if(h instanceof THREE.MeshBasicMaterial)c.uniform1i(D.uniforms.material,0);else if(h instanceof THREE.MeshCubeMaterial){c.uniform1i(D.uniforms.material,5);K=h.env_map}if(Q){e(Q,0);c.uniform1i(D.uniforms.tMap,0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(K){d(K,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);o=D.attributes;c.bindBuffer(c.ARRAY_BUFFER, +z.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,z.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);if(o.uv>=0)if(z.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,z.__webGLUVBuffer);c.enableVertexAttribArray(o.uv);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(o.uv);if(B){c.lineWidth(A);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLLineBuffer);c.drawElements(c.LINES,z.__webGLLineCount,c.UNSIGNED_SHORT, +0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,z.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,z.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(i,m,h,z,l,o){var B,A,Q,K,R;Q=0;for(K=h.material.length;Q=0;h--){z=i.__webGLObjects[h].object;m==z&&i.__webGLObjects.splice(h,1)}};this.setupMatrices=function(i,m){i.autoUpdateMatrix&&i.updateMatrix();r.multiply(m.matrix,i.matrix);u.set(m.matrix.flatten());w.set(r.flatten());I.set(m.projectionMatrix.flatten());t=THREE.Matrix4.makeInvert3x3(r).transpose(); +E.set(t.m);y.set(i.matrix.flatten())};this.loadMatrices=function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,u);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,I);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,E);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,y)};this.loadCamera=function(i,m){c.uniform3f(i.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); +c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,m){if(i){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}}; 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.faceMaterial=this.meshMaterial=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.material=null}; THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; -var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,f=d?b.geometry:b,j=a.vertices,k=f.vertices,g=a.faces,p=f.faces,c=a.uvs;f=f.uvs;d&&b.updateMatrix();for(var t=0,F=k.length;t0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,k,F)))-1);p.push(c)}b.push(p)}var r,w,v;a=b.length;for(d=0;d0)for(e=0;e1){r=this.vertices[j].position.clone(); -w=this.vertices[g].position.clone();v=this.vertices[p].position.clone();r.normalize();w.normalize();v.normalize();this.faces.push(new THREE.Face3(j,g,p,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,t,y])}}}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,k,C)))-1);p.push(c)}b.push(p)}var r,t,u;a=b.length;for(d=0;d0)for(e=0;e1){r=this.vertices[j].position.clone(); +t=this.vertices[f].position.clone();u=this.vertices[p].position.clone();r.normalize();t.normalize();u.normalize();this.faces.push(new THREE.Face3(j,f,p,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(u.x,u.y,u.z)]));this.uvs.push([c,v,w])}}}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null}; THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML= -b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);a.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers, -j.data.materials,b,d,f)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,f){var j=new XMLHttpRequest,k=e+"/"+a,g=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,e,b):alert("Couldn't load ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(g==0)g=j.getResponseHeader("Content-Length");f({total:g,loaded:j.responseText.length})}}else if(j.readyState== -2)g=j.getResponseHeader("Content-Length")};j.open("GET",k,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(a,b,d,e){var f=function(j){function k(q,s){var z=t(q,s),K=t(q,s+1),W=t(q,s+2),ga=t(q,s+3),ma=(ga<<1&255|W>>7)-127;z=(W&127)<<16|K<<8|z;if(z==0&&ma==-127)return 0;return(1-2*(ga>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ma)}function g(q,s){var z=t(q,s),K=t(q,s+1),W=t(q,s+2);return(t(q,s+3)<<24)+(W<< -16)+(K<<8)+z}function p(q,s){var z=t(q,s);return(t(q,s+1)<<8)+z}function c(q,s){var z=t(q,s);return z>127?z-256:z}function t(q,s){return q.charCodeAt(s)&255}function F(q){var s,z,K;s=g(a,q);z=g(a,q+h);K=g(a,q+x);q=p(a,q+m);THREE.Loader.prototype.f3(u,s,z,K,q)}function r(q){var s,z,K,W,ga,ma;s=g(a,q);z=g(a,q+h);K=g(a,q+x);W=p(a,q+m);ga=g(a,q+l);ma=g(a,q+B);q=g(a,q+C);THREE.Loader.prototype.f3n(u,i,s,z,K,W,ga,ma,q)}function w(q){var s,z,K,W;s=g(a,q);z=g(a,q+Q);K=g(a,q+J);W=g(a,q+P);q=p(a,q+S);THREE.Loader.prototype.f4(u, -s,z,K,W,q)}function v(q){var s,z,K,W,ga,ma,ua,pa;s=g(a,q);z=g(a,q+Q);K=g(a,q+J);W=g(a,q+P);ga=p(a,q+S);ma=g(a,q+E);ua=g(a,q+T);pa=g(a,q+D);q=g(a,q+I);THREE.Loader.prototype.f4n(u,i,s,z,K,W,ga,ma,ua,pa,q)}function y(q){var s,z;s=g(a,q);z=g(a,q+H);q=g(a,q+V);THREE.Loader.prototype.uv3(u,n[s*2],n[s*2+1],n[z*2],n[z*2+1],n[q*2],n[q*2+1])}function L(q){var s,z,K;s=g(a,q);z=g(a,q+N);K=g(a,q+M);q=g(a,q+Y);THREE.Loader.prototype.uv4(u,n[s*2],n[s*2+1],n[z*2],n[z*2+1],n[K*2],n[K*2+1],n[q*2],n[q*2+1])}var u= -this,A=0,o,i=[],n=[],h,x,m,l,B,C,Q,J,P,S,E,T,D,I,H,V,N,M,Y;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,e,j);o={signature:a.substr(A,8),header_bytes:t(a,A+8),vertex_coordinate_bytes:t(a,A+9),normal_coordinate_bytes:t(a,A+10),uv_coordinate_bytes:t(a,A+11),vertex_index_bytes:t(a,A+12),normal_index_bytes:t(a,A+13),uv_index_bytes:t(a,A+14),material_index_bytes:t(a,A+15),nvertices:g(a,A+16),nnormals:g(a,A+16+4),nuvs:g(a,A+16+8),ntri_flat:g(a,A+16+12),ntri_smooth:g(a,A+16+16),ntri_flat_uv:g(a, -A+16+20),ntri_smooth_uv:g(a,A+16+24),nquad_flat:g(a,A+16+28),nquad_smooth:g(a,A+16+32),nquad_flat_uv:g(a,A+16+36),nquad_smooth_uv:g(a,A+16+40)};A+=o.header_bytes;h=o.vertex_index_bytes;x=o.vertex_index_bytes*2;m=o.vertex_index_bytes*3;l=o.vertex_index_bytes*3+o.material_index_bytes;B=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;C=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;Q=o.vertex_index_bytes;J=o.vertex_index_bytes*2;P=o.vertex_index_bytes*3;S=o.vertex_index_bytes* -4;E=o.vertex_index_bytes*4+o.material_index_bytes;T=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes;D=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;I=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;H=o.uv_index_bytes;V=o.uv_index_bytes*2;N=o.uv_index_bytes;M=o.uv_index_bytes*2;Y=o.uv_index_bytes*3;A+=function(q){var s,z,K,W=o.vertex_coordinate_bytes*3,ga=q+o.nvertices*W;for(q=q;q>7)-127;x=(U&127)<<16|G<<8|x;if(x==0&&ha==-127)return 0;return(1-2*(ca>>7))*(1+x*Math.pow(2,-23))*Math.pow(2,ha)}function f(q,s){var x=v(q,s),G=v(q,s+1),U=v(q,s+2);return(v(q,s+3)<<24)+(U<< +16)+(G<<8)+x}function p(q,s){var x=v(q,s);return(v(q,s+1)<<8)+x}function c(q,s){var x=v(q,s);return x>127?x-256:x}function v(q,s){return q.charCodeAt(s)&255}function C(q){var s,x,G;s=f(a,q);x=f(a,q+h);G=f(a,q+z);q=p(a,q+l);THREE.Loader.prototype.f3(E,s,x,G,q)}function r(q){var s,x,G,U,ca,ha;s=f(a,q);x=f(a,q+h);G=f(a,q+z);U=p(a,q+l);ca=f(a,q+o);ha=f(a,q+B);q=f(a,q+A);THREE.Loader.prototype.f3n(E,i,s,x,G,U,ca,ha,q)}function t(q){var s,x,G,U;s=f(a,q);x=f(a,q+Q);G=f(a,q+K);U=f(a,q+R);q=p(a,q+T);THREE.Loader.prototype.f4(E, +s,x,G,U,q)}function u(q){var s,x,G,U,ca,ha,$,la;s=f(a,q);x=f(a,q+Q);G=f(a,q+K);U=f(a,q+R);ca=p(a,q+T);ha=f(a,q+D);$=f(a,q+V);la=f(a,q+J);q=f(a,q+L);THREE.Loader.prototype.f4n(E,i,s,x,G,U,ca,ha,$,la,q)}function w(q){var s,x;s=f(a,q);x=f(a,q+N);q=f(a,q+Y);THREE.Loader.prototype.uv3(E,m[s*2],m[s*2+1],m[x*2],m[x*2+1],m[q*2],m[q*2+1])}function I(q){var s,x,G;s=f(a,q);x=f(a,q+P);G=f(a,q+M);q=f(a,q+W);THREE.Loader.prototype.uv4(E,m[s*2],m[s*2+1],m[x*2],m[x*2+1],m[G*2],m[G*2+1],m[q*2],m[q*2+1])}var E=this, +y=0,n,i=[],m=[],h,z,l,o,B,A,Q,K,R,T,D,V,J,L,N,Y,P,M,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,e,j);n={signature:a.substr(y,8),header_bytes:v(a,y+8),vertex_coordinate_bytes:v(a,y+9),normal_coordinate_bytes:v(a,y+10),uv_coordinate_bytes:v(a,y+11),vertex_index_bytes:v(a,y+12),normal_index_bytes:v(a,y+13),uv_index_bytes:v(a,y+14),material_index_bytes:v(a,y+15),nvertices:f(a,y+16),nnormals:f(a,y+16+4),nuvs:f(a,y+16+8),ntri_flat:f(a,y+16+12),ntri_smooth:f(a,y+16+16),ntri_flat_uv:f(a, +y+16+20),ntri_smooth_uv:f(a,y+16+24),nquad_flat:f(a,y+16+28),nquad_smooth:f(a,y+16+32),nquad_flat_uv:f(a,y+16+36),nquad_smooth_uv:f(a,y+16+40)};y+=n.header_bytes;h=n.vertex_index_bytes;z=n.vertex_index_bytes*2;l=n.vertex_index_bytes*3;o=n.vertex_index_bytes*3+n.material_index_bytes;B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;A=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;Q=n.vertex_index_bytes;K=n.vertex_index_bytes*2;R=n.vertex_index_bytes*3;T=n.vertex_index_bytes* +4;D=n.vertex_index_bytes*4+n.material_index_bytes;V=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;J=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;L=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;N=n.uv_index_bytes;Y=n.uv_index_bytes*2;P=n.uv_index_bytes;M=n.uv_index_bytes*2;W=n.uv_index_bytes*3;y+=function(q){var s,x,G,U=n.vertex_coordinate_bytes*3,ca=q+n.nvertices*U;for(q=q;q - + + + + + + + + @@ -133,12 +140,12 @@ objects = []; geometry = new Sphere( 100, 16, 8 ); - material = new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', THREE.ReflectionMapping ) } ); + material = new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ); for ( var i = 0; i < 10; i ++ ) { sphere = new THREE.Mesh( geometry, material ); - // sphere.overdraw = true; + sphere.overdraw = true; sphere.position.x = Math.random() * 1000 - 500; sphere.position.y = Math.random() * 1000 - 500; diff --git a/examples/geometry_earth.html b/examples/geometry_earth.html index a8f888de87..bd4ead8ff8 100644 --- a/examples/geometry_earth.html +++ b/examples/geometry_earth.html @@ -68,12 +68,12 @@ scene = new THREE.Scene(); - mesh = new THREE.Mesh( new Plane( 300, 300, 3, 3 ), new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/shadow.png', THREE.UVMapping ) } ) ); + mesh = new THREE.Mesh( new Plane( 300, 300, 3, 3 ), new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/shadow.png' ) } ) ); mesh.position.y = - 250; mesh.rotation.x = - 90 * Math.PI / 180; scene.addObject(mesh); - mesh = new THREE.Mesh( new Sphere( 200, 20, 20 ), new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg', THREE.UVMapping ) } ) ); + mesh = new THREE.Mesh( new Sphere( 200, 20, 20 ), new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ) ); mesh.overdraw = true; scene.addObject(mesh); diff --git a/examples/geometry_panorama.html b/examples/geometry_panorama.html index 065134bce5..bb70ef931a 100644 --- a/examples/geometry_panorama.html +++ b/examples/geometry_panorama.html @@ -98,7 +98,7 @@ function loadTexture( path ) { - var material = new THREE.MeshBasicMaterial( { map: new THREE.Texture( texture_placeholder, THREE.UVMapping ) } ); + var material = new THREE.MeshBasicMaterial( { map: new THREE.Texture( texture_placeholder ) } ); var image = new Image(); diff --git a/examples/geometry_panorama_fisheye.html b/examples/geometry_panorama_fisheye.html index 62074481b6..f30b9fc993 100644 --- a/examples/geometry_panorama_fisheye.html +++ b/examples/geometry_panorama_fisheye.html @@ -107,7 +107,7 @@ function loadTexture( path ) { - var material = new THREE.MeshBasicMaterial( { map: new THREE.Texture( texture_placeholder, THREE.UVMapping ) } ); + var material = new THREE.MeshBasicMaterial( { map: new THREE.Texture( texture_placeholder ) } ); var image = new Image(); diff --git a/examples/geometry_terrain.html b/examples/geometry_terrain.html index 4b2ad609f5..b263a7900d 100644 --- a/examples/geometry_terrain.html +++ b/examples/geometry_terrain.html @@ -69,7 +69,7 @@ var heightMap = height( 1024, 1024 ); - var texture = new THREE.Texture( shadow( heightMap ), THREE.UVMapping ); + var texture = new THREE.Texture( shadow( heightMap ) ); texture.loaded = true; var material = new THREE.MeshBasicMaterial( { map: texture } ); diff --git a/examples/materials.html b/examples/materials.html index 6792643d93..866be93284 100644 --- a/examples/materials.html +++ b/examples/materials.html @@ -78,9 +78,9 @@ // materials.push( { material: new THREE.MeshPhongMaterial( { ambient: 0x030383, color: 0xf55555, specular: 0x66f6f6, shininess: 10, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } ); materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } ); materials.push( { material: new THREE.MeshNormalMaterial(), overdraw: true, doubleSided: false } ); - materials.push( { material: new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg', THREE.UVMapping ) } ), overdraw: false, doubleSided: false } ); - materials.push( { material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg', THREE.UVMapping ) } ), overdraw: false, doubleSided: false } ); - materials.push( { material: new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', THREE.ReflectionMapping ) } ), overdraw: false, doubleSided: false } ); + materials.push( { material: new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false } ); + materials.push( { material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false } ); + materials.push( { material: new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ), overdraw: false, doubleSided: false } ); for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) { diff --git a/examples/materials_reflection.html b/examples/materials_reflection.html index 0f7c5a5cf4..030a5c990e 100644 --- a/examples/materials_reflection.html +++ b/examples/materials_reflection.html @@ -64,7 +64,7 @@ geometry = new WaltHead(); geometry.computeVertexNormals(); - mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/metal.jpg', THREE.ReflectionMapping ) } ) ); + mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ) } ) ); mesh.overdraw = true; scene.addObject( mesh ); diff --git a/examples/materials_video.html b/examples/materials_video.html index 37ab70a19b..3ead02e73d 100644 --- a/examples/materials_video.html +++ b/examples/materials_video.html @@ -81,7 +81,7 @@ textureContext.fillStyle = '#000000'; textureContext.fillRect( 0, 0, 480, 204 ); - var map = new THREE.Texture( texture, THREE.UVMapping ); + var map = new THREE.Texture( texture ); map.loaded = true; var material = new THREE.MeshBasicMaterial( { map: map } ); @@ -98,7 +98,7 @@ textureReflectionGradient.addColorStop( 0.2, 'rgba(240, 240, 240, 1)' ); textureReflectionGradient.addColorStop( 1, 'rgba(240, 240, 240, 0.8)' ); - var materialReflection = new THREE.MeshBasicMaterial( { map: new THREE.Texture( textureReflection, THREE.UVMapping ) } ); + var materialReflection = new THREE.MeshBasicMaterial( { map: new THREE.Texture( textureReflection ) } ); // diff --git a/src/materials/MeshShaderMaterial.js b/src/materials/MeshShaderMaterial.js index e551d8bbc1..a7190d3cc8 100644 --- a/src/materials/MeshShaderMaterial.js +++ b/src/materials/MeshShaderMaterial.js @@ -19,7 +19,7 @@ THREE.MeshShaderMaterial = function ( parameters ) { this.fragment_shader = "void main() {}"; this.vertex_shader = "void main() {}"; - this.uniforms = {}; + this.uniforms = {}; this.shading = THREE.SmoothShading; this.blending = THREE.NormalBlending; @@ -31,10 +31,10 @@ THREE.MeshShaderMaterial = function ( parameters ) { if ( parameters ) { - if ( parameters.fragment_shader !== undefined ) this.fragment_shader = parameters.fragment_shader; - if ( parameters.vertex_shader !== undefined ) this.vertex_shader = parameters.vertex_shader; + if ( parameters.fragment_shader !== undefined ) this.fragment_shader = parameters.fragment_shader; + if ( parameters.vertex_shader !== undefined ) this.vertex_shader = parameters.vertex_shader; - if ( parameters.uniforms !== undefined ) this.uniforms = parameters.uniforms; + if ( parameters.uniforms !== undefined ) this.uniforms = parameters.uniforms; if ( parameters.shading !== undefined ) this.shading = parameters.shading; if ( parameters.blending !== undefined ) this.blending = parameters.blending; @@ -50,7 +50,7 @@ THREE.MeshShaderMaterial = function ( parameters ) { return 'THREE.MeshShaderMaterial (
' + 'id: ' + this.id + '
' + - + 'blending: ' + this.blending + '
' + 'wireframe: ' + this.wireframe + '
' + 'wireframe_linewidth: ' + this.wireframe_linewidth +'
' + diff --git a/src/materials/textures/Texture.js b/src/materials/Texture.js similarity index 100% rename from src/materials/textures/Texture.js rename to src/materials/Texture.js diff --git a/src/materials/textures/TextureCube.js b/src/materials/textures/TextureCube.js deleted file mode 100644 index d0297492f0..0000000000 --- a/src/materials/textures/TextureCube.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @author mr.doob / http://mrdoob.com/ - * @author alteredq / http://alteredqualia.com/ - * } - */ - -THREE.TextureCube = function ( image, mapping ) { - - this.image = image; - this.mapping = mapping ? mapping : THREE.ReflectionMap; - - this.toString = function () { - - return 'THREE.TextureCube (
' + - 'image: ' + this.image + '
' + - 'mapping: ' + this.mapping + '
' + - ')'; - - }; - -}; diff --git a/src/renderers/CanvasRenderer.js b/src/renderers/CanvasRenderer.js index 2c3a776275..14f9e63403 100644 --- a/src/renderers/CanvasRenderer.js +++ b/src/renderers/CanvasRenderer.js @@ -231,81 +231,83 @@ THREE.CanvasRenderer = function () { _context.setTransform( 1, 0, 0, 1, 0, 0 ); - }; + // + + function calculateLights( scene ) { - function calculateLights( scene ) { + var l, ll, light, lightColor, + lights = scene.lights; - var l, ll, light, lightColor, - lights = scene.lights; + _ambientLight.setRGB( 0, 0, 0 ); + _directionalLights.setRGB( 0, 0, 0 ); + _pointLights.setRGB( 0, 0, 0 ); - _ambientLight.setRGB( 0, 0, 0 ); - _directionalLights.setRGB( 0, 0, 0 ); - _pointLights.setRGB( 0, 0, 0 ); + for ( l = 0, ll = lights.length; l < ll; l ++ ) { - for ( l = 0, ll = lights.length; l < ll; l ++ ) { + light = lights[ l ]; + lightColor = light.color; - light = lights[ l ]; - lightColor = light.color; + if ( light instanceof THREE.AmbientLight ) { - if ( light instanceof THREE.AmbientLight ) { + _ambientLight.r += lightColor.r; + _ambientLight.g += lightColor.g; + _ambientLight.b += lightColor.b; - _ambientLight.r += lightColor.r; - _ambientLight.g += lightColor.g; - _ambientLight.b += lightColor.b; + } else if ( light instanceof THREE.DirectionalLight ) { - } else if ( light instanceof THREE.DirectionalLight ) { + _directionalLights.r += lightColor.r; + _directionalLights.g += lightColor.g; + _directionalLights.b += lightColor.b; - _directionalLights.r += lightColor.r; - _directionalLights.g += lightColor.g; - _directionalLights.b += lightColor.b; + } else if ( light instanceof THREE.PointLight ) { - } else if ( light instanceof THREE.PointLight ) { + _pointLights.r += lightColor.r; + _pointLights.g += lightColor.g; + _pointLights.b += lightColor.b; - _pointLights.r += lightColor.r; - _pointLights.g += lightColor.g; - _pointLights.b += lightColor.b; + } } } - } + function calculateLight( scene, position, normal, color ) { - function calculateLight( scene, position, normal, color ) { + var l, ll, light, lightColor, lightIntensity, + amount, lights = scene.lights; - var l, ll, light, lightColor, lightIntensity, - amount, lights = scene.lights; + for ( l = 0, ll = lights.length; l < ll; l ++ ) { - for ( l = 0, ll = lights.length; l < ll; l ++ ) { + light = lights[ l ]; + lightColor = light.color; + lightIntensity = light.intensity; - light = lights[ l ]; - lightColor = light.color; - lightIntensity = light.intensity; + if ( light instanceof THREE.DirectionalLight ) { - if ( light instanceof THREE.DirectionalLight ) { + amount = normal.dot( light.position ) * lightIntensity; - amount = normal.dot( light.position ) * lightIntensity; + if ( amount > 0 ) { - if ( amount > 0 ) { + color.r += lightColor.r * amount; + color.g += lightColor.g * amount; + color.b += lightColor.b * amount; - color.r += lightColor.r * amount; - color.g += lightColor.g * amount; - color.b += lightColor.b * amount; + } - } + } else if ( light instanceof THREE.PointLight ) { - } else if ( light instanceof THREE.PointLight ) { + _vector3.sub( light.position, position ); + _vector3.normalize(); - _vector3.sub( light.position, position ); - _vector3.normalize(); + amount = normal.dot( _vector3 ) * lightIntensity; - amount = normal.dot( _vector3 ) * lightIntensity; + if ( amount > 0 ) { - if ( amount > 0 ) { + color.r += lightColor.r * amount; + color.g += lightColor.g * amount; + color.b += lightColor.b * amount; - color.r += lightColor.r * amount; - color.g += lightColor.g * amount; - color.b += lightColor.b * amount; + } } @@ -313,483 +315,486 @@ THREE.CanvasRenderer = function () { } - } + function renderParticle ( v1, element, material, scene ) { - function renderParticle ( v1, element, material, scene ) { + if ( material.opacity == 0 ) return; - if ( material.opacity == 0 ) return; + setOpacity( material.opacity ); + setBlending( material.blending ); - setOpacity( material.opacity ); - setBlending( material.blending ); + var width, height, scaleX, scaleY, + bitmap, bitmapWidth, bitmapHeight; - var width, height, scaleX, scaleY, - bitmap, bitmapWidth, bitmapHeight; + if ( material instanceof THREE.ParticleBasicMaterial ) { - if ( material instanceof THREE.ParticleBasicMaterial ) { + if ( material.map ) { - if ( material.map ) { + bitmap = material.map; + bitmapWidth = bitmap.width >> 1; + bitmapHeight = bitmap.height >> 1; - bitmap = material.map; - bitmapWidth = bitmap.width >> 1; - bitmapHeight = bitmap.height >> 1; + scaleX = element.scale.x * _canvasWidthHalf; + scaleY = element.scale.y * _canvasHeightHalf; - scaleX = element.scale.x * _canvasWidthHalf; - scaleY = element.scale.y * _canvasHeightHalf; + width = scaleX * bitmapWidth; + height = scaleY * bitmapHeight; - width = scaleX * bitmapWidth; - height = scaleY * bitmapHeight; + // TODO: Rotations break this... - // TODO: Rotations break this... + _bboxRect.set( v1.x - width, v1.y - height, v1.x + width, v1.y + height ); - _bboxRect.set( v1.x - width, v1.y - height, v1.x + width, v1.y + height ); + if ( !_clipRect.instersects( _bboxRect ) ) { - if ( !_clipRect.instersects( _bboxRect ) ) { + return; - return; + } - } + _context.save(); + _context.translate( v1.x, v1.y ); + _context.rotate( - element.rotation ); + _context.scale( scaleX, - scaleY ); + _context.translate( - bitmapWidth, - bitmapHeight ); - _context.save(); - _context.translate( v1.x, v1.y ); - _context.rotate( - element.rotation ); - _context.scale( scaleX, - scaleY ); - _context.translate( - bitmapWidth, - bitmapHeight ); + _context.drawImage( bitmap, 0, 0 ); - _context.drawImage( bitmap, 0, 0 ); + _context.restore(); - _context.restore(); + } - } + /* DEBUG + _context.beginPath(); + _context.moveTo( v1.x - 10, v1.y ); + _context.lineTo( v1.x + 10, v1.y ); + _context.moveTo( v1.x, v1.y - 10 ); + _context.lineTo( v1.x, v1.y + 10 ); + _context.closePath(); + _context.strokeStyle = 'rgb(255,255,0)'; + _context.stroke(); + */ - /* DEBUG - _context.beginPath(); - _context.moveTo( v1.x - 10, v1.y ); - _context.lineTo( v1.x + 10, v1.y ); - _context.moveTo( v1.x, v1.y - 10 ); - _context.lineTo( v1.x, v1.y + 10 ); - _context.closePath(); - _context.strokeStyle = 'rgb(255,255,0)'; - _context.stroke(); - */ + } else if ( material instanceof THREE.ParticleCircleMaterial ) { - } else if ( material instanceof THREE.ParticleCircleMaterial ) { + if ( _enableLighting ) { - if ( _enableLighting ) { + _light.r = _ambientLight.r + _directionalLights.r + _pointLights.r; + _light.g = _ambientLight.g + _directionalLights.g + _pointLights.g; + _light.b = _ambientLight.b + _directionalLights.b + _pointLights.b; - _light.r = _ambientLight.r + _directionalLights.r + _pointLights.r; - _light.g = _ambientLight.g + _directionalLights.g + _pointLights.g; - _light.b = _ambientLight.b + _directionalLights.b + _pointLights.b; + _color.r = material.color.r * _light.r; + _color.g = material.color.g * _light.g; + _color.b = material.color.b * _light.b; - _color.r = material.color.r * _light.r; - _color.g = material.color.g * _light.g; - _color.b = material.color.b * _light.b; + _color.updateStyleString(); - _color.updateStyleString(); + } else { - } else { + _color.__styleString = material.color.__styleString; - _color.__styleString = material.color.__styleString; + } - } + width = element.scale.x * _canvasWidthHalf; + height = element.scale.y * _canvasHeightHalf; - width = element.scale.x * _canvasWidthHalf; - height = element.scale.y * _canvasHeightHalf; + _bboxRect.set( v1.x - width, v1.y - height, v1.x + width, v1.y + height ); - _bboxRect.set( v1.x - width, v1.y - height, v1.x + width, v1.y + height ); + if ( !_clipRect.instersects( _bboxRect ) ) { - if ( !_clipRect.instersects( _bboxRect ) ) { + return; - return; + } - } + setFillStyle( _color.__styleString ); - setFillStyle( _color.__styleString ); + _context.save(); + _context.translate( v1.x, v1.y ); + _context.rotate( - element.rotation ); + _context.scale( width, height ); - _context.save(); - _context.translate( v1.x, v1.y ); - _context.rotate( - element.rotation ); - _context.scale( width, height ); + _context.beginPath(); + _context.arc( 0, 0, 1, 0, _pi2, true ); + _context.closePath(); - _context.beginPath(); - _context.arc( 0, 0, 1, 0, _pi2, true ); - _context.closePath(); + _context.fill(); + _context.restore(); - _context.fill(); - _context.restore(); + } } - } + function renderLine( v1, v2, element, material, scene ) { - function renderLine( v1, v2, element, material, scene ) { + if ( material.opacity == 0 ) return; - if ( material.opacity == 0 ) return; + setOpacity( material.opacity ); + setBlending( material.blending ); - setOpacity( material.opacity ); - setBlending( material.blending ); + _context.beginPath(); + _context.moveTo( v1.positionScreen.x, v1.positionScreen.y ); + _context.lineTo( v2.positionScreen.x, v2.positionScreen.y ); + _context.closePath(); - _context.beginPath(); - _context.moveTo( v1.positionScreen.x, v1.positionScreen.y ); - _context.lineTo( v2.positionScreen.x, v2.positionScreen.y ); - _context.closePath(); + if ( material instanceof THREE.LineBasicMaterial ) { - if ( material instanceof THREE.LineBasicMaterial ) { + _color.__styleString = material.color.__styleString; - _color.__styleString = material.color.__styleString; + setLineWidth( material.linewidth ); + setStrokeStyle( _color.__styleString ); - setLineWidth( material.linewidth ); - setStrokeStyle( _color.__styleString ); + _context.stroke(); + _bboxRect.inflate( material.linewidth * 2 ); - _context.stroke(); - _bboxRect.inflate( material.linewidth * 2 ); + } } - } + function renderFace3( v1, v2, v3, element, material, scene ) { - function renderFace3( v1, v2, v3, element, material, scene ) { + if ( material.opacity == 0 ) return; - if ( material.opacity == 0 ) return; + setOpacity( material.opacity ); + setBlending( material.blending ); - setOpacity( material.opacity ); - setBlending( material.blending ); + _v1x = v1.positionScreen.x; _v1y = v1.positionScreen.y; + _v2x = v2.positionScreen.x; _v2y = v2.positionScreen.y; + _v3x = v3.positionScreen.x; _v3y = v3.positionScreen.y; - _v1x = v1.positionScreen.x; _v1y = v1.positionScreen.y; - _v2x = v2.positionScreen.x; _v2y = v2.positionScreen.y; - _v3x = v3.positionScreen.x; _v3y = v3.positionScreen.y; + drawTriangle( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y ); - drawTriangle( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y ); + if ( material instanceof THREE.MeshBasicMaterial ) { - if ( material instanceof THREE.MeshBasicMaterial ) { + if ( material.map && !material.wireframe ) { - if ( material.map && material.map.loaded ) { + if ( material.map.mapping instanceof THREE.UVMapping ) { - texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.map.image, element.uvs[ 0 ].u, element.uvs[ 0 ].v, element.uvs[ 1 ].u, element.uvs[ 1 ].v, element.uvs[ 2 ].u, element.uvs[ 2 ].v ); + texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.map.image, element.uvs[ 0 ].u, element.uvs[ 0 ].v, element.uvs[ 1 ].u, element.uvs[ 1 ].v, element.uvs[ 2 ].u, element.uvs[ 2 ].v ); - /* - setBlending( THREE.SubtractiveBlending ); - fillPath( material.color.__styleString ); - */ + } - } else if ( material.env_map && material.env_map.loaded ) { + } else if ( material.env_map ) { - if ( material.env_map.mapping == THREE.ReflectionMapping ) { + if ( material.env_map.mapping instanceof THREE.SphericalReflectionMapping ) { - _vector3.copy( element.vertexNormalsWorld[ 0 ] ); - _uv1x = ( _vector3.x * camera.matrix.n11 + _vector3.y * camera.matrix.n12 + _vector3.z * camera.matrix.n13 ) * 0.5 + 0.5; - _uv1y = - ( _vector3.x * camera.matrix.n21 + _vector3.y * camera.matrix.n22 + _vector3.z * camera.matrix.n23 ) * 0.5 + 0.5; + _vector3.copy( element.vertexNormalsWorld[ 0 ] ); + _uv1x = ( _vector3.x * camera.matrix.n11 + _vector3.y * camera.matrix.n12 + _vector3.z * camera.matrix.n13 ) * 0.5 + 0.5; + _uv1y = - ( _vector3.x * camera.matrix.n21 + _vector3.y * camera.matrix.n22 + _vector3.z * camera.matrix.n23 ) * 0.5 + 0.5; - _vector3.copy( element.vertexNormalsWorld[ 1 ] ); - _uv2x = ( _vector3.x * camera.matrix.n11 + _vector3.y * camera.matrix.n12 + _vector3.z * camera.matrix.n13 ) * 0.5 + 0.5; - _uv2y = - ( _vector3.x * camera.matrix.n21 + _vector3.y * camera.matrix.n22 + _vector3.z * camera.matrix.n23 ) * 0.5 + 0.5; + _vector3.copy( element.vertexNormalsWorld[ 1 ] ); + _uv2x = ( _vector3.x * camera.matrix.n11 + _vector3.y * camera.matrix.n12 + _vector3.z * camera.matrix.n13 ) * 0.5 + 0.5; + _uv2y = - ( _vector3.x * camera.matrix.n21 + _vector3.y * camera.matrix.n22 + _vector3.z * camera.matrix.n23 ) * 0.5 + 0.5; - _vector3.copy( element.vertexNormalsWorld[ 2 ] ); - _uv3x = ( _vector3.x * camera.matrix.n11 + _vector3.y * camera.matrix.n12 + _vector3.z * camera.matrix.n13 ) * 0.5 + 0.5; - _uv3y = - ( _vector3.x * camera.matrix.n21 + _vector3.y * camera.matrix.n22 + _vector3.z * camera.matrix.n23 ) * 0.5 + 0.5; + _vector3.copy( element.vertexNormalsWorld[ 2 ] ); + _uv3x = ( _vector3.x * camera.matrix.n11 + _vector3.y * camera.matrix.n12 + _vector3.z * camera.matrix.n13 ) * 0.5 + 0.5; + _uv3y = - ( _vector3.x * camera.matrix.n21 + _vector3.y * camera.matrix.n22 + _vector3.z * camera.matrix.n23 ) * 0.5 + 0.5; - texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.env_map.image, _uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y ); + texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.env_map.image, _uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y ); - }/* else if ( material.env_map.mapping == THREE.RefractionMapping ) { + }/* else if ( material.env_map.mapping == THREE.RefractionMapping ) { - + - }*/ + }*/ - } else { + } else { - material.wireframe ? strokePath( material.color.__styleString, material.wireframe_linewidth ) : fillPath( material.color.__styleString ); + material.wireframe ? strokePath( material.color.__styleString, material.wireframe_linewidth ) : fillPath( material.color.__styleString ); - } + } - } else if ( material instanceof THREE.MeshLambertMaterial ) { + } else if ( material instanceof THREE.MeshLambertMaterial ) { - if ( material.map && !material.wireframe ) { + if ( material.map && !material.wireframe ) { - texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.map.image, element.uvs[ 0 ].u, element.uvs[ 0 ].v, element.uvs[ 1 ].u, element.uvs[ 1 ].v, element.uvs[ 2 ].u, element.uvs[ 2 ].v ); + if ( material.map.mapping instanceof THREE.UVMapping ) { - setBlending( THREE.SubtractiveBlending ); + texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, material.map.image, element.uvs[ 0 ].u, element.uvs[ 0 ].v, element.uvs[ 1 ].u, element.uvs[ 1 ].v, element.uvs[ 2 ].u, element.uvs[ 2 ].v ); - } + } - if ( _enableLighting ) { + setBlending( THREE.SubtractiveBlending ); - if ( !material.wireframe && material.shading == THREE.SmoothShading && element.vertexNormalsWorld.length == 3 ) { + } - _color1.r = _color2.r = _color3.r = _ambientLight.r; - _color1.g = _color2.g = _color3.g = _ambientLight.g; - _color1.b = _color2.b = _color3.b = _ambientLight.b; + if ( _enableLighting ) { - calculateLight( scene, element.v1.positionWorld, element.vertexNormalsWorld[ 0 ], _color1 ); - calculateLight( scene, element.v2.positionWorld, element.vertexNormalsWorld[ 1 ], _color2 ); - calculateLight( scene, element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color3 ); + if ( !material.wireframe && material.shading == THREE.SmoothShading && element.vertexNormalsWorld.length == 3 ) { - _color4.r = ( _color2.r + _color3.r ) * 0.5; - _color4.g = ( _color2.g + _color3.g ) * 0.5; - _color4.b = ( _color2.b + _color3.b ) * 0.5; + _color1.r = _color2.r = _color3.r = _ambientLight.r; + _color1.g = _color2.g = _color3.g = _ambientLight.g; + _color1.b = _color2.b = _color3.b = _ambientLight.b; - _bitmap = getGradientTexture( _color1, _color2, _color3, _color4 ); + calculateLight( scene, element.v1.positionWorld, element.vertexNormalsWorld[ 0 ], _color1 ); + calculateLight( scene, element.v2.positionWorld, element.vertexNormalsWorld[ 1 ], _color2 ); + calculateLight( scene, element.v3.positionWorld, element.vertexNormalsWorld[ 2 ], _color3 ); - texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _bitmap, 0, 0, 1, 0, 0, 1 ); + _color4.r = ( _color2.r + _color3.r ) * 0.5; + _color4.g = ( _color2.g + _color3.g ) * 0.5; + _color4.b = ( _color2.b + _color3.b ) * 0.5; - } else { + _bitmap = getGradientTexture( _color1, _color2, _color3, _color4 ); - _light.r = _ambientLight.r; - _light.g = _ambientLight.g; - _light.b = _ambientLight.b; + texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _bitmap, 0, 0, 1, 0, 0, 1 ); - calculateLight( scene, element.centroidWorld, element.normalWorld, _light ); + } else { - _color.r = material.color.r * _light.r; - _color.g = material.color.g * _light.g; - _color.b = material.color.b * _light.b; + _light.r = _ambientLight.r; + _light.g = _ambientLight.g; + _light.b = _ambientLight.b; - _color.updateStyleString(); - material.wireframe ? strokePath( _color.__styleString, material.wireframe_linewidth ) : fillPath( _color.__styleString ); + calculateLight( scene, element.centroidWorld, element.normalWorld, _light ); - } + _color.r = material.color.r * _light.r; + _color.g = material.color.g * _light.g; + _color.b = material.color.b * _light.b; - } else { + _color.updateStyleString(); + material.wireframe ? strokePath( _color.__styleString, material.wireframe_linewidth ) : fillPath( _color.__styleString ); - material.wireframe ? strokePath( material.color.__styleString, material.wireframe_linewidth ) : fillPath( material.color.__styleString ); + } - } + } else { - } else if ( material instanceof THREE.MeshDepthMaterial ) { + material.wireframe ? strokePath( material.color.__styleString, material.wireframe_linewidth ) : fillPath( material.color.__styleString ); - /* - _w = 1 - ( material.__2near / (material.__farPlusNear - element.z * material.__farMinusNear ) ); - _color.setRGB( _w, _w, _w ); - */ + } + + } else if ( material instanceof THREE.MeshDepthMaterial ) { - _2near = material.__2near; - _farPlusNear = material.__farPlusNear; - _farMinusNear = material.__farMinusNear; + /* + _w = 1 - ( material.__2near / (material.__farPlusNear - element.z * material.__farMinusNear ) ); + _color.setRGB( _w, _w, _w ); + */ + + _2near = material.__2near; + _farPlusNear = material.__farPlusNear; + _farMinusNear = material.__farMinusNear; - _color1.r = _color1.g = _color1.b = 1 - ( _2near / ( _farPlusNear - v1.positionScreen.z * _farMinusNear ) ); - _color2.r = _color2.g = _color2.b = 1 - ( _2near / ( _farPlusNear - v2.positionScreen.z * _farMinusNear ) ); - _color3.r = _color3.g = _color3.b = 1 - ( _2near / ( _farPlusNear - v3.positionScreen.z * _farMinusNear ) ); + _color1.r = _color1.g = _color1.b = 1 - ( _2near / ( _farPlusNear - v1.positionScreen.z * _farMinusNear ) ); + _color2.r = _color2.g = _color2.b = 1 - ( _2near / ( _farPlusNear - v2.positionScreen.z * _farMinusNear ) ); + _color3.r = _color3.g = _color3.b = 1 - ( _2near / ( _farPlusNear - v3.positionScreen.z * _farMinusNear ) ); - _color4.r = ( _color2.r + _color3.r ) * 0.5; - _color4.g = ( _color2.g + _color3.g ) * 0.5; - _color4.b = ( _color2.b + _color3.b ) * 0.5; + _color4.r = ( _color2.r + _color3.r ) * 0.5; + _color4.g = ( _color2.g + _color3.g ) * 0.5; + _color4.b = ( _color2.b + _color3.b ) * 0.5; - _bitmap = getGradientTexture( _color1, _color2, _color3, _color4 ); + _bitmap = getGradientTexture( _color1, _color2, _color3, _color4 ); - texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _bitmap, 0, 0, 1, 0, 0, 1 ); + texturePath( _v1x, _v1y, _v2x, _v2y, _v3x, _v3y, _bitmap, 0, 0, 1, 0, 0, 1 ); - } else if ( material instanceof THREE.MeshNormalMaterial ) { + } else if ( material instanceof THREE.MeshNormalMaterial ) { - _color.r = normalToComponent( element.normalWorld.x ); - _color.g = normalToComponent( element.normalWorld.y ); - _color.b = normalToComponent( element.normalWorld.z ); - _color.updateStyleString(); + _color.r = normalToComponent( element.normalWorld.x ); + _color.g = normalToComponent( element.normalWorld.y ); + _color.b = normalToComponent( element.normalWorld.z ); + _color.updateStyleString(); + + material.wireframe ? strokePath( _color.__styleString, material.wireframe_linewidth ) : fillPath( _color.__styleString ); - material.wireframe ? strokePath( _color.__styleString, material.wireframe_linewidth ) : fillPath( _color.__styleString ); + } } - } + function drawTriangle( x0, y0, x1, y1, x2, y2 ) { - function drawTriangle( x0, y0, x1, y1, x2, y2 ) { + _context.beginPath(); + _context.moveTo( x0, y0 ); + _context.lineTo( x1, y1 ); + _context.lineTo( x2, y2 ); + _context.lineTo( x0, y0 ); + _context.closePath(); - _context.beginPath(); - _context.moveTo( x0, y0 ); - _context.lineTo( x1, y1 ); - _context.lineTo( x2, y2 ); - _context.lineTo( x0, y0 ); - _context.closePath(); + } - } + /* + function drawQuad( x0, y0, x1, y1, x2, y2, x3, y3 ) { - /* - function drawQuad( x0, y0, x1, y1, x2, y2, x3, y3 ) { + _context.beginPath(); + _context.moveTo( x0, y0 ); + _context.lineTo( x1, y1 ); + _context.lineTo( x2, y2 ); + _context.lineTo( x3, y3 ); + _context.lineTo( x0, y0 ); + _context.closePath(); - _context.beginPath(); - _context.moveTo( x0, y0 ); - _context.lineTo( x1, y1 ); - _context.lineTo( x2, y2 ); - _context.lineTo( x3, y3 ); - _context.lineTo( x0, y0 ); - _context.closePath(); + } + */ - } - */ + function strokePath( color, linewidth ) { - function strokePath( color, linewidth ) { + setStrokeStyle( color ); + setLineWidth( linewidth ); - setStrokeStyle( color ); - setLineWidth( linewidth ); + _context.stroke(); - _context.stroke(); + _bboxRect.inflate( linewidth * 2 ); - _bboxRect.inflate( linewidth * 2 ); + } - } + function fillPath( color ) { - function fillPath( color ) { + setFillStyle( color ); + _context.fill(); - setFillStyle( color ); - _context.fill(); + } - } + function texturePath( x0, y0, x1, y1, x2, y2, bitmap, u0, v0, u1, v1, u2, v2 ) { - function texturePath( x0, y0, x1, y1, x2, y2, bitmap, u0, v0, u1, v1, u2, v2 ) { + // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120 - // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120 + var a, b, c, d, e, f, det, + width = bitmap.width - 1, + height = bitmap.height - 1; - var a, b, c, d, e, f, det, - width = bitmap.width - 1, - height = bitmap.height - 1; + u0 *= width; v0 *= height; + u1 *= width; v1 *= height; + u2 *= width; v2 *= height; - u0 *= width; v0 *= height; - u1 *= width; v1 *= height; - u2 *= width; v2 *= height; + x1 -= x0; y1 -= y0; + x2 -= x0; y2 -= y0; - x1 -= x0; y1 -= y0; - x2 -= x0; y2 -= y0; + u1 -= u0; v1 -= v0; + u2 -= u0; v2 -= v0; - u1 -= u0; v1 -= v0; - u2 -= u0; v2 -= v0; + det = 1 / ( u1 * v2 - u2 * v1 ), - det = 1 / ( u1 * v2 - u2 * v1 ), + a = ( v2 * x1 - v1 * x2 ) * det, + b = ( v2 * y1 - v1 * y2 ) * det, + c = ( u1 * x2 - u2 * x1 ) * det, + d = ( u1 * y2 - u2 * y1 ) * det, - a = ( v2 * x1 - v1 * x2 ) * det, - b = ( v2 * y1 - v1 * y2 ) * det, - c = ( u1 * x2 - u2 * x1 ) * det, - d = ( u1 * y2 - u2 * y1 ) * det, + e = x0 - a * u0 - c * v0, + f = y0 - b * u0 - d * v0; - e = x0 - a * u0 - c * v0, - f = y0 - b * u0 - d * v0; + _context.save(); + _context.transform( a, b, c, d, e, f ); + _context.clip(); + _context.drawImage( bitmap, 0, 0 ); + _context.restore(); - _context.save(); - _context.transform( a, b, c, d, e, f ); - _context.clip(); - _context.drawImage( bitmap, 0, 0 ); - _context.restore(); + } - } + // - // + function setOpacity( value ) { - function setOpacity( value ) { + if ( _contextGlobalAlpha != value ) { - if ( _contextGlobalAlpha != value ) { + _context.globalAlpha = _contextGlobalAlpha = value; - _context.globalAlpha = _contextGlobalAlpha = value; + } } - } + function setBlending( value ) { + + if ( _contextGlobalCompositeOperation != value ) { - function setBlending( value ) { + switch ( value ) { - if ( _contextGlobalCompositeOperation != value ) { + case THREE.NormalBlending: - switch ( value ) { + _context.globalCompositeOperation = 'source-over'; - case THREE.NormalBlending: + break; - _context.globalCompositeOperation = 'source-over'; + case THREE.AdditiveBlending: - break; + _context.globalCompositeOperation = 'lighter'; - case THREE.AdditiveBlending: + break; - _context.globalCompositeOperation = 'lighter'; + case THREE.SubtractiveBlending: - break; + _context.globalCompositeOperation = 'darker'; - case THREE.SubtractiveBlending: + break; - _context.globalCompositeOperation = 'darker'; + } - break; + _contextGlobalCompositeOperation = value; } - _contextGlobalCompositeOperation = value; - } - } + function setLineWidth( value ) { - function setLineWidth( value ) { + if ( _contextLineWidth != value ) { - if ( _contextLineWidth != value ) { + _context.lineWidth = _contextLineWidth = value; - _context.lineWidth = _contextLineWidth = value; + } } - } + function setStrokeStyle( value ) { - function setStrokeStyle( value ) { + if ( _contextStrokeStyle != value ) { - if ( _contextStrokeStyle != value ) { + _context.strokeStyle = _contextStrokeStyle = value; - _context.strokeStyle = _contextStrokeStyle = value; + } } - } + function setFillStyle( value ) { - function setFillStyle( value ) { + if ( _contextFillStyle != value ) { - if ( _contextFillStyle != value ) { + _context.fillStyle = _contextFillStyle = value; - _context.fillStyle = _contextFillStyle = value; + } } - } + function getGradientTexture( color1, color2, color3, color4 ) { - function getGradientTexture( color1, color2, color3, color4 ) { + // http://mrdoob.com/blog/post/710 - // http://mrdoob.com/blog/post/710 + _pixelMapData[ 0 ] = _max( 0, _min( 255, ~~ ( color1.r * 255 ) ) ); + _pixelMapData[ 1 ] = _max( 0, _min( 255, ~~ ( color1.g * 255 ) ) ); + _pixelMapData[ 2 ] = _max( 0, _min( 255, ~~ ( color1.b * 255 ) ) ); - _pixelMapData[ 0 ] = _max( 0, _min( 255, ~~ ( color1.r * 255 ) ) ); - _pixelMapData[ 1 ] = _max( 0, _min( 255, ~~ ( color1.g * 255 ) ) ); - _pixelMapData[ 2 ] = _max( 0, _min( 255, ~~ ( color1.b * 255 ) ) ); + _pixelMapData[ 4 ] = _max( 0, _min( 255, ~~ ( color2.r * 255 ) ) ); + _pixelMapData[ 5 ] = _max( 0, _min( 255, ~~ ( color2.g * 255 ) ) ); + _pixelMapData[ 6 ] = _max( 0, _min( 255, ~~ ( color2.b * 255 ) ) ); - _pixelMapData[ 4 ] = _max( 0, _min( 255, ~~ ( color2.r * 255 ) ) ); - _pixelMapData[ 5 ] = _max( 0, _min( 255, ~~ ( color2.g * 255 ) ) ); - _pixelMapData[ 6 ] = _max( 0, _min( 255, ~~ ( color2.b * 255 ) ) ); + _pixelMapData[ 8 ] = _max( 0, _min( 255, ~~ ( color3.r * 255 ) ) ); + _pixelMapData[ 9 ] = _max( 0, _min( 255, ~~ ( color3.g * 255 ) ) ); + _pixelMapData[ 10 ] = _max( 0, _min( 255, ~~ ( color3.b * 255 ) ) ); - _pixelMapData[ 8 ] = _max( 0, _min( 255, ~~ ( color3.r * 255 ) ) ); - _pixelMapData[ 9 ] = _max( 0, _min( 255, ~~ ( color3.g * 255 ) ) ); - _pixelMapData[ 10 ] = _max( 0, _min( 255, ~~ ( color3.b * 255 ) ) ); + _pixelMapData[ 12 ] = _max( 0, _min( 255, ~~ ( color4.r * 255 ) ) ); + _pixelMapData[ 13 ] = _max( 0, _min( 255, ~~ ( color4.g * 255 ) ) ); + _pixelMapData[ 14 ] = _max( 0, _min( 255, ~~ ( color4.b * 255 ) ) ); - _pixelMapData[ 12 ] = _max( 0, _min( 255, ~~ ( color4.r * 255 ) ) ); - _pixelMapData[ 13 ] = _max( 0, _min( 255, ~~ ( color4.g * 255 ) ) ); - _pixelMapData[ 14 ] = _max( 0, _min( 255, ~~ ( color4.b * 255 ) ) ); + _pixelMapContext.putImageData( _pixelMapImage, 0, 0 ); + _gradientMapContext.drawImage( _pixelMap, 0, 0 ); - _pixelMapContext.putImageData( _pixelMapImage, 0, 0 ); - _gradientMapContext.drawImage( _pixelMap, 0, 0 ); + return _gradientMap; - return _gradientMap; + } - } + function normalToComponent( normal ) { - function normalToComponent( normal ) { + // https://gist.github.com/665829 - // https://gist.github.com/665829 + return normal < 0 ? _min( ( 1 + normal ) * 0.5, 0.5 ) : 0.5 + _min( normal * 0.5, 0.5 ); - return normal < 0 ? _min( ( 1 + normal ) * 0.5, 0.5 ) : 0.5 + _min( normal * 0.5, 0.5 ); + } - } + // Hide anti-alias gaps - // Hide anti-alias gaps + function expand( v1, v2 ) { - function expand( v1, v2 ) { + var x = v2.x - v1.x, y = v2.y - v1.y, + unit = 1 / Math.sqrt( x * x + y * y ); - var x = v2.x - v1.x, y = v2.y - v1.y, - unit = 1 / Math.sqrt( x * x + y * y ); + x *= unit; y *= unit; - x *= unit; y *= unit; + v2.x += x; v2.y += y; + v1.x -= x; v1.y -= y; - v2.x += x; v2.y += y; - v1.x -= x; v1.y -= y; + } - } + }; }; diff --git a/utils/build.py b/utils/build.py index 47c464ae87..8b0fb776a4 100644 --- a/utils/build.py +++ b/utils/build.py @@ -122,8 +122,14 @@ def buildCommon(debug): 'materials/ParticleBasicMaterial.js', 'materials/ParticleCircleMaterial.js', 'materials/ParticleDOMMaterial.js', - 'materials/textures/Texture.js', - 'materials/textures/TextureCube.js', + 'materials/Texture.js', + 'materials/mappings/CubeReflectionMapping.js', + 'materials/mappings/CubeRefractionMapping.js', + 'materials/mappings/LatitudeReflectionMapping.js', + 'materials/mappings/LatitudeRefractionMapping.js', + 'materials/mappings/SphericalReflectionMapping.js', + 'materials/mappings/SphericalRefractionMapping.js', + 'materials/mappings/UVMapping.js', 'scenes/Scene.js', 'renderers/Projector.js', 'renderers/DOMRenderer.js', @@ -175,8 +181,14 @@ def buildExtras(debug): 'materials/ParticleBasicMaterial.js', 'materials/ParticleCircleMaterial.js', 'materials/ParticleDOMMaterial.js', - 'materials/textures/Texture.js', - 'materials/textures/TextureCube.js', + 'materials/Texture.js', + 'materials/mappings/CubeReflectionMapping.js', + 'materials/mappings/CubeRefractionMapping.js', + 'materials/mappings/LatitudeReflectionMapping.js', + 'materials/mappings/LatitudeRefractionMapping.js', + 'materials/mappings/SphericalReflectionMapping.js', + 'materials/mappings/SphericalRefractionMapping.js', + 'materials/mappings/UVMapping.js', 'scenes/Scene.js', 'renderers/Projector.js', 'renderers/DOMRenderer.js', @@ -235,7 +247,14 @@ def buildCanvas(debug): 'materials/MeshFaceMaterial.js', 'materials/ParticleBasicMaterial.js', 'materials/ParticleCircleMaterial.js', - 'materials/textures/Texture.js', + 'materials/Texture.js', + 'materials/mappings/CubeReflectionMapping.js', + 'materials/mappings/CubeRefractionMapping.js', + 'materials/mappings/LatitudeReflectionMapping.js', + 'materials/mappings/LatitudeRefractionMapping.js', + 'materials/mappings/SphericalReflectionMapping.js', + 'materials/mappings/SphericalRefractionMapping.js', + 'materials/mappings/UVMapping.js', 'scenes/Scene.js', 'renderers/Projector.js', 'renderers/CanvasRenderer.js', @@ -285,8 +304,14 @@ def buildWebGL(debug): 'materials/MeshShaderMaterial.js', 'materials/ParticleBasicMaterial.js', 'materials/ParticleCircleMaterial.js', - 'materials/textures/Texture.js', - 'materials/textures/TextureCube.js', + 'materials/Texture.js', + 'materials/mappings/CubeReflectionMapping.js', + 'materials/mappings/CubeRefractionMapping.js', + 'materials/mappings/LatitudeReflectionMapping.js', + 'materials/mappings/LatitudeRefractionMapping.js', + 'materials/mappings/SphericalReflectionMapping.js', + 'materials/mappings/SphericalRefractionMapping.js', + 'materials/mappings/UVMapping.js', 'scenes/Scene.js', 'renderers/WebGLRenderer.js', ] -- GitLab