|
@@ -1,60 +1,60 @@
|
|
|
// ThreeExtras.js r30 - http://github.com/mrdoob/three.js
|
|
|
var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
|
|
|
-THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
|
|
|
-","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
|
|
|
-THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
|
|
|
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
|
|
|
-THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
|
|
|
-cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=
|
|
|
-this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,
|
|
|
-0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
|
|
|
-THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
|
|
|
-return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
|
|
|
-THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
|
|
|
-THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,g=[];a=0;for(c=f.length;a<c;a++){d=f[a];if(d instanceof THREE.Mesh)g=g.concat(this.intersectObject(d))}g.sort(function(i,k){return i.distance-k.distance});return g},intersectObject:function(a){function c(I,t,h,e){e=e.clone().subSelf(t);h=h.clone().subSelf(t);var l=I.clone().subSelf(t);I=e.dot(e);t=e.dot(h);e=e.dot(l);var r=h.dot(h);h=h.dot(l);l=1/(I*r-t*t);r=(r*e-t*h)*l;I=(I*h-t*e)*l;return r>0&&I>0&&r+I<1}var d,f,g,i,k,b,j,x,s,D,
|
|
|
-o,v=a.geometry,u=v.vertices,y=[];d=0;for(f=v.faces.length;d<f;d++){g=v.faces[d];D=this.origin.clone();o=this.direction.clone();i=a.matrix.transformVector3(u[g.a].position.clone());k=a.matrix.transformVector3(u[g.b].position.clone());b=a.matrix.transformVector3(u[g.c].position.clone());j=g instanceof THREE.Face4?a.matrix.transformVector3(u[g.d].position.clone()):null;x=a.rotationMatrix.transformVector3(g.normal.clone());s=o.dot(x);if(s<0){x=x.dot((new THREE.Vector3).sub(i,D))/s;D=D.addSelf(o.multiplyScalar(x));
|
|
|
-if(g instanceof THREE.Face3){if(c(D,i,k,b)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};y.push(g)}}else if(g instanceof THREE.Face4)if(c(D,i,k,j)||c(D,k,b,j)){g={distance:this.origin.distanceTo(D),point:D,face:g,object:a};y.push(g)}}}return y}};
|
|
|
-THREE.Rectangle=function(){function a(){i=f-c;k=g-d}var c,d,f,g,i,k,b=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return i};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(j,x,s,D){b=false;c=j;d=x;f=s;g=D;a()};this.addPoint=function(j,x){if(b){b=false;c=j;d=x;f=j;g=x}else{c=Math.min(c,j);d=Math.min(d,x);f=Math.max(f,
|
|
|
-j);g=Math.max(g,x)}a()};this.addRectangle=function(j){if(b){b=false;c=j.getLeft();d=j.getTop();f=j.getRight();g=j.getBottom()}else{c=Math.min(c,j.getLeft());d=Math.min(d,j.getTop());f=Math.max(f,j.getRight());g=Math.max(g,j.getBottom())}a()};this.inflate=function(j){c-=j;d-=j;f+=j;g+=j;a()};this.minSelf=function(j){c=Math.max(c,j.getLeft());d=Math.max(d,j.getTop());f=Math.min(f,j.getRight());g=Math.min(g,j.getBottom());a()};this.instersects=function(j){return Math.min(f,j.getRight())-Math.max(c,j.getLeft())>=
|
|
|
-0&&Math.min(g,j.getBottom())-Math.max(d,j.getTop())>=0};this.empty=function(){b=true;g=f=d=c=0;a()};this.isEmpty=function(){return b};this.toString=function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+g+", width: "+i+", 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.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+
|
|
|
+","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
|
|
|
+THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
|
|
|
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,d){this.x=a||0;this.y=b||0;this.z=d||0};
|
|
|
+THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
|
|
|
+cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=
|
|
|
+this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,
|
|
|
+0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};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;a<b;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(j,k){return j.distance-k.distance});return f},intersectObject:function(a){function b(L,u,A,l){l=l.clone().subSelf(u);A=A.clone().subSelf(u);var h=L.clone().subSelf(u);L=l.dot(l);u=l.dot(A);l=l.dot(h);var i=A.dot(A);A=A.dot(h);h=1/(L*i-u*u);i=(i*l-u*A)*h;L=(L*A-u*l)*h;return i>0&&L>0&&i+L<1}var d,e,f,j,k,g,m,c,s,E,
|
|
|
+r,w=a.geometry,v=w.vertices,x=[];d=0;for(e=w.faces.length;d<e;d++){f=w.faces[d];E=this.origin.clone();r=this.direction.clone();j=a.matrix.transformVector3(v[f.a].position.clone());k=a.matrix.transformVector3(v[f.b].position.clone());g=a.matrix.transformVector3(v[f.c].position.clone());m=f instanceof THREE.Face4?a.matrix.transformVector3(v[f.d].position.clone()):null;c=a.rotationMatrix.transformVector3(f.normal.clone());s=r.dot(c);if(s<0){c=c.dot((new THREE.Vector3).sub(j,E))/s;E=E.addSelf(r.multiplyScalar(c));
|
|
|
+if(f instanceof THREE.Face3){if(b(E,j,k,g)){f={distance:this.origin.distanceTo(E),point:E,face:f,object:a};x.push(f)}}else if(f instanceof THREE.Face4)if(b(E,j,k,m)||b(E,k,g,m)){f={distance:this.origin.distanceTo(E),point:E,face:f,object:a};x.push(f)}}}return x}};
|
|
|
+THREE.Rectangle=function(){function a(){j=e-b;k=f-d}var b,d,e,f,j,k,g=true;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(m,c,s,E){g=false;b=m;d=c;e=s;f=E;a()};this.addPoint=function(m,c){if(g){g=false;b=m;d=c;e=m;f=c}else{b=Math.min(b,m);d=Math.min(d,c);e=Math.max(e,
|
|
|
+m);f=Math.max(f,c)}a()};this.addRectangle=function(m){if(g){g=false;b=m.getLeft();d=m.getTop();e=m.getRight();f=m.getBottom()}else{b=Math.min(b,m.getLeft());d=Math.min(d,m.getTop());e=Math.max(e,m.getRight());f=Math.max(f,m.getBottom())}a()};this.inflate=function(m){b-=m;d-=m;e+=m;f+=m;a()};this.minSelf=function(m){b=Math.max(b,m.getLeft());d=Math.max(d,m.getTop());e=Math.min(e,m.getRight());f=Math.min(f,m.getBottom());a()};this.instersects=function(m){return Math.min(e,m.getRight())-Math.max(b,m.getLeft())>=
|
|
|
+0&&Math.min(f,m.getBottom())-Math.max(d,m.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.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,c,d){var f=new THREE.Vector3,g=new THREE.Vector3,i=new THREE.Vector3;i.sub(a,c).normalize();f.cross(d,i).normalize();g.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=i.x;this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},transformVector3:function(a){var c=a.x,d=a.y,f=a.z;a.x=this.n11*c+this.n12*
|
|
|
-d+this.n13*f+this.n14;a.y=this.n21*c+this.n22*d+this.n23*f+this.n24;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34;a.multiplyScalar(1/(this.n41*c+this.n42*d+this.n43*f+this.n44));return a},transformVector4:function(a){var c=a.x,d=a.y,f=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*f+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*g;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*
|
|
|
-a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,g=a.n13,i=a.n14,k=a.n21,b=a.n22,j=a.n23,x=a.n24,s=a.n31,D=a.n32,o=a.n33,v=a.n34,u=a.n41,y=a.n42,I=a.n43,t=a.n44,h=c.n11,e=c.n12,l=c.n13,r=c.n14,n=c.n21,p=c.n22,w=c.n23,C=c.n24,L=c.n31,B=c.n32,U=c.n33,F=c.n34,E=c.n41,V=c.n42,T=c.n43,
|
|
|
-J=c.n44;this.n11=d*h+f*n+g*L+i*E;this.n12=d*e+f*p+g*B+i*V;this.n13=d*l+f*w+g*U+i*T;this.n14=d*r+f*C+g*F+i*J;this.n21=k*h+b*n+j*L+x*E;this.n22=k*e+b*p+j*B+x*V;this.n23=k*l+b*w+j*U+x*T;this.n24=k*r+b*C+j*F+x*J;this.n31=s*h+D*n+o*L+v*E;this.n32=s*e+D*p+o*B+v*V;this.n33=s*l+D*w+o*U+v*T;this.n34=s*r+D*C+o*F+v*J;this.n41=u*h+y*n+I*L+t*E;this.n42=u*e+y*p+I*B+t*V;this.n43=u*l+y*w+I*U+t*T;this.n44=u*r+y*C+I*F+t*J},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,g=this.n14,i=this.n21,k=this.n22,
|
|
|
-b=this.n23,j=this.n24,x=this.n31,s=this.n32,D=this.n33,o=this.n34,v=this.n41,u=this.n42,y=this.n43,I=this.n44;this.n11=c*a.n11+d*a.n21+f*a.n31+g*a.n41;this.n12=c*a.n12+d*a.n22+f*a.n32+g*a.n42;this.n13=c*a.n13+d*a.n23+f*a.n33+g*a.n43;this.n14=c*a.n14+d*a.n24+f*a.n34+g*a.n44;this.n21=i*a.n11+k*a.n21+b*a.n31+j*a.n41;this.n22=i*a.n12+k*a.n22+b*a.n32+j*a.n42;this.n23=i*a.n13+k*a.n23+b*a.n33+j*a.n43;this.n24=i*a.n14+k*a.n24+b*a.n34+j*a.n44;this.n31=x*a.n11+s*a.n21+D*a.n31+o*a.n41;this.n32=x*a.n12+s*a.n22+
|
|
|
-D*a.n32+o*a.n42;this.n33=x*a.n13+s*a.n23+D*a.n33+o*a.n43;this.n34=x*a.n14+s*a.n24+D*a.n34+o*a.n44;this.n41=v*a.n11+u*a.n21+y*a.n31+I*a.n41;this.n42=v*a.n12+u*a.n22+y*a.n32+I*a.n42;this.n43=v*a.n13+u*a.n23+y*a.n33+I*a.n43;this.n44=v*a.n14+u*a.n24+y*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*
|
|
|
+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},transformVector3:function(a){var b=a.x,d=a.y,e=a.z;a.x=this.n11*b+this.n12*
|
|
|
+d+this.n13*e+this.n14;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34;a.multiplyScalar(1/(this.n41*b+this.n42*d+this.n43*e+this.n44));return a},transformVector4: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,m=a.n23,c=a.n24,s=a.n31,E=a.n32,r=a.n33,w=a.n34,v=a.n41,x=a.n42,L=a.n43,u=a.n44,A=b.n11,l=b.n12,h=b.n13,i=b.n14,n=b.n21,y=b.n22,p=b.n23,o=b.n24,G=b.n31,B=b.n32,R=b.n33,F=b.n34,W=b.n41,V=b.n42,D=b.n43,
|
|
|
+P=b.n44;this.n11=d*A+e*n+f*G+j*W;this.n12=d*l+e*y+f*B+j*V;this.n13=d*h+e*p+f*R+j*D;this.n14=d*i+e*o+f*F+j*P;this.n21=k*A+g*n+m*G+c*W;this.n22=k*l+g*y+m*B+c*V;this.n23=k*h+g*p+m*R+c*D;this.n24=k*i+g*o+m*F+c*P;this.n31=s*A+E*n+r*G+w*W;this.n32=s*l+E*y+r*B+w*V;this.n33=s*h+E*p+r*R+w*D;this.n34=s*i+E*o+r*F+w*P;this.n41=v*A+x*n+L*G+u*W;this.n42=v*l+x*y+L*B+u*V;this.n43=v*h+x*p+L*R+u*D;this.n44=v*i+x*o+L*F+u*P},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,m=this.n24,c=this.n31,s=this.n32,E=this.n33,r=this.n34,w=this.n41,v=this.n42,x=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+m*a.n41;this.n22=j*a.n12+k*a.n22+g*a.n32+m*a.n42;this.n23=j*a.n13+k*a.n23+g*a.n33+m*a.n43;this.n24=j*a.n14+k*a.n24+g*a.n34+m*a.n44;this.n31=c*a.n11+s*a.n21+E*a.n31+r*a.n41;this.n32=c*a.n12+s*a.n22+
|
|
|
+E*a.n32+r*a.n42;this.n33=c*a.n13+s*a.n23+E*a.n33+r*a.n43;this.n34=c*a.n14+s*a.n24+E*a.n34+r*a.n44;this.n41=w*a.n11+v*a.n21+x*a.n31+L*a.n41;this.n42=w*a.n12+v*a.n22+x*a.n32+L*a.n42;this.n43=w*a.n13+v*a.n23+x*a.n33+L*a.n43;this.n44=w*a.n14+v*a.n24+x*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*
|
|
|
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(c,d,f){var g=c[d];c[d]=c[f];c[f]=g}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 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,
|
|
|
"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,c,d){var f=new THREE.Matrix4;f.n14=a;f.n24=c;f.n34=d;return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.n11=a;f.n22=c;f.n33=d;return f};
|
|
|
-THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.n22=c.n33=Math.cos(a);c.n32=Math.sin(a);c.n23=-c.n32;return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n33=Math.cos(a);c.n13=Math.sin(a);c.n31=-c.n13;return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.n11=c.n22=Math.cos(a);c.n21=Math.sin(a);c.n12=-c.n21;return c};
|
|
|
-THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4,f=Math.cos(c),g=Math.sin(c),i=1-f,k=a.x,b=a.y,j=a.z;d.n11=i*k*k+f;d.n12=i*k*b-g*j;d.n13=i*k*j+g*b;d.n21=i*k*b+g*j;d.n22=i*b*b+f;d.n23=i*b*j-g*k;d.n31=i*k*j-g*b;d.n32=i*b*j+g*k;d.n33=i*j*j+f;return d};
|
|
|
-THREE.Matrix4.makeInvert=function(a){var c=new THREE.Matrix4;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.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;c.multiplyScalar(1/a.determinant());return c};
|
|
|
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=new THREE.Matrix3;var d=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],g=c[6]*c[1]-c[2]*c[5],i=-c[10]*c[4]+c[6]*c[8],k=c[10]*c[0]-c[2]*c[8],b=-c[6]*c[0]+c[2]*c[4],j=c[9]*c[4]-c[5]*c[8],x=-c[9]*c[0]+c[1]*c[8],s=c[5]*c[0]-c[1]*c[4];c=c[0]*d+c[1]*i+c[2]*j;if(c==0)throw"matrix not invertible";c=1/c;a.m[0]=c*d;a.m[1]=c*f;a.m[2]=c*g;a.m[3]=c*i;a.m[4]=c*k;a.m[5]=c*b;a.m[6]=c*j;a.m[7]=c*x;a.m[8]=c*s;return a};
|
|
|
-THREE.Matrix4.makeFrustum=function(a,c,d,f,g,i){var k,b,j;k=new THREE.Matrix4;b=2*g/(c-a);j=2*g/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(i+g)/(i-g);g=-2*i*g/(i-g);k.n11=b;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=j;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=f;k.n34=g;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,c,d,f){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,f)};
|
|
|
-THREE.Matrix4.makeOrtho=function(a,c,d,f,g,i){var k,b,j,x;k=new THREE.Matrix4;b=c-a;j=d-f;x=i-g;a=(c+a)/b;d=(d+f)/j;g=(i+g)/x;k.n11=2/b;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/j;k.n23=0;k.n24=-d;k.n31=0;k.n32=0;k.n33=-2/x;k.n34=-g;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};
|
|
|
-THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
|
|
|
-THREE.Face3=function(a,c,d,f,g){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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,c,d,f,g,i){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.material=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0};
|
|
|
+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,m=a.z;d.n11=j*k*k+e;d.n12=j*k*g-f*m;d.n13=j*k*m+f*g;d.n21=j*k*g+f*m;d.n22=j*g*g+e;d.n23=j*g*m-f*k;d.n31=j*k*m-f*g;d.n32=j*g*m+f*k;d.n33=j*m*m+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],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],s=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*m;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*m;a.m[7]=b*c;a.m[8]=b*s;return a};
|
|
|
+THREE.Matrix4.makeFrustum=function(a,b,d,e,f,j){var k,g,m;k=new THREE.Matrix4;g=2*f/(b-a);m=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=m;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,m,c;k=new THREE.Matrix4;g=b-a;m=d-e;c=j-f;a=(b+a)/g;d=(d+e)/m;f=(j+f)/c;k.n11=2/g;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/m;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.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.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=[]};
|
|
|
-THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];d.centroid.set(0,0,0);d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);if(d instanceof THREE.Face3)d.centroid.divideScalar(3);else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeNormals:function(a){var c,d,f,g,i,k,b=new THREE.Vector3,
|
|
|
-j=new THREE.Vector3;f=0;for(g=this.vertices.length;f<g;f++){i=this.vertices[f];i.normal.set(0,0,0)}f=0;for(g=this.faces.length;f<g;f++){i=this.faces[f];if(a&&i.vertexNormals.length){b.set(0,0,0);c=0;for(d=i.normal.length;c<d;c++)b.addSelf(i.vertexNormals[c]);b.divideScalar(3)}else{c=this.vertices[i.a];d=this.vertices[i.b];k=this.vertices[i.c];b.sub(k.position,d.position);j.sub(c.position,d.position);b.crossSelf(j)}b.isZero()||b.normalize();i.normal.copy(b)}},computeBoundingBox:function(){if(this.vertices.length>
|
|
|
-0){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,c=this.vertices.length;a<c;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>
|
|
|
+THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);if(d instanceof THREE.Face3)d.centroid.divideScalar(3);else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeNormals:function(a){var b,d,e,f,j,k,g=new THREE.Vector3,
|
|
|
+m=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){j=this.vertices[e];j.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){j=this.faces[e];if(a&&j.vertexNormals.length){g.set(0,0,0);b=0;for(d=j.normal.length;b<d;b++)g.addSelf(j.vertexNormals[b]);g.divideScalar(3)}else{b=this.vertices[j.a];d=this.vertices[j.b];k=this.vertices[j.c];g.sub(k.position,d.position);m.sub(b.position,d.position);g.crossSelf(m)}g.isZero()||g.normalize();j.normal.copy(g)}},computeBoundingBox:function(){if(this.vertices.length>
|
|
|
+0){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;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>
|
|
|
this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}};
|
|
|
-THREE.Camera=function(a,c,d,f){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,c,d,f);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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
|
|
|
-THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
|
|
|
+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;
|
|
|
THREE.Object3D=function(){this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);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.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,c){THREE.Object3D.call(this);this.geometry=a;this.material=c instanceof Array?c:[c]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
|
|
|
-THREE.Mesh=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.material=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.materialFaceGroup={};this.sortFacesByMaterial();d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;
|
|
|
-THREE.Mesh.prototype.sortFacesByMaterial=function(){function a(s){var D=[];c=0;for(d=s.length;c<d;c++)s[c]==undefined?D.push("undefined"):D.push(s[c].toString());return D.join("_")}var c,d,f,g,i,k,b,j,x={};f=0;for(g=this.geometry.faces.length;f<g;f++){i=this.geometry.faces[f];k=i.material;b=a(k);if(x[b]==undefined)x[b]={hash:b,counter:0};j=x[b].hash+"_"+x[b].counter;if(this.materialFaceGroup[j]==undefined)this.materialFaceGroup[j]={faces:[],material:k,vertices:0};i=i instanceof THREE.Face3?3:4;if(this.materialFaceGroup[j].vertices+
|
|
|
-i>65535){x[b].counter+=1;j=x[b].hash+"_"+x[b].counter;if(this.materialFaceGroup[j]==undefined)this.materialFaceGroup[j]={faces:[],material:k,vertices:0}}this.materialFaceGroup[j].faces.push(f);this.materialFaceGroup[j].vertices+=i}};THREE.Mesh.prototype.normalizeUVs=function(){var a,c,d,f,g;a=0;for(c=this.geometry.uvs.length;a<c;a++){g=this.geometry.uvs[a];d=0;for(f=g.length;d<f;d++){if(g[d].u!=1)g[d].u-=Math.floor(g[d].u);if(g[d].v!=1)g[d].v-=Math.floor(g[d].v)}}};THREE.FlatShading=0;
|
|
|
+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;this.materialFaceGroup={};this.sortFacesByMaterial();d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;
|
|
|
+THREE.Mesh.prototype.sortFacesByMaterial=function(){function a(s){var E=[];b=0;for(d=s.length;b<d;b++)s[b]==undefined?E.push("undefined"):E.push(s[b].toString());return E.join("_")}var b,d,e,f,j,k,g,m,c={};e=0;for(f=this.geometry.faces.length;e<f;e++){j=this.geometry.faces[e];k=j.material;g=a(k);if(c[g]==undefined)c[g]={hash:g,counter:0};m=c[g].hash+"_"+c[g].counter;if(this.materialFaceGroup[m]==undefined)this.materialFaceGroup[m]={faces:[],material:k,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.materialFaceGroup[m].vertices+
|
|
|
+j>65535){c[g].counter+=1;m=c[g].hash+"_"+c[g].counter;if(this.materialFaceGroup[m]==undefined)this.materialFaceGroup[m]={faces:[],material:k,vertices:0}}this.materialFaceGroup[m].faces.push(e);this.materialFaceGroup[m].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,e,f;a=0;for(b=this.geometry.uvs.length;a<b;a++){f=this.geometry.uvs[a];d=0;for(e=f.length;d<e;d++){if(f[d].u!=1)f[d].u-=Math.floor(f[d].u);if(f[d].v!=1)f[d].v-=Math.floor(f[d].v)}}};THREE.FlatShading=0;
|
|
|
THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
|
|
|
THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+
|
|
|
this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
|
|
@@ -79,127 +79,126 @@ a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undef
|
|
|
this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};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 (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+
|
|
|
this.blending+"<br/>)"}};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 (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
|
|
|
-THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f){this.image=a;this.loaded=false;this.mapping=c!==undefined?c:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=f!==undefined?f:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>)"}};
|
|
|
-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,c){this.image=a;this.mapping=c?c:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};
|
|
|
+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 (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>)"}};
|
|
|
+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 (<br/>image: "+this.image+"<br/>mapping: "+this.mapping+"<br/>)"}};
|
|
|
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(h,e){var l=0,r=1,n=h.z+h.w,p=e.z+e.w,w=-h.z+h.w,C=-e.z+e.w;if(n>=0&&p>=0&&w>=0&&C>=0)return true;else if(n<0&&p<0||w<0&&C<0)return false;else{if(n<0)l=Math.max(l,n/(n-p));else if(p<0)r=Math.min(r,n/(n-p));if(w<0)l=Math.max(l,w/(w-C));else if(C<0)r=Math.min(r,w/(w-C));if(r<l)return false;else{h.lerpSelf(e,l);e.lerpSelf(h,1-r);return true}}}var c=null,d,f,g,i=[],k,b,j=[],x,s,D=[],o=new THREE.Vector4,v=new THREE.Matrix4,u=new THREE.Matrix4,y=new THREE.Vector4,I=
|
|
|
-new THREE.Vector4,t;this.projectScene=function(h,e){var l,r,n,p,w,C,L,B,U,F,E,V,T,J,A,Q,N;c=[];g=b=s=0;e.autoUpdateMatrix&&e.updateMatrix();v.multiply(e.projectionMatrix,e.matrix);L=h.objects;l=0;for(r=L.length;l<r;l++){B=L[l];B.autoUpdateMatrix&&B.updateMatrix();U=B.matrix;F=B.rotationMatrix;E=B.material;V=B.overdraw;if(B instanceof THREE.Mesh){T=B.geometry.vertices;n=0;for(p=T.length;n<p;n++){J=T[n];J.positionWorld.copy(J.position);U.transformVector3(J.positionWorld);A=J.positionScreen;A.copy(J.positionWorld);
|
|
|
-v.transformVector4(A);A.multiplyScalar(1/A.w);J.__visible=A.z>0&&A.z<1}J=B.geometry.faces;n=0;for(p=J.length;n<p;n++){A=J[n];if(A instanceof THREE.Face3){w=T[A.a];C=T[A.b];Q=T[A.c];if(w.__visible&&C.__visible&&Q.__visible)if(B.doubleSided||B.flipSided!=(Q.positionScreen.x-w.positionScreen.x)*(C.positionScreen.y-w.positionScreen.y)-(Q.positionScreen.y-w.positionScreen.y)*(C.positionScreen.x-w.positionScreen.x)<0){d=i[g]=i[g]||new THREE.RenderableFace3;d.v1.positionWorld.copy(w.positionWorld);d.v2.positionWorld.copy(C.positionWorld);
|
|
|
-d.v3.positionWorld.copy(Q.positionWorld);d.v1.positionScreen.copy(w.positionScreen);d.v2.positionScreen.copy(C.positionScreen);d.v3.positionScreen.copy(Q.positionScreen);d.normalWorld.copy(A.normal);F.transformVector3(d.normalWorld);d.centroidWorld.copy(A.centroid);U.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);v.transformVector3(d.centroidScreen);Q=A.vertexNormals;t=d.vertexNormalsWorld;w=0;for(C=Q.length;w<C;w++){N=t[w]=t[w]||new THREE.Vector3;N.copy(Q[w]);F.transformVector3(N)}d.z=
|
|
|
-d.centroidScreen.z;d.meshMaterial=E;d.faceMaterial=A.material;d.overdraw=V;if(B.geometry.uvs[n]){d.uvs[0]=B.geometry.uvs[n][0];d.uvs[1]=B.geometry.uvs[n][1];d.uvs[2]=B.geometry.uvs[n][2]}c.push(d);g++}}else if(A instanceof THREE.Face4){w=T[A.a];C=T[A.b];Q=T[A.c];N=T[A.d];if(w.__visible&&C.__visible&&Q.__visible&&N.__visible)if(B.doubleSided||B.flipSided!=((N.positionScreen.x-w.positionScreen.x)*(C.positionScreen.y-w.positionScreen.y)-(N.positionScreen.y-w.positionScreen.y)*(C.positionScreen.x-w.positionScreen.x)<
|
|
|
-0||(C.positionScreen.x-Q.positionScreen.x)*(N.positionScreen.y-Q.positionScreen.y)-(C.positionScreen.y-Q.positionScreen.y)*(N.positionScreen.x-Q.positionScreen.x)<0)){d=i[g]=i[g]||new THREE.RenderableFace3;d.v1.positionWorld.copy(w.positionWorld);d.v2.positionWorld.copy(C.positionWorld);d.v3.positionWorld.copy(N.positionWorld);d.v1.positionScreen.copy(w.positionScreen);d.v2.positionScreen.copy(C.positionScreen);d.v3.positionScreen.copy(N.positionScreen);d.normalWorld.copy(A.normal);F.transformVector3(d.normalWorld);
|
|
|
-d.centroidWorld.copy(A.centroid);U.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);v.transformVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=E;d.faceMaterial=A.material;d.overdraw=V;if(B.geometry.uvs[n]){d.uvs[0]=B.geometry.uvs[n][0];d.uvs[1]=B.geometry.uvs[n][1];d.uvs[2]=B.geometry.uvs[n][3]}c.push(d);g++;f=i[g]=i[g]||new THREE.RenderableFace3;f.v1.positionWorld.copy(C.positionWorld);f.v2.positionWorld.copy(Q.positionWorld);f.v3.positionWorld.copy(N.positionWorld);
|
|
|
-f.v1.positionScreen.copy(C.positionScreen);f.v2.positionScreen.copy(Q.positionScreen);f.v3.positionScreen.copy(N.positionScreen);f.normalWorld.copy(d.normalWorld);f.centroidWorld.copy(d.centroidWorld);f.centroidScreen.copy(d.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterial=E;f.faceMaterial=A.material;f.overdraw=V;if(B.geometry.uvs[n]){f.uvs[0]=B.geometry.uvs[n][1];f.uvs[1]=B.geometry.uvs[n][2];f.uvs[2]=B.geometry.uvs[n][3]}c.push(f);g++}}}}else if(B instanceof THREE.Line){u.multiply(v,U);T=B.geometry.vertices;
|
|
|
-J=T[0];J.positionScreen.copy(J.position);u.transformVector4(J.positionScreen);n=1;for(p=T.length;n<p;n++){w=T[n];w.positionScreen.copy(w.position);u.transformVector4(w.positionScreen);C=T[n-1];y.copy(w.positionScreen);I.copy(C.positionScreen);if(a(y,I)){y.multiplyScalar(1/y.w);I.multiplyScalar(1/I.w);k=j[b]=j[b]||new THREE.RenderableLine;k.v1.positionScreen.copy(y);k.v2.positionScreen.copy(I);k.z=Math.max(y.z,I.z);k.material=B.material;c.push(k);b++}}}else if(B instanceof THREE.Particle){o.set(B.position.x,
|
|
|
-B.position.y,B.position.z,1);v.transformVector4(o);o.z/=o.w;if(o.z>0&&o.z<1){x=D[s]=D[s]||new THREE.RenderableParticle;x.x=o.x/o.w;x.y=o.y/o.w;x.z=o.z;x.rotation=B.rotation.z;x.scale.x=B.scale.x*Math.abs(x.x-(o.x+e.projectionMatrix.n11)/(o.w+e.projectionMatrix.n14));x.scale.y=B.scale.y*Math.abs(x.y-(o.y+e.projectionMatrix.n22)/(o.w+e.projectionMatrix.n24));x.material=B.material;c.push(x);s++}}}c.sort(function(W,M){return M.z-W.z});return c};this.unprojectVector=function(h,e){var l=new THREE.Matrix4;
|
|
|
-l.multiply(THREE.Matrix4.makeInvert(e.matrix),THREE.Matrix4.makeInvert(e.projectionMatrix));l.transformVector3(h);return h}};
|
|
|
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,g,i;this.domElement=document.createElement("div");this.setSize=function(k,b){d=k;f=b;g=d/2;i=f/2};this.render=function(k,b){var j,x,s,D,o,v,u,y;a=c.projectScene(k,b);j=0;for(x=a.length;j<x;j++){o=a[j];if(o instanceof THREE.RenderableParticle){u=o.x*g+g;y=o.y*i+i;s=0;for(D=o.material.length;s<D;s++){v=o.material[s];if(v instanceof THREE.ParticleDOMMaterial){v=v.domElement;v.style.left=u+"px";v.style.top=y+"px"}}}}}};
|
|
|
-THREE.CanvasRenderer=function(){function a(R,aa,Z,O){var H,S,ca,X,$=R.lights;R=0;for(H=$.length;R<H;R++){S=$[R];ca=S.color;X=S.intensity;if(S instanceof THREE.DirectionalLight){S=Z.dot(S.position)*X;if(S>0){O.r+=ca.r*S;O.g+=ca.g*S;O.b+=ca.b*S}}else if(S instanceof THREE.PointLight){ta.sub(S.position,aa);ta.normalize();S=Z.dot(ta)*X;if(S>0){O.r+=ca.r*S;O.g+=ca.g*S;O.b+=ca.b*S}}}}function c(R,aa,Z,O,H,S){if(H.opacity!=0){i(H.opacity);k(H.blending);U=R.positionScreen.x;F=R.positionScreen.y;E=aa.positionScreen.x;
|
|
|
-V=aa.positionScreen.y;T=Z.positionScreen.x;J=Z.positionScreen.y;var ca=U,X=F,$=E,da=V,ba=T,ha=J;t.beginPath();t.moveTo(ca,X);t.lineTo($,da);t.lineTo(ba,ha);t.lineTo(ca,X);t.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map)g(U,F,E,V,T,J,H.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 H.wireframe?d(H.color.__styleString,H.wireframe_linewidth):f(H.color.__styleString);else if(H instanceof THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){g(U,F,E,V,T,J,
|
|
|
-H.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(fa)if(!H.wireframe&&H.shading==THREE.SmoothShading&&O.vertexNormalsWorld.length==3){Q.r=N.r=W.r=ga.r;Q.g=N.g=W.g=ga.g;Q.b=N.b=W.b=ga.b;a(S,O.v1.positionWorld,O.vertexNormalsWorld[0],Q);a(S,O.v2.positionWorld,O.vertexNormalsWorld[1],N);a(S,O.v3.positionWorld,O.vertexNormalsWorld[2],W);M.r=(N.r+W.r)*0.5;M.g=(N.g+W.g)*0.5;M.b=(N.b+W.b)*0.5;q=b(Q,N,W,M);g(U,F,E,V,T,J,q,0,0,1,0,0,1)}else{ea.r=
|
|
|
-ga.r;ea.g=ga.g;ea.b=ga.b;a(S,O.centroidWorld,O.normalWorld,ea);A.r=H.color.r*ea.r;A.g=H.color.g*ea.g;A.b=H.color.b*ea.b;A.updateStyleString();H.wireframe?d(A.__styleString,H.wireframe_linewidth):f(A.__styleString)}else H.wireframe?d(H.color.__styleString,H.wireframe_linewidth):f(H.color.__styleString)}else if(H instanceof THREE.MeshDepthMaterial){K=H.__2near;Y=H.__farPlusNear;m=H.__farMinusNear;Q.r=Q.g=Q.b=1-K/(Y-R.positionScreen.z*m);N.r=N.g=N.b=1-K/(Y-aa.positionScreen.z*m);W.r=W.g=W.b=1-K/(Y-Z.positionScreen.z*
|
|
|
-m);M.r=(N.r+W.r)*0.5;M.g=(N.g+W.g)*0.5;M.b=(N.b+W.b)*0.5;q=b(Q,N,W,M);g(U,F,E,V,T,J,q,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){A.r=j(O.normalWorld.x);A.g=j(O.normalWorld.y);A.b=j(O.normalWorld.z);A.updateStyleString();H.wireframe?d(A.__styleString,H.wireframe_linewidth):f(A.__styleString)}}}function d(R,aa){if(l!=R)t.strokeStyle=l=R;if(n!=aa)t.lineWidth=n=aa;t.stroke();P.inflate(aa*2)}function f(R){if(r!=R)t.fillStyle=r=R;t.fill()}function g(R,aa,Z,O,H,S,ca,X,$,da,ba,ha,ma){var ka,
|
|
|
-ia;ka=ca.width-1;ia=ca.height-1;X*=ka;$*=ia;da*=ka;ba*=ia;ha*=ka;ma*=ia;Z-=R;O-=aa;H-=R;S-=aa;da-=X;ba-=$;ha-=X;ma-=$;ia=1/(da*ma-ha*ba);ka=(ma*Z-ba*H)*ia;ba=(ma*O-ba*S)*ia;Z=(da*H-ha*Z)*ia;O=(da*S-ha*O)*ia;R=R-ka*X-Z*$;aa=aa-ba*X-O*$;t.save();t.transform(ka,ba,Z,O,R,aa);t.clip();t.drawImage(ca,0,0);t.restore()}function i(R){if(h!=R)t.globalAlpha=h=R}function k(R){if(e!=R){switch(R){case THREE.NormalBlending:t.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:t.globalCompositeOperation=
|
|
|
-"lighter";break;case THREE.SubtractiveBlending:t.globalCompositeOperation="darker"}e=R}}function b(R,aa,Z,O){ja[0]=w(0,p(255,~~(R.r*255)));ja[1]=w(0,p(255,~~(R.g*255)));ja[2]=w(0,p(255,~~(R.b*255)));ja[4]=w(0,p(255,~~(aa.r*255)));ja[5]=w(0,p(255,~~(aa.g*255)));ja[6]=w(0,p(255,~~(aa.b*255)));ja[8]=w(0,p(255,~~(Z.r*255)));ja[9]=w(0,p(255,~~(Z.g*255)));ja[10]=w(0,p(255,~~(Z.b*255)));ja[12]=w(0,p(255,~~(O.r*255)));ja[13]=w(0,p(255,~~(O.g*255)));ja[14]=w(0,p(255,~~(O.b*255)));pa.putImageData(ua,0,0);sa.drawImage(qa,
|
|
|
-0,0);return ra}function j(R){return R<0?p((1+R)*0.5,0.5):0.5+p(R*0.5,0.5)}function x(R,aa){var Z=aa.x-R.x,O=aa.y-R.y,H=1/Math.sqrt(Z*Z+O*O);Z*=H;O*=H;aa.x+=Z;aa.y+=O;R.x-=Z;R.y-=O}var s=null,D=new THREE.Projector,o=document.createElement("canvas"),v,u,y,I,t=o.getContext("2d"),h=1,e=0,l=null,r=null,n=1,p=Math.min,w=Math.max,C,L,B,U,F,E,V,T,J,A=new THREE.Color,Q=new THREE.Color,N=new THREE.Color,W=new THREE.Color,M=new THREE.Color,K,Y,m,q,z=new THREE.Rectangle,G=new THREE.Rectangle,P=new THREE.Rectangle,
|
|
|
-fa=false,ea=new THREE.Color,ga=new THREE.Color,la=new THREE.Color,na=new THREE.Color,xa=Math.PI*2,ta=new THREE.Vector3,qa,pa,ua,ja,ra,sa,oa=16;qa=document.createElement("canvas");qa.width=qa.height=2;pa=qa.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);ua=pa.getImageData(0,0,2,2);ja=ua.data;ra=document.createElement("canvas");ra.width=ra.height=oa;sa=ra.getContext("2d");sa.translate(-oa/2,-oa/2);sa.scale(oa,oa);oa--;this.domElement=o;this.autoClear=true;this.setSize=function(R,
|
|
|
-aa){v=R;u=aa;y=v/2;I=u/2;o.width=v;o.height=u;z.set(-y,-I,y,I)};this.clear=function(){if(!G.isEmpty()){G.inflate(1);G.minSelf(z);t.clearRect(G.getX(),G.getY(),G.getWidth(),G.getHeight());G.empty()}};this.render=function(R,aa){var Z,O,H,S,ca,X,$,da;t.setTransform(1,0,0,-1,y,I);this.autoClear&&this.clear();s=D.projectScene(R,aa);if(fa=R.lights.length>0){ca=R.lights;ga.setRGB(0,0,0);la.setRGB(0,0,0);na.setRGB(0,0,0);Z=0;for(O=ca.length;Z<O;Z++){H=ca[Z];S=H.color;if(H instanceof THREE.AmbientLight){ga.r+=
|
|
|
-S.r;ga.g+=S.g;ga.b+=S.b}else if(H instanceof THREE.DirectionalLight){la.r+=S.r;la.g+=S.g;la.b+=S.b}else if(H instanceof THREE.PointLight){na.r+=S.r;na.g+=S.g;na.b+=S.b}}}Z=0;for(O=s.length;Z<O;Z++){H=s[Z];P.empty();if(H instanceof THREE.RenderableParticle){C=H;C.x*=y;C.y*=I;S=0;for(ca=H.material.length;S<ca;S++){X=C;$=H;var ba=H.material[S];if(ba.opacity!=0){i(ba.opacity);k(ba.blending);da=void 0;var ha=void 0,ma=void 0,ka=void 0,ia=void 0,va=void 0,wa=void 0;if(ba instanceof THREE.ParticleBasicMaterial){if(ba.map){ia=
|
|
|
-ba.map;va=ia.width>>1;wa=ia.height>>1;ma=$.scale.x*y;ka=$.scale.y*I;da=ma*va;ha=ka*wa;P.set(X.x-da,X.y-ha,X.x+da,X.y+ha);if(z.instersects(P)){t.save();t.translate(X.x,X.y);t.rotate(-$.rotation);t.scale(ma,-ka);t.translate(-va,-wa);t.drawImage(ia,0,0);t.restore()}}}else if(ba instanceof THREE.ParticleCircleMaterial){if(fa){ea.r=ga.r+la.r+na.r;ea.g=ga.g+la.g+na.g;ea.b=ga.b+la.b+na.b;A.r=ba.color.r*ea.r;A.g=ba.color.g*ea.g;A.b=ba.color.b*ea.b;A.updateStyleString()}else A.__styleString=ba.color.__styleString;
|
|
|
-da=$.scale.x*y;ha=$.scale.y*I;P.set(X.x-da,X.y-ha,X.x+da,X.y+ha);if(z.instersects(P)){ba=A.__styleString;if(r!=ba)t.fillStyle=r=ba;t.save();t.translate(X.x,X.y);t.rotate(-$.rotation);t.scale(da,ha);t.beginPath();t.arc(0,0,1,0,xa,true);t.closePath();t.fill();t.restore()}}}}}else if(H instanceof THREE.RenderableLine){C=H.v1;L=H.v2;C.positionScreen.x*=y;C.positionScreen.y*=I;L.positionScreen.x*=y;L.positionScreen.y*=I;P.addPoint(C.positionScreen.x,C.positionScreen.y);P.addPoint(L.positionScreen.x,L.positionScreen.y);
|
|
|
-if(z.instersects(P)){S=0;for(ca=H.material.length;S<ca;){$=C;da=L;X=H.material[S++];if(X.opacity!=0){i(X.opacity);k(X.blending);t.beginPath();t.moveTo($.positionScreen.x,$.positionScreen.y);t.lineTo(da.positionScreen.x,da.positionScreen.y);t.closePath();if(X instanceof THREE.LineBasicMaterial){A.__styleString=X.color.__styleString;$=X.linewidth;if(n!=$)t.lineWidth=n=$;$=A.__styleString;if(l!=$)t.strokeStyle=l=$;t.stroke();P.inflate(X.linewidth*2)}}}}}else if(H instanceof THREE.RenderableFace3){C=
|
|
|
-H.v1;L=H.v2;B=H.v3;C.positionScreen.x*=y;C.positionScreen.y*=I;L.positionScreen.x*=y;L.positionScreen.y*=I;B.positionScreen.x*=y;B.positionScreen.y*=I;if(H.overdraw){x(C.positionScreen,L.positionScreen);x(L.positionScreen,B.positionScreen);x(B.positionScreen,C.positionScreen)}P.addPoint(C.positionScreen.x,C.positionScreen.y);P.addPoint(L.positionScreen.x,L.positionScreen.y);P.addPoint(B.positionScreen.x,B.positionScreen.y);if(z.instersects(P)){S=0;for(ca=H.meshMaterial.length;S<ca;){da=H.meshMaterial[S++];
|
|
|
-if(da instanceof THREE.MeshFaceMaterial){X=0;for($=H.faceMaterial.length;X<$;)(da=H.faceMaterial[X++])&&c(C,L,B,H,da,R)}else c(C,L,B,H,da,R)}}}G.addRectangle(P)}t.setTransform(1,0,0,1,0,0)}};
|
|
|
-THREE.SVGRenderer=function(){function a(A,Q,N){var W,M,K,Y;W=0;for(M=A.lights.length;W<M;W++){K=A.lights[W];if(K instanceof THREE.DirectionalLight){Y=Q.normalWorld.dot(K.position)*K.intensity;if(Y>0){N.r+=K.color.r*Y;N.g+=K.color.g*Y;N.b+=K.color.b*Y}}else if(K instanceof THREE.PointLight){C.sub(K.position,Q.centroidWorld);C.normalize();Y=Q.normalWorld.dot(C)*K.intensity;if(Y>0){N.r+=K.color.r*Y;N.g+=K.color.g*Y;N.b+=K.color.b*Y}}}}function c(A,Q,N,W,M,K){F=f(E++);F.setAttribute("d","M "+A.positionScreen.x+
|
|
|
-" "+A.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)e.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(h){l.r=r.r;l.g=r.g;l.b=r.b;a(K,W,l);e.r=M.color.r*l.r;e.g=M.color.g*l.g;e.b=M.color.b*l.b;e.updateStyleString()}else e.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){w=1-M.__2near/(M.__farPlusNear-W.z*M.__farMinusNear);
|
|
|
-e.setRGB(w,w,w)}else M instanceof THREE.MeshNormalMaterial&&e.setRGB(g(W.normalWorld.x),g(W.normalWorld.y),g(W.normalWorld.z));M.wireframe?F.setAttribute("style","fill: none; stroke: "+e.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):F.setAttribute("style","fill: "+e.__styleString+"; fill-opacity: "+M.opacity);b.appendChild(F)}function d(A,Q,N,W,M,K,Y){F=f(E++);F.setAttribute("d",
|
|
|
-"M "+A.positionScreen.x+" "+A.positionScreen.y+" L "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)e.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(h){l.r=r.r;l.g=r.g;l.b=r.b;a(Y,M,l);e.r=K.color.r*l.r;e.g=K.color.g*l.g;e.b=K.color.b*l.b;e.updateStyleString()}else e.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshDepthMaterial){w=
|
|
|
-1-K.__2near/(K.__farPlusNear-M.z*K.__farMinusNear);e.setRGB(w,w,w)}else K instanceof THREE.MeshNormalMaterial&&e.setRGB(g(M.normalWorld.x),g(M.normalWorld.y),g(M.normalWorld.z));K.wireframe?F.setAttribute("style","fill: none; stroke: "+e.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):F.setAttribute("style","fill: "+e.__styleString+"; fill-opacity: "+K.opacity);b.appendChild(F)}
|
|
|
-function f(A){if(L[A]==null){L[A]=document.createElementNS("http://www.w3.org/2000/svg","path");J==0&&L[A].setAttribute("shape-rendering","crispEdges");return L[A]}return L[A]}function g(A){return A<0?Math.min((1+A)*0.5,0.5):0.5+Math.min(A*0.5,0.5)}var i=null,k=new THREE.Projector,b=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,x,s,D,o,v,u,y,I=new THREE.Rectangle,t=new THREE.Rectangle,h=false,e=new THREE.Color(16777215),l=new THREE.Color(16777215),r=new THREE.Color(0),n=new THREE.Color(0),
|
|
|
-p=new THREE.Color(0),w,C=new THREE.Vector3,L=[],B=[],U=[],F,E,V,T,J=1;this.domElement=b;this.autoClear=true;this.setQuality=function(A){switch(A){case "high":J=1;break;case "low":J=0}};this.setSize=function(A,Q){j=A;x=Q;s=j/2;D=x/2;b.setAttribute("viewBox",-s+" "+-D+" "+j+" "+x);b.setAttribute("width",j);b.setAttribute("height",x);I.set(-s,-D,s,D)};this.clear=function(){for(;b.childNodes.length>0;)b.removeChild(b.childNodes[0])};this.render=function(A,Q){var N,W,M,K,Y,m,q,z;this.autoClear&&this.clear();
|
|
|
-i=k.projectScene(A,Q);T=V=E=0;if(h=A.lights.length>0){q=A.lights;r.setRGB(0,0,0);n.setRGB(0,0,0);p.setRGB(0,0,0);N=0;for(W=q.length;N<W;N++){M=q[N];K=M.color;if(M instanceof THREE.AmbientLight){r.r+=K.r;r.g+=K.g;r.b+=K.b}else if(M instanceof THREE.DirectionalLight){n.r+=K.r;n.g+=K.g;n.b+=K.b}else if(M instanceof THREE.PointLight){p.r+=K.r;p.g+=K.g;p.b+=K.b}}}N=0;for(W=i.length;N<W;N++){q=i[N];t.empty();if(q instanceof THREE.RenderableParticle){o=q;o.x*=s;o.y*=-D;M=0;for(K=q.material.length;M<K;M++)if(z=
|
|
|
-q.material[M]){Y=o;m=q;z=z;var G=V++;if(B[G]==null){B[G]=document.createElementNS("http://www.w3.org/2000/svg","circle");J==0&&B[G].setAttribute("shape-rendering","crispEdges")}F=B[G];F.setAttribute("cx",Y.x);F.setAttribute("cy",Y.y);F.setAttribute("r",m.scale.x*s);if(z instanceof THREE.ParticleCircleMaterial){if(h){l.r=r.r+n.r+p.r;l.g=r.g+n.g+p.g;l.b=r.b+n.b+p.b;e.r=z.color.r*l.r;e.g=z.color.g*l.g;e.b=z.color.b*l.b;e.updateStyleString()}else e=z.color;F.setAttribute("style","fill: "+e.__styleString)}b.appendChild(F)}}else if(q instanceof
|
|
|
-THREE.RenderableLine){o=q.v1;v=q.v2;o.positionScreen.x*=s;o.positionScreen.y*=-D;v.positionScreen.x*=s;v.positionScreen.y*=-D;t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);if(I.instersects(t)){M=0;for(K=q.material.length;M<K;)if(z=q.material[M++]){Y=o;m=v;z=z;G=T++;if(U[G]==null){U[G]=document.createElementNS("http://www.w3.org/2000/svg","line");J==0&&U[G].setAttribute("shape-rendering","crispEdges")}F=U[G];F.setAttribute("x1",Y.positionScreen.x);
|
|
|
-F.setAttribute("y1",Y.positionScreen.y);F.setAttribute("x2",m.positionScreen.x);F.setAttribute("y2",m.positionScreen.y);if(z instanceof THREE.LineBasicMaterial){e.__styleString=z.color.__styleString;F.setAttribute("style","fill: none; stroke: "+e.__styleString+"; stroke-width: "+z.linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.linecap+"; stroke-linejoin: "+z.linejoin);b.appendChild(F)}}}}else if(q instanceof THREE.RenderableFace3){o=q.v1;v=q.v2;u=q.v3;o.positionScreen.x*=s;o.positionScreen.y*=
|
|
|
--D;v.positionScreen.x*=s;v.positionScreen.y*=-D;u.positionScreen.x*=s;u.positionScreen.y*=-D;t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);if(I.instersects(t)){M=0;for(K=q.meshMaterial.length;M<K;){z=q.meshMaterial[M++];if(z instanceof THREE.MeshFaceMaterial){Y=0;for(m=q.faceMaterial.length;Y<m;)(z=q.faceMaterial[Y++])&&c(o,v,u,q,z,A)}else z&&c(o,v,u,q,z,A)}}}else if(q instanceof THREE.RenderableFace4){o=
|
|
|
-q.v1;v=q.v2;u=q.v3;y=q.v4;o.positionScreen.x*=s;o.positionScreen.y*=-D;v.positionScreen.x*=s;v.positionScreen.y*=-D;u.positionScreen.x*=s;u.positionScreen.y*=-D;y.positionScreen.x*=s;y.positionScreen.y*=-D;t.addPoint(o.positionScreen.x,o.positionScreen.y);t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);t.addPoint(y.positionScreen.x,y.positionScreen.y);if(I.instersects(t)){M=0;for(K=q.meshMaterial.length;M<K;){z=q.meshMaterial[M++];if(z instanceof
|
|
|
-THREE.MeshFaceMaterial){Y=0;for(m=q.faceMaterial.length;Y<m;)(z=q.faceMaterial[Y++])&&d(o,v,u,y,q,z,A)}else z&&d(o,v,u,y,q,z,A)}}}}}};
|
|
|
-THREE.WebGLRenderer=function(a){function c(h,e){var l=b.createProgram();b.attachShader(l,g("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\n"+h));b.attachShader(l,g("vertex","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"+e));b.linkProgram(l);b.getProgramParameter(l,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(l,
|
|
|
-b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");l.uniforms={};return l}function d(h,e){var l,r,n;l=0;for(r=e.length;l<r;l++){n=e[l];h.uniforms[n]=b.getUniformLocation(h,n)}}function f(h){h.position=b.getAttribLocation(h,"position");b.enableVertexAttribArray(h.position);h.normal=b.getAttribLocation(h,"normal");b.enableVertexAttribArray(h.normal);h.uv=b.getAttribLocation(h,"uv");b.enableVertexAttribArray(h.uv)}function g(h,e){var l;if(h=="fragment")l=b.createShader(b.FRAGMENT_SHADER);else if(h==
|
|
|
-"vertex")l=b.createShader(b.VERTEX_SHADER);b.shaderSource(l,e);b.compileShader(l);if(!b.getShaderParameter(l,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(l));return null}return l}function i(h){switch(h){case THREE.Repeat:return b.REPEAT;case THREE.ClampToEdge:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return b.MIRRORED_REPEAT}return 0}var k=document.createElement("canvas"),b,j,x,s=new THREE.Matrix4,D,o=new Float32Array(16),v=new Float32Array(16),u=new Float32Array(16),y=new Float32Array(9),I=
|
|
|
-new Float32Array(16);a=function(h,e){if(h){var l,r,n,p=pointLights=maxDirLights=maxPointLights=0;l=0;for(r=h.lights.length;l<r;l++){n=h.lights[l];n instanceof THREE.DirectionalLight&&p++;n instanceof THREE.PointLight&&pointLights++}if(pointLights+p<=e){maxDirLights=p;maxPointLights=pointLights}else{maxDirLights=Math.ceil(e*p/(pointLights+p));maxPointLights=e-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:e-1}}(a,4);this.domElement=k;this.autoClear=true;
|
|
|
-try{b=k.getContext("experimental-webgl",{antialias:true})}catch(t){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(0,0,0,0);(function(h,e){var l=[h?"#define MAX_DIR_LIGHTS "+h:"",e?"#define MAX_POINT_LIGHTS "+e:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",
|
|
|
-h?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",e?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",e?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
|
|
|
-h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",h?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",h?"}":"",e?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",e?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",e?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
-"",e?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",e?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",e?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
|
|
|
-r=[h?"#define MAX_DIR_LIGHTS "+h:"",e?"#define MAX_POINT_LIGHTS "+e:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
|
|
|
-h?"uniform mat4 viewMatrix;":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",e?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform vec3 cameraPosition;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 5 ) { \nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n} else if ( material == 4 ) { \ngl_FragColor = vec4( 0.5*normalize( vNormal ) + vec3(0.5, 0.5, 0.5), mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
|
|
|
-e?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",e?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",e?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",e?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",e?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",e?"float pointSpecularWeight = 0.0;":"",e?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
-"",e?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",e?"pointDiffuse += mColor * pointDiffuseWeight;":"",e?"pointSpecular += mSpecular * pointSpecularWeight;":"",e?"}":"",h?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"vec3 dirVector = normalize( lDirection.xyz );":"",h?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
-"",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"totalLight += dirDiffuse + dirSpecular;":"",e?"totalLight += pointDiffuse + pointSpecular;":
|
|
|
+THREE.Projector=function(){function a(A,l){var h=0,i=1,n=A.z+A.w,y=l.z+l.w,p=-A.z+A.w,o=-l.z+l.w;if(n>=0&&y>=0&&p>=0&&o>=0)return true;else if(n<0&&y<0||p<0&&o<0)return false;else{if(n<0)h=Math.max(h,n/(n-y));else if(y<0)i=Math.min(i,n/(n-y));if(p<0)h=Math.max(h,p/(p-o));else if(o<0)i=Math.min(i,p/(p-o));if(i<h)return false;else{A.lerpSelf(l,h);l.lerpSelf(A,1-i);return true}}}var b=null,d,e,f,j=[],k,g,m=[],c,s,E=[],r=new THREE.Vector4,w=new THREE.Matrix4,v=new THREE.Matrix4,x=new THREE.Vector4,L=
|
|
|
+new THREE.Vector4,u;this.projectScene=function(A,l){var h,i,n,y,p,o,G,B,R,F,W,V,D,P,C,J,H;b=[];f=g=s=0;l.autoUpdateMatrix&&l.updateMatrix();w.multiply(l.projectionMatrix,l.matrix);G=A.objects;h=0;for(i=G.length;h<i;h++){B=G[h];B.autoUpdateMatrix&&B.updateMatrix();R=B.matrix;F=B.rotationMatrix;W=B.material;V=B.overdraw;if(B instanceof THREE.Mesh){D=B.geometry.vertices;n=0;for(y=D.length;n<y;n++){P=D[n];P.positionWorld.copy(P.position);R.transformVector3(P.positionWorld);C=P.positionScreen;C.copy(P.positionWorld);
|
|
|
+w.transformVector4(C);C.multiplyScalar(1/C.w);P.__visible=C.z>0&&C.z<1}P=B.geometry.faces;n=0;for(y=P.length;n<y;n++){C=P[n];if(C instanceof THREE.Face3){p=D[C.a];o=D[C.b];J=D[C.c];if(p.__visible&&o.__visible&&J.__visible)if(B.doubleSided||B.flipSided!=(J.positionScreen.x-p.positionScreen.x)*(o.positionScreen.y-p.positionScreen.y)-(J.positionScreen.y-p.positionScreen.y)*(o.positionScreen.x-p.positionScreen.x)<0){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(p.positionWorld);d.v2.positionWorld.copy(o.positionWorld);
|
|
|
+d.v3.positionWorld.copy(J.positionWorld);d.v1.positionScreen.copy(p.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(J.positionScreen);d.normalWorld.copy(C.normal);F.transformVector3(d.normalWorld);d.centroidWorld.copy(C.centroid);R.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);w.transformVector3(d.centroidScreen);J=C.vertexNormals;u=d.vertexNormalsWorld;p=0;for(o=J.length;p<o;p++){H=u[p]=u[p]||new THREE.Vector3;H.copy(J[p]);F.transformVector3(H)}d.z=
|
|
|
+d.centroidScreen.z;d.meshMaterial=W;d.faceMaterial=C.material;d.overdraw=V;if(B.geometry.uvs[n]){d.uvs[0]=B.geometry.uvs[n][0];d.uvs[1]=B.geometry.uvs[n][1];d.uvs[2]=B.geometry.uvs[n][2]}b.push(d);f++}}else if(C instanceof THREE.Face4){p=D[C.a];o=D[C.b];J=D[C.c];H=D[C.d];if(p.__visible&&o.__visible&&J.__visible&&H.__visible)if(B.doubleSided||B.flipSided!=((H.positionScreen.x-p.positionScreen.x)*(o.positionScreen.y-p.positionScreen.y)-(H.positionScreen.y-p.positionScreen.y)*(o.positionScreen.x-p.positionScreen.x)<
|
|
|
+0||(o.positionScreen.x-J.positionScreen.x)*(H.positionScreen.y-J.positionScreen.y)-(o.positionScreen.y-J.positionScreen.y)*(H.positionScreen.x-J.positionScreen.x)<0)){d=j[f]=j[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(p.positionWorld);d.v2.positionWorld.copy(o.positionWorld);d.v3.positionWorld.copy(H.positionWorld);d.v1.positionScreen.copy(p.positionScreen);d.v2.positionScreen.copy(o.positionScreen);d.v3.positionScreen.copy(H.positionScreen);d.normalWorld.copy(C.normal);F.transformVector3(d.normalWorld);
|
|
|
+d.centroidWorld.copy(C.centroid);R.transformVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);w.transformVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=W;d.faceMaterial=C.material;d.overdraw=V;if(B.geometry.uvs[n]){d.uvs[0]=B.geometry.uvs[n][0];d.uvs[1]=B.geometry.uvs[n][1];d.uvs[2]=B.geometry.uvs[n][3]}b.push(d);f++;e=j[f]=j[f]||new THREE.RenderableFace3;e.v1.positionWorld.copy(o.positionWorld);e.v2.positionWorld.copy(J.positionWorld);e.v3.positionWorld.copy(H.positionWorld);
|
|
|
+e.v1.positionScreen.copy(o.positionScreen);e.v2.positionScreen.copy(J.positionScreen);e.v3.positionScreen.copy(H.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=W;e.faceMaterial=C.material;e.overdraw=V;if(B.geometry.uvs[n]){e.uvs[0]=B.geometry.uvs[n][1];e.uvs[1]=B.geometry.uvs[n][2];e.uvs[2]=B.geometry.uvs[n][3]}b.push(e);f++}}}}else if(B instanceof THREE.Line){v.multiply(w,R);D=B.geometry.vertices;
|
|
|
+P=D[0];P.positionScreen.copy(P.position);v.transformVector4(P.positionScreen);n=1;for(y=D.length;n<y;n++){p=D[n];p.positionScreen.copy(p.position);v.transformVector4(p.positionScreen);o=D[n-1];x.copy(p.positionScreen);L.copy(o.positionScreen);if(a(x,L)){x.multiplyScalar(1/x.w);L.multiplyScalar(1/L.w);k=m[g]=m[g]||new THREE.RenderableLine;k.v1.positionScreen.copy(x);k.v2.positionScreen.copy(L);k.z=Math.max(x.z,L.z);k.material=B.material;b.push(k);g++}}}else if(B instanceof THREE.Particle){r.set(B.position.x,
|
|
|
+B.position.y,B.position.z,1);w.transformVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){c=E[s]=E[s]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=B.rotation.z;c.scale.x=B.scale.x*Math.abs(c.x-(r.x+l.projectionMatrix.n11)/(r.w+l.projectionMatrix.n14));c.scale.y=B.scale.y*Math.abs(c.y-(r.y+l.projectionMatrix.n22)/(r.w+l.projectionMatrix.n24));c.material=B.material;b.push(c);s++}}}b.sort(function(U,N){return N.z-U.z});return b};this.unprojectVector=function(A,l){var h=new THREE.Matrix4;
|
|
|
+h.multiply(THREE.Matrix4.makeInvert(l.matrix),THREE.Matrix4.makeInvert(l.projectionMatrix));h.transformVector3(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 m,c,s,E,r,w,v,x;a=b.projectScene(k,g);m=0;for(c=a.length;m<c;m++){r=a[m];if(r instanceof THREE.RenderableParticle){v=r.x*f+f;x=r.y*j+j;s=0;for(E=r.material.length;s<E;s++){w=r.material[s];if(w instanceof THREE.ParticleDOMMaterial){w=w.domElement;w.style.left=v+"px";w.style.top=x+"px"}}}}}};
|
|
|
+THREE.CanvasRenderer=function(){function a(S,aa,Z,O){var K,T,ca,X,$=S.lights;S=0;for(K=$.length;S<K;S++){T=$[S];ca=T.color;X=T.intensity;if(T instanceof THREE.DirectionalLight){T=Z.dot(T.position)*X;if(T>0){O.r+=ca.r*T;O.g+=ca.g*T;O.b+=ca.b*T}}else if(T instanceof THREE.PointLight){ta.sub(T.position,aa);ta.normalize();T=Z.dot(ta)*X;if(T>0){O.r+=ca.r*T;O.g+=ca.g*T;O.b+=ca.b*T}}}}function b(S,aa,Z,O,K,T){if(K.opacity!=0){j(K.opacity);k(K.blending);R=S.positionScreen.x;F=S.positionScreen.y;W=aa.positionScreen.x;
|
|
|
+V=aa.positionScreen.y;D=Z.positionScreen.x;P=Z.positionScreen.y;var ca=R,X=F,$=W,da=V,ba=D,ha=P;u.beginPath();u.moveTo(ca,X);u.lineTo($,da);u.lineTo(ba,ha);u.lineTo(ca,X);u.closePath();if(K instanceof THREE.MeshBasicMaterial)if(K.map)f(R,F,W,V,D,P,K.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 K.wireframe?d(K.color.__styleString,K.wireframe_linewidth):e(K.color.__styleString);else if(K instanceof THREE.MeshLambertMaterial){if(K.map&&!K.wireframe){f(R,F,W,V,D,P,
|
|
|
+K.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(fa)if(!K.wireframe&&K.shading==THREE.SmoothShading&&O.vertexNormalsWorld.length==3){J.r=H.r=U.r=ga.r;J.g=H.g=U.g=ga.g;J.b=H.b=U.b=ga.b;a(T,O.v1.positionWorld,O.vertexNormalsWorld[0],J);a(T,O.v2.positionWorld,O.vertexNormalsWorld[1],H);a(T,O.v3.positionWorld,O.vertexNormalsWorld[2],U);N.r=(H.r+U.r)*0.5;N.g=(H.g+U.g)*0.5;N.b=(H.b+U.b)*0.5;t=g(J,H,U,N);f(R,F,W,V,D,P,t,0,0,1,0,0,1)}else{ea.r=
|
|
|
+ga.r;ea.g=ga.g;ea.b=ga.b;a(T,O.centroidWorld,O.normalWorld,ea);C.r=K.color.r*ea.r;C.g=K.color.g*ea.g;C.b=K.color.b*ea.b;C.updateStyleString();K.wireframe?d(C.__styleString,K.wireframe_linewidth):e(C.__styleString)}else K.wireframe?d(K.color.__styleString,K.wireframe_linewidth):e(K.color.__styleString)}else if(K instanceof THREE.MeshDepthMaterial){M=K.__2near;Y=K.__farPlusNear;q=K.__farMinusNear;J.r=J.g=J.b=1-M/(Y-S.positionScreen.z*q);H.r=H.g=H.b=1-M/(Y-aa.positionScreen.z*q);U.r=U.g=U.b=1-M/(Y-Z.positionScreen.z*
|
|
|
+q);N.r=(H.r+U.r)*0.5;N.g=(H.g+U.g)*0.5;N.b=(H.b+U.b)*0.5;t=g(J,H,U,N);f(R,F,W,V,D,P,t,0,0,1,0,0,1)}else if(K instanceof THREE.MeshNormalMaterial){C.r=m(O.normalWorld.x);C.g=m(O.normalWorld.y);C.b=m(O.normalWorld.z);C.updateStyleString();K.wireframe?d(C.__styleString,K.wireframe_linewidth):e(C.__styleString)}}}function d(S,aa){if(h!=S)u.strokeStyle=h=S;if(n!=aa)u.lineWidth=n=aa;u.stroke();Q.inflate(aa*2)}function e(S){if(i!=S)u.fillStyle=i=S;u.fill()}function f(S,aa,Z,O,K,T,ca,X,$,da,ba,ha,ma){var ka,
|
|
|
+ia;ka=ca.width-1;ia=ca.height-1;X*=ka;$*=ia;da*=ka;ba*=ia;ha*=ka;ma*=ia;Z-=S;O-=aa;K-=S;T-=aa;da-=X;ba-=$;ha-=X;ma-=$;ia=1/(da*ma-ha*ba);ka=(ma*Z-ba*K)*ia;ba=(ma*O-ba*T)*ia;Z=(da*K-ha*Z)*ia;O=(da*T-ha*O)*ia;S=S-ka*X-Z*$;aa=aa-ba*X-O*$;u.save();u.transform(ka,ba,Z,O,S,aa);u.clip();u.drawImage(ca,0,0);u.restore()}function j(S){if(A!=S)u.globalAlpha=A=S}function k(S){if(l!=S){switch(S){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation=
|
|
|
+"lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}l=S}}function g(S,aa,Z,O){ja[0]=p(0,y(255,~~(S.r*255)));ja[1]=p(0,y(255,~~(S.g*255)));ja[2]=p(0,y(255,~~(S.b*255)));ja[4]=p(0,y(255,~~(aa.r*255)));ja[5]=p(0,y(255,~~(aa.g*255)));ja[6]=p(0,y(255,~~(aa.b*255)));ja[8]=p(0,y(255,~~(Z.r*255)));ja[9]=p(0,y(255,~~(Z.g*255)));ja[10]=p(0,y(255,~~(Z.b*255)));ja[12]=p(0,y(255,~~(O.r*255)));ja[13]=p(0,y(255,~~(O.g*255)));ja[14]=p(0,y(255,~~(O.b*255)));pa.putImageData(ua,0,0);sa.drawImage(qa,
|
|
|
+0,0);return ra}function m(S){return S<0?y((1+S)*0.5,0.5):0.5+y(S*0.5,0.5)}function c(S,aa){var Z=aa.x-S.x,O=aa.y-S.y,K=1/Math.sqrt(Z*Z+O*O);Z*=K;O*=K;aa.x+=Z;aa.y+=O;S.x-=Z;S.y-=O}var s=null,E=new THREE.Projector,r=document.createElement("canvas"),w,v,x,L,u=r.getContext("2d"),A=1,l=0,h=null,i=null,n=1,y=Math.min,p=Math.max,o,G,B,R,F,W,V,D,P,C=new THREE.Color,J=new THREE.Color,H=new THREE.Color,U=new THREE.Color,N=new THREE.Color,M,Y,q,t,z=new THREE.Rectangle,I=new THREE.Rectangle,Q=new THREE.Rectangle,
|
|
|
+fa=false,ea=new THREE.Color,ga=new THREE.Color,la=new THREE.Color,na=new THREE.Color,xa=Math.PI*2,ta=new THREE.Vector3,qa,pa,ua,ja,ra,sa,oa=16;qa=document.createElement("canvas");qa.width=qa.height=2;pa=qa.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);ua=pa.getImageData(0,0,2,2);ja=ua.data;ra=document.createElement("canvas");ra.width=ra.height=oa;sa=ra.getContext("2d");sa.translate(-oa/2,-oa/2);sa.scale(oa,oa);oa--;this.domElement=r;this.autoClear=true;this.setSize=function(S,
|
|
|
+aa){w=S;v=aa;x=w/2;L=v/2;r.width=w;r.height=v;z.set(-x,-L,x,L)};this.clear=function(){if(!I.isEmpty()){I.inflate(1);I.minSelf(z);u.clearRect(I.getX(),I.getY(),I.getWidth(),I.getHeight());I.empty()}};this.render=function(S,aa){var Z,O,K,T,ca,X,$,da;u.setTransform(1,0,0,-1,x,L);this.autoClear&&this.clear();s=E.projectScene(S,aa);if(fa=S.lights.length>0){ca=S.lights;ga.setRGB(0,0,0);la.setRGB(0,0,0);na.setRGB(0,0,0);Z=0;for(O=ca.length;Z<O;Z++){K=ca[Z];T=K.color;if(K instanceof THREE.AmbientLight){ga.r+=
|
|
|
+T.r;ga.g+=T.g;ga.b+=T.b}else if(K instanceof THREE.DirectionalLight){la.r+=T.r;la.g+=T.g;la.b+=T.b}else if(K instanceof THREE.PointLight){na.r+=T.r;na.g+=T.g;na.b+=T.b}}}Z=0;for(O=s.length;Z<O;Z++){K=s[Z];Q.empty();if(K instanceof THREE.RenderableParticle){o=K;o.x*=x;o.y*=L;T=0;for(ca=K.material.length;T<ca;T++){X=o;$=K;var ba=K.material[T];if(ba.opacity!=0){j(ba.opacity);k(ba.blending);da=void 0;var ha=void 0,ma=void 0,ka=void 0,ia=void 0,va=void 0,wa=void 0;if(ba instanceof THREE.ParticleBasicMaterial){if(ba.map){ia=
|
|
|
+ba.map;va=ia.width>>1;wa=ia.height>>1;ma=$.scale.x*x;ka=$.scale.y*L;da=ma*va;ha=ka*wa;Q.set(X.x-da,X.y-ha,X.x+da,X.y+ha);if(z.instersects(Q)){u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(ma,-ka);u.translate(-va,-wa);u.drawImage(ia,0,0);u.restore()}}}else if(ba instanceof THREE.ParticleCircleMaterial){if(fa){ea.r=ga.r+la.r+na.r;ea.g=ga.g+la.g+na.g;ea.b=ga.b+la.b+na.b;C.r=ba.color.r*ea.r;C.g=ba.color.g*ea.g;C.b=ba.color.b*ea.b;C.updateStyleString()}else C.__styleString=ba.color.__styleString;
|
|
|
+da=$.scale.x*x;ha=$.scale.y*L;Q.set(X.x-da,X.y-ha,X.x+da,X.y+ha);if(z.instersects(Q)){ba=C.__styleString;if(i!=ba)u.fillStyle=i=ba;u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(da,ha);u.beginPath();u.arc(0,0,1,0,xa,true);u.closePath();u.fill();u.restore()}}}}}else if(K instanceof THREE.RenderableLine){o=K.v1;G=K.v2;o.positionScreen.x*=x;o.positionScreen.y*=L;G.positionScreen.x*=x;G.positionScreen.y*=L;Q.addPoint(o.positionScreen.x,o.positionScreen.y);Q.addPoint(G.positionScreen.x,G.positionScreen.y);
|
|
|
+if(z.instersects(Q)){T=0;for(ca=K.material.length;T<ca;){$=o;da=G;X=K.material[T++];if(X.opacity!=0){j(X.opacity);k(X.blending);u.beginPath();u.moveTo($.positionScreen.x,$.positionScreen.y);u.lineTo(da.positionScreen.x,da.positionScreen.y);u.closePath();if(X instanceof THREE.LineBasicMaterial){C.__styleString=X.color.__styleString;$=X.linewidth;if(n!=$)u.lineWidth=n=$;$=C.__styleString;if(h!=$)u.strokeStyle=h=$;u.stroke();Q.inflate(X.linewidth*2)}}}}}else if(K instanceof THREE.RenderableFace3){o=
|
|
|
+K.v1;G=K.v2;B=K.v3;o.positionScreen.x*=x;o.positionScreen.y*=L;G.positionScreen.x*=x;G.positionScreen.y*=L;B.positionScreen.x*=x;B.positionScreen.y*=L;if(K.overdraw){c(o.positionScreen,G.positionScreen);c(G.positionScreen,B.positionScreen);c(B.positionScreen,o.positionScreen)}Q.addPoint(o.positionScreen.x,o.positionScreen.y);Q.addPoint(G.positionScreen.x,G.positionScreen.y);Q.addPoint(B.positionScreen.x,B.positionScreen.y);if(z.instersects(Q)){T=0;for(ca=K.meshMaterial.length;T<ca;){da=K.meshMaterial[T++];
|
|
|
+if(da instanceof THREE.MeshFaceMaterial){X=0;for($=K.faceMaterial.length;X<$;)(da=K.faceMaterial[X++])&&b(o,G,B,K,da,S)}else b(o,G,B,K,da,S)}}}I.addRectangle(Q)}u.setTransform(1,0,0,1,0,0)}};
|
|
|
+THREE.SVGRenderer=function(){function a(C,J,H){var U,N,M,Y;U=0;for(N=C.lights.length;U<N;U++){M=C.lights[U];if(M instanceof THREE.DirectionalLight){Y=J.normalWorld.dot(M.position)*M.intensity;if(Y>0){H.r+=M.color.r*Y;H.g+=M.color.g*Y;H.b+=M.color.b*Y}}else if(M instanceof THREE.PointLight){o.sub(M.position,J.centroidWorld);o.normalize();Y=J.normalWorld.dot(o)*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(C,J,H,U,N,M){F=e(W++);F.setAttribute("d","M "+C.positionScreen.x+
|
|
|
+" "+C.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+H.positionScreen.x+","+H.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)l.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(M,U,h);l.r=N.color.r*h.r;l.g=N.color.g*h.g;l.b=N.color.b*h.b;l.updateStyleString()}else l.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){p=1-N.__2near/(N.__farPlusNear-U.z*N.__farMinusNear);
|
|
|
+l.setRGB(p,p,p)}else N instanceof THREE.MeshNormalMaterial&&l.setRGB(f(U.normalWorld.x),f(U.normalWorld.y),f(U.normalWorld.z));N.wireframe?F.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):F.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+N.opacity);g.appendChild(F)}function d(C,J,H,U,N,M,Y){F=e(W++);F.setAttribute("d",
|
|
|
+"M "+C.positionScreen.x+" "+C.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+H.positionScreen.x+","+H.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)l.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(Y,N,h);l.r=M.color.r*h.r;l.g=M.color.g*h.g;l.b=M.color.b*h.b;l.updateStyleString()}else l.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){p=
|
|
|
+1-M.__2near/(M.__farPlusNear-N.z*M.__farMinusNear);l.setRGB(p,p,p)}else M instanceof THREE.MeshNormalMaterial&&l.setRGB(f(N.normalWorld.x),f(N.normalWorld.y),f(N.normalWorld.z));M.wireframe?F.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):F.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(F)}
|
|
|
+function e(C){if(G[C]==null){G[C]=document.createElementNS("http://www.w3.org/2000/svg","path");P==0&&G[C].setAttribute("shape-rendering","crispEdges");return G[C]}return G[C]}function f(C){return C<0?Math.min((1+C)*0.5,0.5):0.5+Math.min(C*0.5,0.5)}var j=null,k=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,s,E,r,w,v,x,L=new THREE.Rectangle,u=new THREE.Rectangle,A=false,l=new THREE.Color(16777215),h=new THREE.Color(16777215),i=new THREE.Color(0),n=new THREE.Color(0),
|
|
|
+y=new THREE.Color(0),p,o=new THREE.Vector3,G=[],B=[],R=[],F,W,V,D,P=1;this.domElement=g;this.autoClear=true;this.setQuality=function(C){switch(C){case "high":P=1;break;case "low":P=0}};this.setSize=function(C,J){m=C;c=J;s=m/2;E=c/2;g.setAttribute("viewBox",-s+" "+-E+" "+m+" "+c);g.setAttribute("width",m);g.setAttribute("height",c);L.set(-s,-E,s,E)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(C,J){var H,U,N,M,Y,q,t,z;this.autoClear&&this.clear();
|
|
|
+j=k.projectScene(C,J);D=V=W=0;if(A=C.lights.length>0){t=C.lights;i.setRGB(0,0,0);n.setRGB(0,0,0);y.setRGB(0,0,0);H=0;for(U=t.length;H<U;H++){N=t[H];M=N.color;if(N instanceof THREE.AmbientLight){i.r+=M.r;i.g+=M.g;i.b+=M.b}else if(N instanceof THREE.DirectionalLight){n.r+=M.r;n.g+=M.g;n.b+=M.b}else if(N instanceof THREE.PointLight){y.r+=M.r;y.g+=M.g;y.b+=M.b}}}H=0;for(U=j.length;H<U;H++){t=j[H];u.empty();if(t instanceof THREE.RenderableParticle){r=t;r.x*=s;r.y*=-E;N=0;for(M=t.material.length;N<M;N++)if(z=
|
|
|
+t.material[N]){Y=r;q=t;z=z;var I=V++;if(B[I]==null){B[I]=document.createElementNS("http://www.w3.org/2000/svg","circle");P==0&&B[I].setAttribute("shape-rendering","crispEdges")}F=B[I];F.setAttribute("cx",Y.x);F.setAttribute("cy",Y.y);F.setAttribute("r",q.scale.x*s);if(z instanceof THREE.ParticleCircleMaterial){if(A){h.r=i.r+n.r+y.r;h.g=i.g+n.g+y.g;h.b=i.b+n.b+y.b;l.r=z.color.r*h.r;l.g=z.color.g*h.g;l.b=z.color.b*h.b;l.updateStyleString()}else l=z.color;F.setAttribute("style","fill: "+l.__styleString)}g.appendChild(F)}}else if(t instanceof
|
|
|
+THREE.RenderableLine){r=t.v1;w=t.v2;r.positionScreen.x*=s;r.positionScreen.y*=-E;w.positionScreen.x*=s;w.positionScreen.y*=-E;u.addPoint(r.positionScreen.x,r.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);if(L.instersects(u)){N=0;for(M=t.material.length;N<M;)if(z=t.material[N++]){Y=r;q=w;z=z;I=D++;if(R[I]==null){R[I]=document.createElementNS("http://www.w3.org/2000/svg","line");P==0&&R[I].setAttribute("shape-rendering","crispEdges")}F=R[I];F.setAttribute("x1",Y.positionScreen.x);
|
|
|
+F.setAttribute("y1",Y.positionScreen.y);F.setAttribute("x2",q.positionScreen.x);F.setAttribute("y2",q.positionScreen.y);if(z instanceof THREE.LineBasicMaterial){l.__styleString=z.color.__styleString;F.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+z.linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.linecap+"; stroke-linejoin: "+z.linejoin);g.appendChild(F)}}}}else if(t instanceof THREE.RenderableFace3){r=t.v1;w=t.v2;v=t.v3;r.positionScreen.x*=s;r.positionScreen.y*=
|
|
|
+-E;w.positionScreen.x*=s;w.positionScreen.y*=-E;v.positionScreen.x*=s;v.positionScreen.y*=-E;u.addPoint(r.positionScreen.x,r.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(v.positionScreen.x,v.positionScreen.y);if(L.instersects(u)){N=0;for(M=t.meshMaterial.length;N<M;){z=t.meshMaterial[N++];if(z instanceof THREE.MeshFaceMaterial){Y=0;for(q=t.faceMaterial.length;Y<q;)(z=t.faceMaterial[Y++])&&b(r,w,v,t,z,C)}else z&&b(r,w,v,t,z,C)}}}else if(t instanceof THREE.RenderableFace4){r=
|
|
|
+t.v1;w=t.v2;v=t.v3;x=t.v4;r.positionScreen.x*=s;r.positionScreen.y*=-E;w.positionScreen.x*=s;w.positionScreen.y*=-E;v.positionScreen.x*=s;v.positionScreen.y*=-E;x.positionScreen.x*=s;x.positionScreen.y*=-E;u.addPoint(r.positionScreen.x,r.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);u.addPoint(v.positionScreen.x,v.positionScreen.y);u.addPoint(x.positionScreen.x,x.positionScreen.y);if(L.instersects(u)){N=0;for(M=t.meshMaterial.length;N<M;){z=t.meshMaterial[N++];if(z instanceof
|
|
|
+THREE.MeshFaceMaterial){Y=0;for(q=t.faceMaterial.length;Y<q;)(z=t.faceMaterial[Y++])&&d(r,w,v,x,t,z,C)}else z&&d(r,w,v,x,t,z,C)}}}}}};
|
|
|
+THREE.WebGLRenderer=function(a){function b(h,i){var n=c.createProgram();c.attachShader(n,k("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\n"+h));c.attachShader(n,k("vertex","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"+i));c.linkProgram(n);c.getProgramParameter(n,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(n,
|
|
|
+c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");n.uniforms={};return n}function d(h,i){if(h instanceof THREE.TextureCube&&h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,
|
|
|
+c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var n=0;n<6;++n)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image[n]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+i);c.bindTexture(c.TEXTURE_CUBE_MAP,h.image.__webGLTextureCube)}}function e(h,i){if(!h.__webGLTexture&&h.image.loaded){h.__webGLTexture=c.createTexture();
|
|
|
+c.bindTexture(c.TEXTURE_2D,h.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,g(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,g(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+i);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}
|
|
|
+function f(h,i){var n,y,p;n=0;for(y=i.length;n<y;n++){p=i[n];h.uniforms[p]=c.getUniformLocation(h,p)}}function j(h){h.position=c.getAttribLocation(h,"position");c.enableVertexAttribArray(h.position);h.normal=c.getAttribLocation(h,"normal");c.enableVertexAttribArray(h.normal);h.uv=c.getAttribLocation(h,"uv");c.enableVertexAttribArray(h.uv)}function k(h,i){var n;if(h=="fragment")n=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")n=c.createShader(c.VERTEX_SHADER);c.shaderSource(n,i);c.compileShader(n);
|
|
|
+if(!c.getShaderParameter(n,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(n));return null}return n}function g(h){switch(h){case THREE.Repeat:return c.REPEAT;case THREE.ClampToEdge:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeat:return c.MIRRORED_REPEAT}return 0}var m=document.createElement("canvas"),c,s,E,r=new THREE.Matrix4,w,v=new Float32Array(16),x=new Float32Array(16),L=new Float32Array(16),u=new Float32Array(9),A=new Float32Array(16);a=function(h,i){if(h){var n,y,p,o=pointLights=maxDirLights=maxPointLights=
|
|
|
+0;n=0;for(y=h.lights.length;n<y;n++){p=h.lights[n];p instanceof THREE.DirectionalLight&&o++;p instanceof THREE.PointLight&&pointLights++}if(pointLights+o<=i){maxDirLights=o;maxPointLights=pointLights}else{maxDirLights=Math.ceil(i*o/(pointLights+o));maxPointLights=i-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:i-1}}(a,4);this.domElement=m;this.autoClear=true;try{c=m.getContext("experimental-webgl",{antialias:true})}catch(l){}if(!c){alert("WebGL not supported");
|
|
|
+throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);(function(h,i){var n=[h?"#define MAX_DIR_LIGHTS "+h:"",i?"#define MAX_POINT_LIGHTS "+i:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",
|
|
|
+h?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",i?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","uniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",i?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
|
|
|
+h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"float directionalLightWeighting = max( dot( transformedNormal, normalize(lDirection.xyz ) ), 0.0 );":"",h?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",h?"}":"",i?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",i?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",i?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
|
|
|
+"",i?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",i?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",i?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
|
|
|
+y=[h?"#define MAX_DIR_LIGHTS "+h:"",i?"#define MAX_POINT_LIGHTS "+i:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\nuniform float m2Near;\nuniform float mFarPlusNear;\nuniform float mFarMinusNear;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
|
|
|
+h?"uniform mat4 viewMatrix;":"",h?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",i?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform vec3 cameraPosition;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 5 ) { \nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );\n} else if ( material == 4 ) { \ngl_FragColor = vec4( 0.5*normalize( vNormal ) + vec3(0.5, 0.5, 0.5), mOpacity );\n} else if ( material == 3 ) { \nfloat w = 0.5;\ngl_FragColor = vec4( w, w, w, mOpacity );\n} else if ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
|
|
|
+i?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",i?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",i?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",i?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",i?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",i?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",i?"float pointSpecularWeight = 0.0;":"",i?"if ( pointDotNormalHalf >= 0.0 )":
|
|
|
+"",i?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",i?"pointDiffuse += mColor * pointDiffuseWeight;":"",i?"pointSpecular += mSpecular * pointSpecularWeight;":"",i?"}":"",h?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"vec3 dirVector = normalize( lDirection.xyz );":"",h?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
|
|
|
+"",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"totalLight += dirDiffuse + dirSpecular;":"",i?"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");
|
|
|
-j=c(r,l);b.useProgram(j);d(j,["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"]);h&&d(j,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);e&&d(j,["pointLightNumber","pointLightColor",
|
|
|
-"pointLightPosition"]);b.uniform1i(j.uniforms.enableMap,0);b.uniform1i(j.uniforms.tMap,0);b.uniform1i(j.uniforms.enableCubeMap,0);b.uniform1i(j.uniforms.tCube,1);b.uniform1i(j.uniforms.mixEnvMap,0);b.uniform1i(j.uniforms.useRefract,0);f(j)})(a.directional,a.point);this.setSize=function(h,e){k.width=h;k.height=e;b.viewport(0,0,k.width,k.height)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(h,e){var l,r,n,p,w,C=[],L=[],B=[];p=[];w=[];b.uniform1i(h.uniforms.enableLighting,
|
|
|
-e.lights.length);l=0;for(r=e.lights.length;l<r;l++){n=e.lights[l];if(n instanceof THREE.AmbientLight)C.push(n);else if(n instanceof THREE.DirectionalLight)B.push(n);else n instanceof THREE.PointLight&&L.push(n)}l=n=p=w=0;for(r=C.length;l<r;l++){n+=C[l].color.r;p+=C[l].color.g;w+=C[l].color.b}b.uniform3f(h.uniforms.ambientLightColor,n,p,w);p=[];w=[];l=0;for(r=B.length;l<r;l++){n=B[l];p.push(n.color.r*n.intensity);p.push(n.color.g*n.intensity);p.push(n.color.b*n.intensity);w.push(n.position.x);w.push(n.position.y);
|
|
|
-w.push(n.position.z)}if(B.length){b.uniform1i(h.uniforms.directionalLightNumber,B.length);b.uniform3fv(h.uniforms.directionalLightDirection,w);b.uniform3fv(h.uniforms.directionalLightColor,p)}p=[];w=[];l=0;for(r=L.length;l<r;l++){n=L[l];p.push(n.color.r*n.intensity);p.push(n.color.g*n.intensity);p.push(n.color.b*n.intensity);w.push(n.position.x);w.push(n.position.y);w.push(n.position.z)}if(L.length){b.uniform1i(h.uniforms.pointLightNumber,L.length);b.uniform3fv(h.uniforms.pointLightPosition,w);b.uniform3fv(h.uniforms.pointLightColor,
|
|
|
-p)}};this.createBuffers=function(h,e){var l,r,n,p,w,C,L,B,U=[],F=[],E=[],V=[],T=[],J=0,A=h.materialFaceGroup[e],Q;n=false;l=0;for(r=h.material.length;l<r;l++){meshMaterial=h.material[l];if(meshMaterial instanceof THREE.MeshFaceMaterial){w=0;for(Q=A.material.length;w<Q;w++)if(A.material[w]&&A.material[w].shading!=undefined&&A.material[w].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}Q=
|
|
|
-n;l=0;for(r=A.faces.length;l<r;l++){n=A.faces[l];p=h.geometry.faces[n];w=p.vertexNormals;faceNormal=p.normal;n=h.geometry.uvs[n];if(p instanceof THREE.Face3){C=h.geometry.vertices[p.a].position;L=h.geometry.vertices[p.b].position;B=h.geometry.vertices[p.c].position;E.push(C.x,C.y,C.z);E.push(L.x,L.y,L.z);E.push(B.x,B.y,B.z);if(w.length==3&&Q)for(p=0;p<3;p++)V.push(w[p].x,w[p].y,w[p].z);else for(p=0;p<3;p++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(p=0;p<3;p++)T.push(n[p].u,n[p].v);U.push(J,
|
|
|
-J+1,J+2);F.push(J,J+1);F.push(J,J+2);F.push(J+1,J+2);J+=3}else if(p instanceof THREE.Face4){C=h.geometry.vertices[p.a].position;L=h.geometry.vertices[p.b].position;B=h.geometry.vertices[p.c].position;p=h.geometry.vertices[p.d].position;E.push(C.x,C.y,C.z);E.push(L.x,L.y,L.z);E.push(B.x,B.y,B.z);E.push(p.x,p.y,p.z);if(w.length==4&&Q)for(p=0;p<4;p++)V.push(w[p].x,w[p].y,w[p].z);else for(p=0;p<4;p++)V.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(p=0;p<4;p++)T.push(n[p].u,n[p].v);U.push(J,J+
|
|
|
-1,J+2);U.push(J,J+2,J+3);F.push(J,J+1);F.push(J,J+2);F.push(J,J+3);F.push(J+1,J+2);F.push(J+2,J+3);J+=4}}if(E.length){A.__webGLVertexBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,A.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(E),b.STATIC_DRAW);A.__webGLNormalBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,A.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,new Float32Array(V),b.STATIC_DRAW);A.__webGLUVBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,A.__webGLUVBuffer);
|
|
|
-b.bufferData(b.ARRAY_BUFFER,new Float32Array(T),b.STATIC_DRAW);A.__webGLFaceBuffer=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,new Uint16Array(U),b.STATIC_DRAW);A.__webGLLineBuffer=b.createBuffer();b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,new Uint16Array(F),b.STATIC_DRAW);A.__webGLFaceCount=U.length;A.__webGLLineCount=F.length}};this.renderBuffer=function(h,e,l){var r,n,p,w,C,L,B,
|
|
|
-U,F,E;if(e instanceof THREE.MeshShaderMaterial){if(!e.program){e.program=c(e.fragment_shader,e.vertex_shader);C=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in e.uniforms)C.push(E);d(e.program,C);f(e.program)}E=e.program}else E=j;if(E!=x){b.useProgram(E);x=E}if(e instanceof THREE.MeshShaderMaterial){C=E;U=e.uniforms;var V,T;for(n in U){V=U[n].type;F=U[n].value;T=C.uniforms[n];if(V=="i")b.uniform1i(T,F);else if(V=="f")b.uniform1f(T,F);else if(V==
|
|
|
-"t"){b.uniform1i(T,F);F=U[n].texture;if(F instanceof THREE.TextureCube&&F.image.length==6){if(!F.image.__webGLTextureCube&&!F.image.__cubeMapInitialized&&F.image.loadCount==6){F.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,F.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,
|
|
|
-b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(V=0;V<6;++V)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,F.image[V]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);F.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_CUBE_MAP,F.image.__webGLTextureCube)}}}this.loadCamera(E,h);this.loadMatrices(E)}else if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){h=
|
|
|
-e.color;r=e.opacity;p=e.wireframe;w=e.wireframe_linewidth;L=e.map;B=e.env_map;C=e.combine==THREE.Mix;n=e.reflectivity;F=e.env_map&&e.env_map.mapping==THREE.RefractionMapping;U=e.refraction_ratio;b.uniform4f(E.uniforms.mColor,h.r*r,h.g*r,h.b*r,r);b.uniform1i(E.uniforms.mixEnvMap,C);b.uniform1f(E.uniforms.mReflectivity,n);b.uniform1i(E.uniforms.useRefract,F);b.uniform1f(E.uniforms.mRefractionRatio,U)}if(e instanceof THREE.MeshNormalMaterial){r=e.opacity;b.uniform1f(E.uniforms.mOpacity,r);b.uniform1i(E.uniforms.material,
|
|
|
-4)}else if(e instanceof THREE.MeshDepthMaterial){r=e.opacity;p=e.wireframe;w=e.wireframe_linewidth;b.uniform1f(E.uniforms.mOpacity,r);b.uniform1f(E.uniforms.m2Near,e.__2near);b.uniform1f(E.uniforms.mFarPlusNear,e.__farPlusNear);b.uniform1f(E.uniforms.mFarMinusNear,e.__farMinusNear);b.uniform1i(E.uniforms.material,3)}else if(e instanceof THREE.MeshPhongMaterial){h=e.ambient;n=e.specular;C=e.shininess;b.uniform4f(E.uniforms.mAmbient,h.r,h.g,h.b,r);b.uniform4f(E.uniforms.mSpecular,n.r,n.g,n.b,r);b.uniform1f(E.uniforms.mShininess,
|
|
|
-C);b.uniform1i(E.uniforms.material,2)}else if(e instanceof THREE.MeshLambertMaterial)b.uniform1i(E.uniforms.material,1);else if(e instanceof THREE.MeshBasicMaterial)b.uniform1i(E.uniforms.material,0);else if(e instanceof THREE.MeshCubeMaterial){b.uniform1i(E.uniforms.material,5);B=e.env_map}if(L){if(!e.map.__webGLTexture&&e.map.image.loaded){e.map.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,e.map.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.map.image);
|
|
|
-b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,i(e.map.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,i(e.map.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,e.map.__webGLTexture);b.uniform1i(E.uniforms.tMap,0);b.uniform1i(E.uniforms.enableMap,1)}else b.uniform1i(E.uniforms.enableMap,
|
|
|
-0);if(B){if(e.env_map&&e.env_map instanceof THREE.TextureCube&&e.env_map.image.length==6){if(!e.env_map.image.__webGLTextureCube&&!e.env_map.image.__cubeMapInitialized&&e.env_map.image.loadCount==6){e.env_map.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,e.env_map.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,
|
|
|
-b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(r=0;r<6;++r)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,e.env_map.image[r]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);e.env_map.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_CUBE_MAP,e.env_map.image.__webGLTextureCube);b.uniform1i(E.uniforms.tCube,1)}b.uniform1i(E.uniforms.enableCubeMap,1)}else b.uniform1i(E.uniforms.enableCubeMap,
|
|
|
-0);b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.vertexAttribPointer(E.position,3,b.FLOAT,false,0,0);b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);b.vertexAttribPointer(E.normal,3,b.FLOAT,false,0,0);if(L){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUVBuffer);b.enableVertexAttribArray(E.uv);b.vertexAttribPointer(E.uv,2,b.FLOAT,false,0,0)}else b.disableVertexAttribArray(E.uv);if(p){b.lineWidth(w);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.drawElements(b.LINES,l.__webGLLineCount,
|
|
|
-b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,l.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(h,e,l,r,n){var p,w,C,L,B;C=0;for(L=e.material.length;C<L;C++){p=e.material[C];if(p instanceof THREE.MeshFaceMaterial){p=0;for(w=l.material.length;p<w;p++)if((B=l.material[p])&&B.blending==r&&B.opacity<1==n){this.setBlending(B.blending);this.renderBuffer(h,B,l)}}else if((B=p)&&B.blending==r&&B.opacity<1==n){this.setBlending(B.blending);
|
|
|
-this.renderBuffer(h,B,l)}}};this.render=function(h,e){var l,r;this.initWebGLObjects(h);this.autoClear&&this.clear();e.autoUpdateMatrix&&e.updateMatrix();this.loadCamera(j,e);this.setupLights(j,h);l=0;for(r=h.__webGLObjects.length;l<r;l++){webGLObject=h.__webGLObjects[l];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,e);this.loadMatrices(j);this.renderPass(e,webGLObject.__object,webGLObject,THREE.NormalBlending,false)}}l=0;for(r=h.__webGLObjects.length;l<r;l++){webGLObject=
|
|
|
-h.__webGLObjects[l];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,e);this.loadMatrices(j);this.renderPass(e,webGLObject.__object,webGLObject,THREE.AdditiveBlending,false);this.renderPass(e,webGLObject.__object,webGLObject,THREE.SubtractiveBlending,false);this.renderPass(e,webGLObject.__object,webGLObject,THREE.AdditiveBlending,true);this.renderPass(e,webGLObject.__object,webGLObject,THREE.SubtractiveBlending,true);this.renderPass(e,webGLObject.__object,webGLObject,THREE.NormalBlending,
|
|
|
-true)}}};this.initWebGLObjects=function(h){var e,l,r,n,p;if(!h.__webGLObjects)h.__webGLObjects=[];e=0;for(l=h.objects.length;e<l;e++){r=h.objects[e];if(r instanceof THREE.Mesh)for(n in r.materialFaceGroup){p=r.materialFaceGroup[n];if(!p.__webGLVertexBuffer){this.createBuffers(r,n);p.__object=r;h.__webGLObjects.push(p)}}}};this.removeObject=function(h,e){var l,r;for(l=h.__webGLObjects.length-1;l>=0;l--){r=h.__webGLObjects[l].__object;e==r&&h.__webGLObjects.splice(l,1)}};this.setupMatrices=function(h,
|
|
|
-e){h.autoUpdateMatrix&&h.updateMatrix();s.multiply(e.matrix,h.matrix);o.set(e.matrix.flatten());v.set(s.flatten());u.set(e.projectionMatrix.flatten());D=THREE.Matrix4.makeInvert3x3(s).transpose();y.set(D.m);I.set(h.matrix.flatten())};this.loadMatrices=function(h){b.uniformMatrix4fv(h.uniforms.viewMatrix,false,o);b.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,v);b.uniformMatrix4fv(h.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(h.uniforms.normalMatrix,false,y);b.uniformMatrix4fv(h.uniforms.objectMatrix,
|
|
|
-false,I)};this.loadCamera=function(h,e){b.uniform3f(h.uniforms.cameraPosition,e.position.x,e.position.y,e.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(h,e){if(h){!e||e=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(h=="back")b.cullFace(b.BACK);
|
|
|
-else h=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.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,c){var d=c instanceof THREE.Mesh,f=a.vertices.length,g=d?c.geometry:c,i=a.vertices,k=g.vertices,b=a.faces,j=g.faces,x=a.uvs;g=g.uvs;d&&c.updateMatrix();for(var s=0,D=k.length;s<D;s++){var o=new THREE.Vertex(k[s].position.clone());d&&c.matrix.transformVector3(o.position);i.push(o)}s=0;for(D=j.length;s<D;s++){d=j[s];var v;k=d.vertexNormals;if(d instanceof THREE.Face3)v=new THREE.Face3(d.a+f,d.b+f,d.c+f);else if(d instanceof THREE.Face4)v=new THREE.Face4(d.a+f,d.b+
|
|
|
-f,d.c+f,d.d+f);d=0;for(i=k.length;d<i;d++){o=k[d];v.vertexNormals.push(o.clone())}b.push(v)}s=0;for(D=g.length;s<D;s++){f=g[s];b=[];d=0;for(i=f.length;d<i;d++)b.push(new THREE.UV(f[d].u,f[d].v));x.push(b)}}},ImageUtils={loadArray:function(a){var c,d,f=[];c=f.loadCount=0;for(d=a.length;c<d;++c){f[c]=new Image;f[c].loaded=0;f[c].onload=function(){f.loadCount+=1;this.loaded=1};f[c].src=a[c]}return f}},SceneUtils={addMesh:function(a,c,d,f,g,i,k,b,j,x){c=new THREE.Mesh(c,x);c.scale.x=c.scale.y=c.scale.z=
|
|
|
-d;c.position.x=f;c.position.y=g;c.position.z=i;c.rotation.x=k;c.rotation.y=b;c.rotation.z=j;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){d=new THREE.MeshCubeMaterial({env_map:d});c=new THREE.Mesh(new Cube(c,c,c,1,1,null,true),d);a.addObject(c);return c},addPanoramaCube:function(a,c,d){var f=[];f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));
|
|
|
-f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));mesh=new THREE.Mesh(new Cube(c,c,c,1,1,f,true),new THREE.MeshFaceMaterial);a.addObject(mesh);return mesh},addPanoramaCubePlanes:function(a,c,d){var f=c/2;c=new Plane(c,c);var g=Math.PI/2,i=Math.PI;SceneUtils.addMesh(a,c,1,0,0,-f,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,
|
|
|
-c,1,-f,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,f,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,c,1,0,f,0,g,0,i,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,c,1,0,-f,0,-g,0,i,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",
|
|
|
-value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
|
|
|
+s=b(y,n);c.useProgram(s);f(s,["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"]);h&&f(s,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);i&&f(s,["pointLightNumber","pointLightColor",
|
|
|
+"pointLightPosition"]);c.uniform1i(s.uniforms.enableMap,0);c.uniform1i(s.uniforms.tMap,0);c.uniform1i(s.uniforms.enableCubeMap,0);c.uniform1i(s.uniforms.tCube,1);c.uniform1i(s.uniforms.mixEnvMap,0);c.uniform1i(s.uniforms.useRefract,0);j(s)})(a.directional,a.point);this.setSize=function(h,i){m.width=h;m.height=i;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,i){var n,y,p,o,G,B=[],R=[],F=[];o=[];G=[];c.uniform1i(h.uniforms.enableLighting,
|
|
|
+i.lights.length);n=0;for(y=i.lights.length;n<y;n++){p=i.lights[n];if(p instanceof THREE.AmbientLight)B.push(p);else if(p instanceof THREE.DirectionalLight)F.push(p);else p instanceof THREE.PointLight&&R.push(p)}n=p=o=G=0;for(y=B.length;n<y;n++){p+=B[n].color.r;o+=B[n].color.g;G+=B[n].color.b}c.uniform3f(h.uniforms.ambientLightColor,p,o,G);o=[];G=[];n=0;for(y=F.length;n<y;n++){p=F[n];o.push(p.color.r*p.intensity);o.push(p.color.g*p.intensity);o.push(p.color.b*p.intensity);G.push(p.position.x);G.push(p.position.y);
|
|
|
+G.push(p.position.z)}if(F.length){c.uniform1i(h.uniforms.directionalLightNumber,F.length);c.uniform3fv(h.uniforms.directionalLightDirection,G);c.uniform3fv(h.uniforms.directionalLightColor,o)}o=[];G=[];n=0;for(y=R.length;n<y;n++){p=R[n];o.push(p.color.r*p.intensity);o.push(p.color.g*p.intensity);o.push(p.color.b*p.intensity);G.push(p.position.x);G.push(p.position.y);G.push(p.position.z)}if(R.length){c.uniform1i(h.uniforms.pointLightNumber,R.length);c.uniform3fv(h.uniforms.pointLightPosition,G);c.uniform3fv(h.uniforms.pointLightColor,
|
|
|
+o)}};this.createBuffers=function(h,i){var n,y,p,o,G,B,R,F,W=[],V=[],D=[],P=[],C=[],J=0,H=h.materialFaceGroup[i],U;p=false;n=0;for(y=h.material.length;n<y;n++){meshMaterial=h.material[n];if(meshMaterial instanceof THREE.MeshFaceMaterial){G=0;for(U=H.material.length;G<U;G++)if(H.material[G]&&H.material[G].shading!=undefined&&H.material[G].shading==THREE.SmoothShading){p=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){p=true;break}if(p)break}U=
|
|
|
+p;n=0;for(y=H.faces.length;n<y;n++){p=H.faces[n];o=h.geometry.faces[p];G=o.vertexNormals;faceNormal=o.normal;p=h.geometry.uvs[p];if(o instanceof THREE.Face3){B=h.geometry.vertices[o.a].position;R=h.geometry.vertices[o.b].position;F=h.geometry.vertices[o.c].position;D.push(B.x,B.y,B.z);D.push(R.x,R.y,R.z);D.push(F.x,F.y,F.z);if(G.length==3&&U)for(o=0;o<3;o++)P.push(G[o].x,G[o].y,G[o].z);else for(o=0;o<3;o++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(p)for(o=0;o<3;o++)C.push(p[o].u,p[o].v);W.push(J,
|
|
|
+J+1,J+2);V.push(J,J+1);V.push(J,J+2);V.push(J+1,J+2);J+=3}else if(o instanceof THREE.Face4){B=h.geometry.vertices[o.a].position;R=h.geometry.vertices[o.b].position;F=h.geometry.vertices[o.c].position;o=h.geometry.vertices[o.d].position;D.push(B.x,B.y,B.z);D.push(R.x,R.y,R.z);D.push(F.x,F.y,F.z);D.push(o.x,o.y,o.z);if(G.length==4&&U)for(o=0;o<4;o++)P.push(G[o].x,G[o].y,G[o].z);else for(o=0;o<4;o++)P.push(faceNormal.x,faceNormal.y,faceNormal.z);if(p)for(o=0;o<4;o++)C.push(p[o].u,p[o].v);W.push(J,J+
|
|
|
+1,J+2);W.push(J,J+2,J+3);V.push(J,J+1);V.push(J,J+2);V.push(J,J+3);V.push(J+1,J+2);V.push(J+2,J+3);J+=4}}if(D.length){H.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(D),c.STATIC_DRAW);H.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(P),c.STATIC_DRAW);H.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);
|
|
|
+c.bufferData(c.ARRAY_BUFFER,new Float32Array(C),c.STATIC_DRAW);H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(V),c.STATIC_DRAW);H.__webGLFaceCount=W.length;H.__webGLLineCount=V.length}};this.renderBuffer=function(h,i,n){var y,p,o,G,B,R,F,
|
|
|
+W,V,D;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);F=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in i.uniforms)F.push(D);f(i.program,F);j(i.program)}D=i.program}else D=s;if(D!=E){c.useProgram(D);E=D}if(i instanceof THREE.MeshShaderMaterial){F=D;W=i.uniforms;var P,C;for(p in W){P=W[p].type;V=W[p].value;C=F.uniforms[p];if(P=="i")c.uniform1i(C,V);else if(P=="f")c.uniform1f(C,V);else if(P==
|
|
|
+"t"){c.uniform1i(C,V);P=W[p].texture;if(P instanceof THREE.TextureCube)d(P,V);else P instanceof THREE.Texture&&e(P,V)}}this.loadCamera(D,h);this.loadMatrices(D)}else if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){h=i.color;y=i.opacity;o=i.wireframe;G=i.wireframe_linewidth;B=i.map;R=i.env_map;F=i.combine==THREE.Mix;p=i.reflectivity;V=i.env_map&&i.env_map.mapping==THREE.RefractionMapping;W=i.refraction_ratio;c.uniform4f(D.uniforms.mColor,
|
|
|
+h.r*y,h.g*y,h.b*y,y);c.uniform1i(D.uniforms.mixEnvMap,F);c.uniform1f(D.uniforms.mReflectivity,p);c.uniform1i(D.uniforms.useRefract,V);c.uniform1f(D.uniforms.mRefractionRatio,W)}if(i instanceof THREE.MeshNormalMaterial){y=i.opacity;c.uniform1f(D.uniforms.mOpacity,y);c.uniform1i(D.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){y=i.opacity;o=i.wireframe;G=i.wireframe_linewidth;c.uniform1f(D.uniforms.mOpacity,y);c.uniform1f(D.uniforms.m2Near,i.__2near);c.uniform1f(D.uniforms.mFarPlusNear,
|
|
|
+i.__farPlusNear);c.uniform1f(D.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(D.uniforms.material,3)}else if(i instanceof THREE.MeshPhongMaterial){h=i.ambient;p=i.specular;i=i.shininess;c.uniform4f(D.uniforms.mAmbient,h.r,h.g,h.b,y);c.uniform4f(D.uniforms.mSpecular,p.r,p.g,p.b,y);c.uniform1f(D.uniforms.mShininess,i);c.uniform1i(D.uniforms.material,2)}else if(i instanceof THREE.MeshLambertMaterial)c.uniform1i(D.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(D.uniforms.material,
|
|
|
+0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(D.uniforms.material,5);R=i.env_map}if(B){e(B,0);c.uniform1i(D.uniforms.tMap,0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(R){d(R,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(D.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);
|
|
|
+c.vertexAttribPointer(D.normal,3,c.FLOAT,false,0,0);if(B){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.enableVertexAttribArray(D.uv);c.vertexAttribPointer(D.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(D.uv);if(o){c.lineWidth(G);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(h,i,n,y,p){var o,G,B,R,F;B=0;for(R=i.material.length;B<R;B++){o=i.material[B];if(o instanceof THREE.MeshFaceMaterial){o=0;for(G=n.material.length;o<G;o++)if((F=n.material[o])&&F.blending==y&&F.opacity<1==p){this.setBlending(F.blending);this.renderBuffer(h,F,n)}}else if((F=o)&&F.blending==y&&F.opacity<1==p){this.setBlending(F.blending);this.renderBuffer(h,F,n)}}};this.render=function(h,i){var n,y;this.initWebGLObjects(h);this.autoClear&&this.clear();i.autoUpdateMatrix&&i.updateMatrix();this.loadCamera(s,
|
|
|
+i);this.setupLights(s,h);n=0;for(y=h.__webGLObjects.length;n<y;n++){webGLObject=h.__webGLObjects[n];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,i);this.loadMatrices(s);this.renderPass(i,webGLObject.__object,webGLObject,THREE.NormalBlending,false)}}n=0;for(y=h.__webGLObjects.length;n<y;n++){webGLObject=h.__webGLObjects[n];if(webGLObject.__object.visible){this.setupMatrices(webGLObject.__object,i);this.loadMatrices(s);this.renderPass(i,webGLObject.__object,webGLObject,THREE.AdditiveBlending,
|
|
|
+false);this.renderPass(i,webGLObject.__object,webGLObject,THREE.SubtractiveBlending,false);this.renderPass(i,webGLObject.__object,webGLObject,THREE.AdditiveBlending,true);this.renderPass(i,webGLObject.__object,webGLObject,THREE.SubtractiveBlending,true);this.renderPass(i,webGLObject.__object,webGLObject,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(h){var i,n,y,p,o;if(!h.__webGLObjects)h.__webGLObjects=[];i=0;for(n=h.objects.length;i<n;i++){y=h.objects[i];if(y instanceof THREE.Mesh)for(p in y.materialFaceGroup){o=
|
|
|
+y.materialFaceGroup[p];if(!o.__webGLVertexBuffer){this.createBuffers(y,p);o.__object=y;h.__webGLObjects.push(o)}}}};this.removeObject=function(h,i){var n,y;for(n=h.__webGLObjects.length-1;n>=0;n--){y=h.__webGLObjects[n].__object;i==y&&h.__webGLObjects.splice(n,1)}};this.setupMatrices=function(h,i){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(i.matrix,h.matrix);v.set(i.matrix.flatten());x.set(r.flatten());L.set(i.projectionMatrix.flatten());w=THREE.Matrix4.makeInvert3x3(r).transpose();u.set(w.m);
|
|
|
+A.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,L);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,u);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,A)};this.loadCamera=function(h,i){c.uniform3f(h.uniforms.cameraPosition,i.position.x,i.position.y,i.position.z)};this.setBlending=function(h){switch(h){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(h,i){if(h){!i||i=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="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,m=f.faces,c=a.uvs;f=f.uvs;d&&b.updateMatrix();for(var s=0,E=k.length;s<E;s++){var r=new THREE.Vertex(k[s].position.clone());d&&b.matrix.transformVector3(r.position);j.push(r)}s=0;for(E=m.length;s<E;s++){d=m[s];var w;k=d.vertexNormals;if(d instanceof THREE.Face3)w=new THREE.Face3(d.a+e,d.b+e,d.c+e);else if(d instanceof THREE.Face4)w=new THREE.Face4(d.a+e,d.b+
|
|
|
+e,d.c+e,d.d+e);d=0;for(j=k.length;d<j;d++){r=k[d];w.vertexNormals.push(r.clone())}g.push(w)}s=0;for(E=f.length;s<E;s++){e=f[s];g=[];d=0;for(j=e.length;d<j;d++)g.push(new THREE.UV(e[d].u,e[d].v));c.push(g)}}},ImageUtils={loadTexture:function(a,b){var d=new THREE.Texture(null,b),e=new Image;e.onload=function(){d.image=this;d.loaded=true};e.src=a;return d},loadArray:function(a){var b,d,e=[];b=e.loadCount=0;for(d=a.length;b<d;++b){e[b]=new Image;e[b].loaded=0;e[b].onload=function(){e.loadCount+=1;this.loaded=
|
|
|
+1};e[b].src=a[b]}return e}},SceneUtils={addMesh:function(a,b,d,e,f,j,k,g,m,c){b=new THREE.Mesh(b,c);b.scale.x=b.scale.y=b.scale.z=d;b.position.x=e;b.position.y=f;b.position.z=j;b.rotation.x=k;b.rotation.y=g;b.rotation.z=m;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,d){d=new THREE.MeshCubeMaterial({env_map:d});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,true),d);a.addObject(b);return b},addPanoramaCube:function(a,b,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));
|
|
|
+e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));mesh=new THREE.Mesh(new Cube(b,b,b,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(mesh);return mesh},addPanoramaCubePlanes:function(a,b,d){var e=b/2;b=new Plane(b,
|
|
|
+b);var f=Math.PI/2,j=Math.PI;SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,b,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,b,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,b,1,0,e,0,f,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));SceneUtils.addMesh(a,b,1,0,-e,0,-f,0,j,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},
|
|
|
+ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
|
|
|
vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main(void) {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"}}},
|
|
|
-Cube=function(a,c,d,f,g,i,k){function b(v,u,y,I,t,h,e,l){var r=f||1,n=g||1,p=r+1,w=n+1;t=t/r;h=h/n;var C=j.vertices.length,L;if(v=="x"&&u=="y"||v=="y"&&u=="x")L="z";else if(v=="x"&&u=="z"||v=="z"&&u=="x")L="y";else if(v=="z"&&u=="y"||v=="y"&&u=="z")L="x";for(iy=0;iy<w;iy++)for(ix=0;ix<p;ix++){var B=new THREE.Vector3;B[v]=(ix*t-x)*y;B[u]=(iy*h-s)*I;B[L]=e;j.vertices.push(new THREE.Vertex(B))}for(iy=0;iy<n;iy++)for(ix=0;ix<r;ix++){j.faces.push(new THREE.Face4(ix+p*iy+C,ix+p*(iy+1)+C,ix+1+p*(iy+1)+C,
|
|
|
-ix+1+p*iy+C,null,l));j.uvs.push([new THREE.UV(ix/r,iy/n),new THREE.UV(ix/r,(iy+1)/n),new THREE.UV((ix+1)/r,(iy+1)/n),new THREE.UV((ix+1)/r,iy/n)])}}THREE.Geometry.call(this);var j=this,x=a/2,s=c/2,D=d/2;k=k?-1:1;if(i!==undefined)if(i instanceof Array)this.materials=i;else{this.materials=[];for(var o=0;o<6;o++)this.materials.push([i])}else this.materials=[];b("z","y",1*k,-1,d,c,-x,this.materials[0]);b("z","y",-1*k,-1,d,c,x,this.materials[1]);b("x","z",1*k,1,a,d,s,this.materials[2]);b("x","z",1*k,-1,
|
|
|
-a,d,-s,this.materials[3]);b("x","y",1*k,-1,a,c,D,this.materials[4]);b("x","y",-1*k,-1,a,c,-D,this.materials[5]);(function(){for(var v=[],u=[],y=0,I=j.vertices.length;y<I;y++){for(var t=j.vertices[y],h=false,e=0,l=v.length;e<l;e++){var r=v[e];if(t.position.x==r.position.x&&t.position.y==r.position.y&&t.position.z==r.position.z){u[y]=e;h=true;break}}if(!h){u[y]=v.length;v.push(new THREE.Vertex(t.position.clone()))}}y=0;for(I=j.faces.length;y<I;y++){t=j.faces[y];t.a=u[t.a];t.b=u[t.b];t.c=u[t.c];t.d=
|
|
|
-u[t.d]}j.vertices=v})();this.computeCentroids();this.computeNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
|
|
-var Cylinder=function(a,c,d,f,g){function i(j,x,s){k.vertices.push(new THREE.Vertex(new THREE.Vector3(j,x,s)))}THREE.Geometry.call(this);var k=this,b;for(b=0;b<a;b++)i(Math.sin(6.283*b/a)*c,Math.cos(6.283*b/a)*c,0);for(b=0;b<a;b++)i(Math.sin(6.283*b/a)*d,Math.cos(6.283*b/a)*d,f);for(b=0;b<a;b++)k.faces.push(new THREE.Face4(b,b+a,a+(b+1)%a,(b+1)%a));if(d!=0){i(0,0,-g);for(b=a;b<a+a/2;b++)k.faces.push(new THREE.Face4(2*a,(2*b-2*a)%a,(2*b-2*a+1)%a,(2*b-2*a+2)%a))}if(c!=0){i(0,0,f+g);for(b=a+a/2;b<2*
|
|
|
-a;b++)k.faces.push(new THREE.Face4((2*b-2*a+2)%a+a,(2*b-2*a+1)%a+a,(2*b-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
|
|
-var Plane=function(a,c,d,f){THREE.Geometry.call(this);var g,i=a/2,k=c/2;d=d||1;f=f||1;var b=d+1,j=f+1;a=a/d;var x=c/f;for(g=0;g<j;g++)for(c=0;c<b;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-i,-(g*x-k),0)));for(g=0;g<f;g++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+b*g,c+b*(g+1),c+1+b*(g+1),c+1+b*g));this.uvs.push([new THREE.UV(c/d,g/f),new THREE.UV(c/d,(g+1)/f),new THREE.UV((c+1)/d,(g+1)/f),new THREE.UV((c+1)/d,g/f)])}this.computeCentroids();this.computeNormals()};
|
|
|
+Cube=function(a,b,d,e,f,j,k){function g(w,v,x,L,u,A,l,h){var i=e||1,n=f||1,y=i+1,p=n+1;u=u/i;A=A/n;var o=m.vertices.length,G;if(w=="x"&&v=="y"||w=="y"&&v=="x")G="z";else if(w=="x"&&v=="z"||w=="z"&&v=="x")G="y";else if(w=="z"&&v=="y"||w=="y"&&v=="z")G="x";for(iy=0;iy<p;iy++)for(ix=0;ix<y;ix++){var B=new THREE.Vector3;B[w]=(ix*u-c)*x;B[v]=(iy*A-s)*L;B[G]=l;m.vertices.push(new THREE.Vertex(B))}for(iy=0;iy<n;iy++)for(ix=0;ix<i;ix++){m.faces.push(new THREE.Face4(ix+y*iy+o,ix+y*(iy+1)+o,ix+1+y*(iy+1)+o,
|
|
|
+ix+1+y*iy+o,null,h));m.uvs.push([new THREE.UV(ix/i,iy/n),new THREE.UV(ix/i,(iy+1)/n),new THREE.UV((ix+1)/i,(iy+1)/n),new THREE.UV((ix+1)/i,iy/n)])}}THREE.Geometry.call(this);var m=this,c=a/2,s=b/2,E=d/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var r=0;r<6;r++)this.materials.push([j])}else this.materials=[];g("z","y",1*k,-1,d,b,-c,this.materials[0]);g("z","y",-1*k,-1,d,b,c,this.materials[1]);g("x","z",1*k,1,a,d,s,this.materials[2]);g("x","z",1*k,-1,
|
|
|
+a,d,-s,this.materials[3]);g("x","y",1*k,-1,a,b,E,this.materials[4]);g("x","y",-1*k,-1,a,b,-E,this.materials[5]);(function(){for(var w=[],v=[],x=0,L=m.vertices.length;x<L;x++){for(var u=m.vertices[x],A=false,l=0,h=w.length;l<h;l++){var i=w[l];if(u.position.x==i.position.x&&u.position.y==i.position.y&&u.position.z==i.position.z){v[x]=l;A=true;break}}if(!A){v[x]=w.length;w.push(new THREE.Vertex(u.position.clone()))}}x=0;for(L=m.faces.length;x<L;x++){u=m.faces[x];u.a=v[u.a];u.b=v[u.b];u.c=v[u.c];u.d=
|
|
|
+v[u.d]}m.vertices=w})();this.computeCentroids();this.computeNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
|
|
+var Cylinder=function(a,b,d,e,f){function j(m,c,s){k.vertices.push(new THREE.Vertex(new THREE.Vector3(m,c,s)))}THREE.Geometry.call(this);var k=this,g;for(g=0;g<a;g++)j(Math.sin(6.283*g/a)*b,Math.cos(6.283*g/a)*b,0);for(g=0;g<a;g++)j(Math.sin(6.283*g/a)*d,Math.cos(6.283*g/a)*d,e);for(g=0;g<a;g++)k.faces.push(new THREE.Face4(g,g+a,a+(g+1)%a,(g+1)%a));if(d!=0){j(0,0,-f);for(g=a;g<a+a/2;g++)k.faces.push(new THREE.Face4(2*a,(2*g-2*a)%a,(2*g-2*a+1)%a,(2*g-2*a+2)%a))}if(b!=0){j(0,0,e+f);for(g=a+a/2;g<2*
|
|
|
+a;g++)k.faces.push(new THREE.Face4((2*g-2*a+2)%a+a,(2*g-2*a+1)%a+a,(2*g-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
|
|
+var Plane=function(a,b,d,e){THREE.Geometry.call(this);var f,j=a/2,k=b/2;d=d||1;e=e||1;var g=d+1,m=e+1;a=a/d;var c=b/e;for(f=0;f<m;f++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-j,-(f*c-k),0)));for(f=0;f<e;f++)for(b=0;b<d;b++){this.faces.push(new THREE.Face4(b+g*f,b+g*(f+1),b+1+g*(f+1),b+1+g*f));this.uvs.push([new THREE.UV(b/d,f/e),new THREE.UV(b/d,(f+1)/e),new THREE.UV((b+1)/d,(f+1)/e),new THREE.UV((b+1)/d,f/e)])}this.computeCentroids();this.computeNormals()};
|
|
|
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
|
|
-var Sphere=function(a,c,d){THREE.Geometry.call(this);var f,g=Math.max(3,c||8),i=Math.max(2,d||6);c=[];for(d=0;d<i+1;d++){f=d/i;var k=a*Math.cos(f*Math.PI),b=a*Math.sin(f*Math.PI),j=[],x=0;for(f=0;f<g;f++){var s=2*f/g,D=b*Math.sin(s*Math.PI);s=b*Math.cos(s*Math.PI);(d==0||d==i)&&f>0||(x=this.vertices.push(new THREE.Vertex(new THREE.Vector3(s,k,D)))-1);j.push(x)}c.push(j)}var o,v,u;a=c.length;for(d=0;d<a;d++){g=c[d].length;if(d>0)for(f=0;f<g;f++){j=f==g-1;i=c[d][j?0:f+1];k=c[d][j?g-1:f];b=c[d-1][j?
|
|
|
-g-1:f];j=c[d-1][j?0:f+1];D=d/(a-1);o=(d-1)/(a-1);v=(f+1)/g;s=f/g;x=new THREE.UV(1-v,D);D=new THREE.UV(1-s,D);s=new THREE.UV(1-s,o);var y=new THREE.UV(1-v,o);if(d<c.length-1){o=this.vertices[i].position.clone();v=this.vertices[k].position.clone();u=this.vertices[b].position.clone();o.normalize();v.normalize();u.normalize();this.faces.push(new THREE.Face3(i,k,b,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(u.x,u.y,u.z)]));this.uvs.push([x,D,s])}if(d>1){o=this.vertices[i].position.clone();
|
|
|
-v=this.vertices[b].position.clone();u=this.vertices[j].position.clone();o.normalize();v.normalize();u.normalize();this.faces.push(new THREE.Face3(i,b,j,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(u.x,u.y,u.z)]));this.uvs.push([x,s,y])}}}this.computeCentroids();this.computeNormals()};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 c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
|
|
|
-c},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="text/javascript";d.onload=c;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a,c,d){var f=(new Date).getTime();a=new Worker(a);a.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,c,d)};a.postMessage(f)},loadBinary:function(a,c,d){var f=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(i){THREE.Loader.prototype.loadAjaxBuffers(i.data.buffers,
|
|
|
-i.data.materials,c,d,g)};a.onerror=function(i){alert("worker.onerror: "+i.message+"\n"+i.data);i.preventDefault()};a.postMessage(f)},loadAjaxBuffers:function(a,c,d,f,g){var i=new XMLHttpRequest,k=f+"/"+a,b=0;i.onreadystatechange=function(){if(i.readyState==4)i.status==200||i.status==0?THREE.Loader.prototype.createBinModel(i.responseText,d,f,c):alert("Couldn't load ["+k+"] ["+i.status+"]");else if(i.readyState==3){if(g){if(b==0)b=i.getResponseHeader("Content-Length");g({total:b,loaded:i.responseText.length})}}else if(i.readyState==
|
|
|
-2)b=i.getResponseHeader("Content-Length")};i.open("GET",k,true);i.overrideMimeType("text/plain; charset=x-user-defined");i.setRequestHeader("Content-Type","text/plain");i.send(null)},createBinModel:function(a,c,d,f){var g=function(i){function k(m,q){var z=s(m,q),G=s(m,q+1),P=s(m,q+2),fa=s(m,q+3),ea=(fa<<1&255|P>>7)-127;z=(P&127)<<16|G<<8|z;if(z==0&&ea==-127)return 0;return(1-2*(fa>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ea)}function b(m,q){var z=s(m,q),G=s(m,q+1),P=s(m,q+2);return(s(m,q+3)<<24)+(P<<
|
|
|
-16)+(G<<8)+z}function j(m,q){var z=s(m,q);return(s(m,q+1)<<8)+z}function x(m,q){var z=s(m,q);return z>127?z-256:z}function s(m,q){return m.charCodeAt(q)&255}function D(m){var q,z,G;q=b(a,m);z=b(a,m+n);G=b(a,m+p);m=j(a,m+w);THREE.Loader.prototype.f3(t,q,z,G,m)}function o(m){var q,z,G,P,fa,ea;q=b(a,m);z=b(a,m+n);G=b(a,m+p);P=j(a,m+w);fa=b(a,m+C);ea=b(a,m+L);m=b(a,m+B);THREE.Loader.prototype.f3n(t,l,q,z,G,P,fa,ea,m)}function v(m){var q,z,G,P;q=b(a,m);z=b(a,m+U);G=b(a,m+F);P=b(a,m+E);m=j(a,m+V);THREE.Loader.prototype.f4(t,
|
|
|
-q,z,G,P,m)}function u(m){var q,z,G,P,fa,ea,ga,la;q=b(a,m);z=b(a,m+U);G=b(a,m+F);P=b(a,m+E);fa=j(a,m+V);ea=b(a,m+T);ga=b(a,m+J);la=b(a,m+A);m=b(a,m+Q);THREE.Loader.prototype.f4n(t,l,q,z,G,P,fa,ea,ga,la,m)}function y(m){var q,z;q=b(a,m);z=b(a,m+N);m=b(a,m+W);THREE.Loader.prototype.uv3(t,r[q*2],r[q*2+1],r[z*2],r[z*2+1],r[m*2],r[m*2+1])}function I(m){var q,z,G;q=b(a,m);z=b(a,m+M);G=b(a,m+K);m=b(a,m+Y);THREE.Loader.prototype.uv4(t,r[q*2],r[q*2+1],r[z*2],r[z*2+1],r[G*2],r[G*2+1],r[m*2],r[m*2+1])}var t=
|
|
|
-this,h=0,e,l=[],r=[],n,p,w,C,L,B,U,F,E,V,T,J,A,Q,N,W,M,K,Y;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t,f,i);e={signature:a.substr(h,8),header_bytes:s(a,h+8),vertex_coordinate_bytes:s(a,h+9),normal_coordinate_bytes:s(a,h+10),uv_coordinate_bytes:s(a,h+11),vertex_index_bytes:s(a,h+12),normal_index_bytes:s(a,h+13),uv_index_bytes:s(a,h+14),material_index_bytes:s(a,h+15),nvertices:b(a,h+16),nnormals:b(a,h+16+4),nuvs:b(a,h+16+8),ntri_flat:b(a,h+16+12),ntri_smooth:b(a,h+16+16),ntri_flat_uv:b(a,
|
|
|
-h+16+20),ntri_smooth_uv:b(a,h+16+24),nquad_flat:b(a,h+16+28),nquad_smooth:b(a,h+16+32),nquad_flat_uv:b(a,h+16+36),nquad_smooth_uv:b(a,h+16+40)};h+=e.header_bytes;n=e.vertex_index_bytes;p=e.vertex_index_bytes*2;w=e.vertex_index_bytes*3;C=e.vertex_index_bytes*3+e.material_index_bytes;L=e.vertex_index_bytes*3+e.material_index_bytes+e.normal_index_bytes;B=e.vertex_index_bytes*3+e.material_index_bytes+e.normal_index_bytes*2;U=e.vertex_index_bytes;F=e.vertex_index_bytes*2;E=e.vertex_index_bytes*3;V=e.vertex_index_bytes*
|
|
|
-4;T=e.vertex_index_bytes*4+e.material_index_bytes;J=e.vertex_index_bytes*4+e.material_index_bytes+e.normal_index_bytes;A=e.vertex_index_bytes*4+e.material_index_bytes+e.normal_index_bytes*2;Q=e.vertex_index_bytes*4+e.material_index_bytes+e.normal_index_bytes*3;N=e.uv_index_bytes;W=e.uv_index_bytes*2;M=e.uv_index_bytes;K=e.uv_index_bytes*2;Y=e.uv_index_bytes*3;h+=function(m){var q,z,G,P=e.vertex_coordinate_bytes*3,fa=m+e.nvertices*P;for(m=m;m<fa;m+=P){q=k(a,m);z=k(a,m+e.vertex_coordinate_bytes);G=
|
|
|
-k(a,m+e.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(t,q,z,G)}return e.nvertices*P}(h);h+=function(m){var q,z,G,P=e.normal_coordinate_bytes*3,fa=m+e.nnormals*P;for(m=m;m<fa;m+=P){q=x(a,m);z=x(a,m+e.normal_coordinate_bytes);G=x(a,m+e.normal_coordinate_bytes*2);l.push(q/127,z/127,G/127)}return e.nnormals*P}(h);h+=function(m){var q,z,G=e.uv_coordinate_bytes*2,P=m+e.nuvs*G;for(m=m;m<P;m+=G){q=k(a,m);z=k(a,m+e.uv_coordinate_bytes);r.push(q,z)}return e.nuvs*G}(h);h+=function(m){var q,z=e.vertex_index_bytes*
|
|
|
-3+e.material_index_bytes,G=m+e.ntri_flat*z;for(q=m;q<G;q+=z)D(q);return G-m}(h);h+=function(m){var q,z=e.vertex_index_bytes*3+e.material_index_bytes+e.normal_index_bytes*3,G=m+e.ntri_smooth*z;for(q=m;q<G;q+=z)o(q);return G-m}(h);h+=function(m){var q,z=e.vertex_index_bytes*3+e.material_index_bytes,G=z+e.uv_index_bytes*3,P=m+e.ntri_flat_uv*G;for(q=m;q<P;q+=G){D(q);y(q+z)}return P-m}(h);h+=function(m){var q,z=e.vertex_index_bytes*3+e.material_index_bytes+e.normal_index_bytes*3,G=z+e.uv_index_bytes*3,
|
|
|
-P=m+e.ntri_smooth_uv*G;for(q=m;q<P;q+=G){o(q);y(q+z)}return P-m}(h);h+=function(m){var q,z=e.vertex_index_bytes*4+e.material_index_bytes,G=m+e.nquad_flat*z;for(q=m;q<G;q+=z)v(q);return G-m}(h);h+=function(m){var q,z=e.vertex_index_bytes*4+e.material_index_bytes+e.normal_index_bytes*4,G=m+e.nquad_smooth*z;for(q=m;q<G;q+=z)u(q);return G-m}(h);h+=function(m){var q,z=e.vertex_index_bytes*4+e.material_index_bytes,G=z+e.uv_index_bytes*4,P=m+e.nquad_flat_uv*G;for(q=m;q<P;q+=G){v(q);I(q+z)}return P-m}(h);
|
|
|
-h+=function(m){var q,z=e.vertex_index_bytes*4+e.material_index_bytes+e.normal_index_bytes*4,G=z+e.uv_index_bytes*4,P=m+e.nquad_smooth_uv*G;for(q=m;q<P;q+=G){u(q);I(q+z)}return P-m}(h);this.computeCentroids();this.computeNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(d))},createModel:function(a,c,d){var f=function(g){var i=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(i,a.materials,g);(function(){var k,b,j,x,s;k=0;for(b=a.vertices.length;k<b;k+=3){j=
|
|
|
-a.vertices[k];x=a.vertices[k+1];s=a.vertices[k+2];THREE.Loader.prototype.v(i,j,x,s)}})();(function(){function k(u,y){THREE.Loader.prototype.f3(i,u[y],u[y+1],u[y+2],u[y+3])}function b(u,y){THREE.Loader.prototype.f3n(i,a.normals,u[y],u[y+1],u[y+2],u[y+3],u[y+4],u[y+5],u[y+6])}function j(u,y){THREE.Loader.prototype.f4(i,u[y],u[y+1],u[y+2],u[y+3],u[y+4])}function x(u,y){THREE.Loader.prototype.f4n(i,a.normals,u[y],u[y+1],u[y+2],u[y+3],u[y+4],u[y+5],u[y+6],u[y+7],u[y+8])}function s(u,y){var I,t,h;I=u[y];
|
|
|
-t=u[y+1];h=u[y+2];THREE.Loader.prototype.uv3(i,a.uvs[I*2],a.uvs[I*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[h*2],a.uvs[h*2+1])}function D(u,y){var I,t,h,e;I=u[y];t=u[y+1];h=u[y+2];e=u[y+3];THREE.Loader.prototype.uv4(i,a.uvs[I*2],a.uvs[I*2+1],a.uvs[t*2],a.uvs[t*2+1],a.uvs[h*2],a.uvs[h*2+1],a.uvs[e*2],a.uvs[e*2+1])}var o,v;o=0;for(v=a.triangles.length;o<v;o+=4)k(a.triangles,o);o=0;for(v=a.triangles_uv.length;o<v;o+=7){k(a.triangles_uv,o);s(a.triangles_uv,o+4)}o=0;for(v=a.triangles_n.length;o<v;o+=7)b(a.triangles_n,
|
|
|
-o);o=0;for(v=a.triangles_n_uv.length;o<v;o+=10){b(a.triangles_n_uv,o);s(a.triangles_n_uv,o+7)}o=0;for(v=a.quads.length;o<v;o+=5)j(a.quads,o);o=0;for(v=a.quads_uv.length;o<v;o+=9){j(a.quads_uv,o);D(a.quads_uv,o+5)}o=0;for(v=a.quads_n.length;o<v;o+=9)x(a.quads_n,o);o=0;for(v=a.quads_n_uv.length;o<v;o+=13){x(a.quads_n_uv,o);D(a.quads_n_uv,o+9)}})();this.computeCentroids();this.computeNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},v:function(a,c,d,f){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,
|
|
|
-d,f)))},f3:function(a,c,d,f,g){a.faces.push(new THREE.Face3(c,d,f,null,a.materials[g]))},f4:function(a,c,d,f,g,i){a.faces.push(new THREE.Face4(c,d,f,g,null,a.materials[i]))},f3n:function(a,c,d,f,g,i,k,b,j){i=a.materials[i];var x=c[b*3],s=c[b*3+1];b=c[b*3+2];var D=c[j*3],o=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(d,f,g,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(x,s,b),new THREE.Vector3(D,o,j)],i))},f4n:function(a,c,d,f,g,i,k,b,j,x,s){k=a.materials[k];var D=c[j*3],o=c[j*
|
|
|
-3+1];j=c[j*3+2];var v=c[x*3],u=c[x*3+1];x=c[x*3+2];var y=c[s*3],I=c[s*3+1];s=c[s*3+2];a.faces.push(new THREE.Face4(d,f,g,i,[new THREE.Vector3(c[b*3],c[b*3+1],c[b*3+2]),new THREE.Vector3(D,o,j),new THREE.Vector3(v,u,x),new THREE.Vector3(y,I,s)],k))},uv3:function(a,c,d,f,g,i,k){var b=[];b.push(new THREE.UV(c,d));b.push(new THREE.UV(f,g));b.push(new THREE.UV(i,k));a.uvs.push(b)},uv4:function(a,c,d,f,g,i,k,b,j){var x=[];x.push(new THREE.UV(c,d));x.push(new THREE.UV(f,g));x.push(new THREE.UV(i,k));x.push(new THREE.UV(b,
|
|
|
-j));a.uvs.push(x)},init_materials:function(a,c,d){a.materials=[];for(var f=0;f<c.length;++f)a.materials[f]=[THREE.Loader.prototype.createMaterial(c[f],d)]},createMaterial:function(a,c){function d(i){i=Math.log(i)/Math.LN2;return Math.floor(i)==i}var f,g;if(a.map_diffuse&&c){g=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(g)});g=new Image;g.onload=function(){if(!d(this.width)||!d(this.height)){var i=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),k=Math.pow(2,
|
|
|
-Math.round(Math.log(this.height)/Math.LN2));f.map.image.width=i;f.map.image.height=k;f.map.image.getContext("2d").drawImage(this,0,0,i,k)}else f.map.image=this;f.map.image.loaded=1};g.src=c+"/"+a.map_diffuse}else if(a.col_diffuse){g=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f=new THREE.MeshLambertMaterial({color:g,opacity:a.transparency})}else f=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});return f}};
|
|
|
+var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,f=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d<j+1;d++){e=d/j;var k=a*Math.cos(e*Math.PI),g=a*Math.sin(e*Math.PI),m=[],c=0;for(e=0;e<f;e++){var s=2*e/f,E=g*Math.sin(s*Math.PI);s=g*Math.cos(s*Math.PI);(d==0||d==j)&&e>0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(s,k,E)))-1);m.push(c)}b.push(m)}var r,w,v;a=b.length;for(d=0;d<a;d++){f=b[d].length;if(d>0)for(e=0;e<f;e++){m=e==f-1;j=b[d][m?0:e+1];k=b[d][m?f-1:e];g=b[d-1][m?
|
|
|
+f-1:e];m=b[d-1][m?0:e+1];E=d/(a-1);r=(d-1)/(a-1);w=(e+1)/f;s=e/f;c=new THREE.UV(1-w,E);E=new THREE.UV(1-s,E);s=new THREE.UV(1-s,r);var x=new THREE.UV(1-w,r);if(d<b.length-1){r=this.vertices[j].position.clone();w=this.vertices[k].position.clone();v=this.vertices[g].position.clone();r.normalize();w.normalize();v.normalize();this.faces.push(new THREE.Face3(j,k,g,[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,E,s])}if(d>1){r=this.vertices[j].position.clone();
|
|
|
+w=this.vertices[g].position.clone();v=this.vertices[m].position.clone();r.normalize();w.normalize();v.normalize();this.faces.push(new THREE.Face3(j,g,m,[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,s,x])}}}this.computeCentroids();this.computeNormals()};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,t){var z=s(q,t),I=s(q,t+1),Q=s(q,t+2),fa=s(q,t+3),ea=(fa<<1&255|Q>>7)-127;z=(Q&127)<<16|I<<8|z;if(z==0&&ea==-127)return 0;return(1-2*(fa>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ea)}function g(q,t){var z=s(q,t),I=s(q,t+1),Q=s(q,t+2);return(s(q,t+3)<<24)+(Q<<
|
|
|
+16)+(I<<8)+z}function m(q,t){var z=s(q,t);return(s(q,t+1)<<8)+z}function c(q,t){var z=s(q,t);return z>127?z-256:z}function s(q,t){return q.charCodeAt(t)&255}function E(q){var t,z,I;t=g(a,q);z=g(a,q+n);I=g(a,q+y);q=m(a,q+p);THREE.Loader.prototype.f3(u,t,z,I,q)}function r(q){var t,z,I,Q,fa,ea;t=g(a,q);z=g(a,q+n);I=g(a,q+y);Q=m(a,q+p);fa=g(a,q+o);ea=g(a,q+G);q=g(a,q+B);THREE.Loader.prototype.f3n(u,h,t,z,I,Q,fa,ea,q)}function w(q){var t,z,I,Q;t=g(a,q);z=g(a,q+R);I=g(a,q+F);Q=g(a,q+W);q=m(a,q+V);THREE.Loader.prototype.f4(u,
|
|
|
+t,z,I,Q,q)}function v(q){var t,z,I,Q,fa,ea,ga,la;t=g(a,q);z=g(a,q+R);I=g(a,q+F);Q=g(a,q+W);fa=m(a,q+V);ea=g(a,q+D);ga=g(a,q+P);la=g(a,q+C);q=g(a,q+J);THREE.Loader.prototype.f4n(u,h,t,z,I,Q,fa,ea,ga,la,q)}function x(q){var t,z;t=g(a,q);z=g(a,q+H);q=g(a,q+U);THREE.Loader.prototype.uv3(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[q*2],i[q*2+1])}function L(q){var t,z,I;t=g(a,q);z=g(a,q+N);I=g(a,q+M);q=g(a,q+Y);THREE.Loader.prototype.uv4(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[I*2],i[I*2+1],i[q*2],i[q*2+1])}var u=
|
|
|
+this,A=0,l,h=[],i=[],n,y,p,o,G,B,R,F,W,V,D,P,C,J,H,U,N,M,Y;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,e,j);l={signature:a.substr(A,8),header_bytes:s(a,A+8),vertex_coordinate_bytes:s(a,A+9),normal_coordinate_bytes:s(a,A+10),uv_coordinate_bytes:s(a,A+11),vertex_index_bytes:s(a,A+12),normal_index_bytes:s(a,A+13),uv_index_bytes:s(a,A+14),material_index_bytes:s(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+=l.header_bytes;n=l.vertex_index_bytes;y=l.vertex_index_bytes*2;p=l.vertex_index_bytes*3;o=l.vertex_index_bytes*3+l.material_index_bytes;G=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes;B=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*2;R=l.vertex_index_bytes;F=l.vertex_index_bytes*2;W=l.vertex_index_bytes*3;V=l.vertex_index_bytes*
|
|
|
+4;D=l.vertex_index_bytes*4+l.material_index_bytes;P=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes;C=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*2;J=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*3;H=l.uv_index_bytes;U=l.uv_index_bytes*2;N=l.uv_index_bytes;M=l.uv_index_bytes*2;Y=l.uv_index_bytes*3;A+=function(q){var t,z,I,Q=l.vertex_coordinate_bytes*3,fa=q+l.nvertices*Q;for(q=q;q<fa;q+=Q){t=k(a,q);z=k(a,q+l.vertex_coordinate_bytes);I=
|
|
|
+k(a,q+l.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(u,t,z,I)}return l.nvertices*Q}(A);A+=function(q){var t,z,I,Q=l.normal_coordinate_bytes*3,fa=q+l.nnormals*Q;for(q=q;q<fa;q+=Q){t=c(a,q);z=c(a,q+l.normal_coordinate_bytes);I=c(a,q+l.normal_coordinate_bytes*2);h.push(t/127,z/127,I/127)}return l.nnormals*Q}(A);A+=function(q){var t,z,I=l.uv_coordinate_bytes*2,Q=q+l.nuvs*I;for(q=q;q<Q;q+=I){t=k(a,q);z=k(a,q+l.uv_coordinate_bytes);i.push(t,z)}return l.nuvs*I}(A);A+=function(q){var t,z=l.vertex_index_bytes*
|
|
|
+3+l.material_index_bytes,I=q+l.ntri_flat*z;for(t=q;t<I;t+=z)E(t);return I-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,I=q+l.ntri_smooth*z;for(t=q;t<I;t+=z)r(t);return I-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*3+l.material_index_bytes,I=z+l.uv_index_bytes*3,Q=q+l.ntri_flat_uv*I;for(t=q;t<Q;t+=I){E(t);x(t+z)}return Q-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,I=z+l.uv_index_bytes*3,
|
|
|
+Q=q+l.ntri_smooth_uv*I;for(t=q;t<Q;t+=I){r(t);x(t+z)}return Q-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes,I=q+l.nquad_flat*z;for(t=q;t<I;t+=z)w(t);return I-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,I=q+l.nquad_smooth*z;for(t=q;t<I;t+=z)v(t);return I-q}(A);A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes,I=z+l.uv_index_bytes*4,Q=q+l.nquad_flat_uv*I;for(t=q;t<Q;t+=I){w(t);L(t+z)}return Q-q}(A);
|
|
|
+A+=function(q){var t,z=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,I=z+l.uv_index_bytes*4,Q=q+l.nquad_smooth_uv*I;for(t=q;t<Q;t+=I){v(t);L(t+z)}return Q-q}(A);this.computeCentroids();this.computeNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(d))},createModel:function(a,b,d){var e=function(f){var j=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(j,a.materials,f);(function(){var k,g,m,c,s;k=0;for(g=a.vertices.length;k<g;k+=3){m=
|
|
|
+a.vertices[k];c=a.vertices[k+1];s=a.vertices[k+2];THREE.Loader.prototype.v(j,m,c,s)}})();(function(){function k(v,x){THREE.Loader.prototype.f3(j,v[x],v[x+1],v[x+2],v[x+3])}function g(v,x){THREE.Loader.prototype.f3n(j,a.normals,v[x],v[x+1],v[x+2],v[x+3],v[x+4],v[x+5],v[x+6])}function m(v,x){THREE.Loader.prototype.f4(j,v[x],v[x+1],v[x+2],v[x+3],v[x+4])}function c(v,x){THREE.Loader.prototype.f4n(j,a.normals,v[x],v[x+1],v[x+2],v[x+3],v[x+4],v[x+5],v[x+6],v[x+7],v[x+8])}function s(v,x){var L,u,A;L=v[x];
|
|
|
+u=v[x+1];A=v[x+2];THREE.Loader.prototype.uv3(j,a.uvs[L*2],a.uvs[L*2+1],a.uvs[u*2],a.uvs[u*2+1],a.uvs[A*2],a.uvs[A*2+1])}function E(v,x){var L,u,A,l;L=v[x];u=v[x+1];A=v[x+2];l=v[x+3];THREE.Loader.prototype.uv4(j,a.uvs[L*2],a.uvs[L*2+1],a.uvs[u*2],a.uvs[u*2+1],a.uvs[A*2],a.uvs[A*2+1],a.uvs[l*2],a.uvs[l*2+1])}var r,w;r=0;for(w=a.triangles.length;r<w;r+=4)k(a.triangles,r);r=0;for(w=a.triangles_uv.length;r<w;r+=7){k(a.triangles_uv,r);s(a.triangles_uv,r+4)}r=0;for(w=a.triangles_n.length;r<w;r+=7)g(a.triangles_n,
|
|
|
+r);r=0;for(w=a.triangles_n_uv.length;r<w;r+=10){g(a.triangles_n_uv,r);s(a.triangles_n_uv,r+7)}r=0;for(w=a.quads.length;r<w;r+=5)m(a.quads,r);r=0;for(w=a.quads_uv.length;r<w;r+=9){m(a.quads_uv,r);E(a.quads_uv,r+5)}r=0;for(w=a.quads_n.length;r<w;r+=9)c(a.quads_n,r);r=0;for(w=a.quads_n_uv.length;r<w;r+=13){c(a.quads_n_uv,r);E(a.quads_n_uv,r+9)}})();this.computeCentroids();this.computeNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(d))},v:function(a,b,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,
|
|
|
+d,e)))},f3:function(a,b,d,e,f){a.faces.push(new THREE.Face3(b,d,e,null,a.materials[f]))},f4:function(a,b,d,e,f,j){a.faces.push(new THREE.Face4(b,d,e,f,null,a.materials[j]))},f3n:function(a,b,d,e,f,j,k,g,m){j=a.materials[j];var c=b[g*3],s=b[g*3+1];g=b[g*3+2];var E=b[m*3],r=b[m*3+1];m=b[m*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(c,s,g),new THREE.Vector3(E,r,m)],j))},f4n:function(a,b,d,e,f,j,k,g,m,c,s){k=a.materials[k];var E=b[m*3],r=b[m*
|
|
|
+3+1];m=b[m*3+2];var w=b[c*3],v=b[c*3+1];c=b[c*3+2];var x=b[s*3],L=b[s*3+1];s=b[s*3+2];a.faces.push(new THREE.Face4(d,e,f,j,[new THREE.Vector3(b[g*3],b[g*3+1],b[g*3+2]),new THREE.Vector3(E,r,m),new THREE.Vector3(w,v,c),new THREE.Vector3(x,L,s)],k))},uv3:function(a,b,d,e,f,j,k){var g=[];g.push(new THREE.UV(b,d));g.push(new THREE.UV(e,f));g.push(new THREE.UV(j,k));a.uvs.push(g)},uv4:function(a,b,d,e,f,j,k,g,m){var c=[];c.push(new THREE.UV(b,d));c.push(new THREE.UV(e,f));c.push(new THREE.UV(j,k));c.push(new THREE.UV(g,
|
|
|
+m));a.uvs.push(c)},init_materials:function(a,b,d){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],d)]},createMaterial:function(a,b){function d(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}var e,f;if(a.map_diffuse&&b){f=document.createElement("canvas");e=new THREE.MeshLambertMaterial({map:new THREE.Texture(f)});f=new Image;f.onload=function(){if(!d(this.width)||!d(this.height)){var j=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),k=Math.pow(2,
|
|
|
+Math.round(Math.log(this.height)/Math.LN2));e.map.image.width=j;e.map.image.height=k;e.map.image.getContext("2d").drawImage(this,0,0,j,k)}else e.map.image=this;e.map.image.loaded=1};f.src=b+"/"+a.map_diffuse}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;e=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else e=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});return e}};
|