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