mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-25 04:46:02 +10:00
Updated builds.
This commit is contained in:
+94
-94
@@ -1,8 +1,8 @@
|
||||
// Three.js r37 - http://github.com/mrdoob/three.js
|
||||
var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
|
||||
THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,e,g,h,k,j;if(b==0)d=e=g=0;else{h=Math.floor(a*6);k=a*6-h;a=b*(1-c);j=b*(1-c*k);c=b*(1-c*(1-k));switch(h){case 1:d=j;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=j;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a;g=j;break;case 6:case 0:d=b;e=c;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex();
|
||||
this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
|
||||
THREE.Vector2=function(a,c){this.set(a||0,c||0)};
|
||||
THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,e,g,h,k,j;if(b==0)d=e=g=0;else{h=Math.floor(a*6);k=a*6-h;a=b*(1-c);j=b*(1-c*k);c=b*(1-c*(1-k));switch(h){case 1:d=j;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=j;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a;
|
||||
g=j;break;case 6:case 0:d=b;e=c;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*
|
||||
255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,c){this.set(a||0,c||0)};
|
||||
THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
|
||||
this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,c,b){this.set(a||0,c||0,b||0)};
|
||||
THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
|
||||
@@ -12,21 +12,21 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
|
||||
1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,c,b,d){this.set(a||0,c||0,b||0,d||1)};
|
||||
THREE.Vector4.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
|
||||
a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
|
||||
THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,e=[];a=0;for(c=d.length;a<c;a++){b=d[a];b instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(b)))}e.sort(function(g,h){return g.distance-h.distance});return e},intersectObject:function(a){function c(H,E,I,z){z=z.clone().subSelf(E);I=I.clone().subSelf(E);var S=H.clone().subSelf(E);H=z.dot(z);E=z.dot(I);z=z.dot(S);var Q=I.dot(I);I=I.dot(S);S=1/(H*Q-E*E);Q=(Q*z-E*I)*S;H=(H*I-E*z)*S;return Q>0&&H>0&&Q+H<1}var b,d,e,g,h,k,j,m,t,x,
|
||||
y,q=a.geometry,A=q.vertices,G=[];b=0;for(d=q.faces.length;b<d;b++){e=q.faces[b];x=this.origin.clone();y=this.direction.clone();j=a.matrixWorld;g=j.multiplyVector3(A[e.a].position.clone());h=j.multiplyVector3(A[e.b].position.clone());k=j.multiplyVector3(A[e.c].position.clone());j=e instanceof THREE.Face4?j.multiplyVector3(A[e.d].position.clone()):null;m=a.matrixRotationWorld.multiplyVector3(e.normal.clone());t=y.dot(m);if(t<0){m=m.dot((new THREE.Vector3).sub(g,x))/t;x=x.addSelf(y.multiplyScalar(m));
|
||||
THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,e=[];a=0;for(c=d.length;a<c;a++){b=d[a];b instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(b)))}e.sort(function(g,h){return g.distance-h.distance});return e},intersectObject:function(a){function c(H,E,I,A){A=A.clone().subSelf(E);I=I.clone().subSelf(E);var S=H.clone().subSelf(E);H=A.dot(A);E=A.dot(I);A=A.dot(S);var Q=I.dot(I);I=I.dot(S);S=1/(H*Q-E*E);Q=(Q*A-E*I)*S;H=(H*I-E*A)*S;return Q>0&&H>0&&Q+H<1}var b,d,e,g,h,k,j,m,t,x,
|
||||
y,q=a.geometry,z=q.vertices,G=[];b=0;for(d=q.faces.length;b<d;b++){e=q.faces[b];x=this.origin.clone();y=this.direction.clone();j=a.matrixWorld;g=j.multiplyVector3(z[e.a].position.clone());h=j.multiplyVector3(z[e.b].position.clone());k=j.multiplyVector3(z[e.c].position.clone());j=e instanceof THREE.Face4?j.multiplyVector3(z[e.d].position.clone()):null;m=a.matrixRotationWorld.multiplyVector3(e.normal.clone());t=y.dot(m);if(t<0){m=m.dot((new THREE.Vector3).sub(g,x))/t;x=x.addSelf(y.multiplyScalar(m));
|
||||
if(e instanceof THREE.Face3){if(c(x,g,h,k)){e={distance:this.origin.distanceTo(x),point:x,face:e,object:a};G.push(e)}}else if(e instanceof THREE.Face4&&(c(x,g,h,j)||c(x,h,k,j))){e={distance:this.origin.distanceTo(x),point:x,face:e,object:a};G.push(e)}}}return G}};
|
||||
THREE.Rectangle=function(){function a(){g=d-c;h=e-b}var c,b,d,e,g,h,k=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(j,m,t,x){k=!1;c=j;b=m;d=t;e=x;a()};this.addPoint=function(j,m){if(k){k=!1;c=j;b=m;d=j;e=m}else{c=c<j?c:j;b=b<m?b:m;d=d>j?d:j;e=e>m?e:m}a()};
|
||||
this.add3Points=function(j,m,t,x,y,q){if(k){k=!1;c=j<t?j<y?j:y:t<y?t:y;b=m<x?m<q?m:q:x<q?x:q;d=j>t?j>y?j:y:t>y?t:y;e=m>x?m>q?m:q:x>q?x:q}else{c=j<t?j<y?j<c?j:c:y<c?y:c:t<y?t<c?t:c:y<c?y:c;b=m<x?m<q?m<b?m:b:q<b?q:b:x<q?x<b?x:b:q<b?q:b;d=j>t?j>y?j>d?j:d:y>d?y:d:t>y?t>d?t:d:y>d?y:d;e=m>x?m>q?m>e?m:e:q>e?q:e:x>q?x>e?x:e:q>e?q:e}a()};this.addRectangle=function(j){if(k){k=!1;c=j.getLeft();b=j.getTop();d=j.getRight();e=j.getBottom()}else{c=c<j.getLeft()?c:j.getLeft();b=b<j.getTop()?b:j.getTop();d=d>j.getRight()?
|
||||
d:j.getRight();e=e>j.getBottom()?e:j.getBottom()}a()};this.inflate=function(j){c-=j;b-=j;d+=j;e+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();b=b>j.getTop()?b:j.getTop();d=d<j.getRight()?d:j.getRight();e=e<j.getBottom()?e:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(c,j.getLeft())>=0&&Math.min(e,j.getBottom())-Math.max(b,j.getTop())>=0};this.empty=function(){k=!0;e=d=b=c=0;a()};this.isEmpty=function(){return k}};
|
||||
THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}};
|
||||
THREE.Matrix4=function(a,c,b,d,e,g,h,k,j,m,t,x,y,q,A,G){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,k||0,j||0,m||0,t||1,x||0,y||0,q||0,A||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
|
||||
THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,k,j,m,t,x,y,q,A,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=t;this.n34=x;this.n41=y;this.n42=q;this.n43=A;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,b){var d=THREE.Matrix4.__v1,
|
||||
THREE.Matrix4=function(a,c,b,d,e,g,h,k,j,m,t,x,y,q,z,G){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,k||0,j||0,m||0,t||1,x||0,y||0,q||0,z||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
|
||||
THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,k,j,m,t,x,y,q,z,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=t;this.n34=x;this.n41=y;this.n42=q;this.n43=z;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,b){var d=THREE.Matrix4.__v1,
|
||||
e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;d.cross(b,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(b,g).normalize()}e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,e=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*e;a.y=(this.n21*c+this.n22*b+this.n23*
|
||||
d+this.n24)*e;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,e=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*e;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*e;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*e;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize();
|
||||
return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,A=a.n41,G=a.n42,H=a.n43,E=a.n44,I=c.n11,z=c.n12,S=c.n13,Q=c.n14,O=c.n21,X=c.n22,
|
||||
f=c.n23,ea=c.n24,ka=c.n31,W=c.n32,T=c.n33,xa=c.n34;this.n11=b*I+d*O+e*ka;this.n12=b*z+d*X+e*W;this.n13=b*S+d*f+e*T;this.n14=b*Q+d*ea+e*xa+g;this.n21=h*I+k*O+j*ka;this.n22=h*z+k*X+j*W;this.n23=h*S+k*f+j*T;this.n24=h*Q+k*ea+j*xa+m;this.n31=t*I+x*O+y*ka;this.n32=t*z+x*X+y*W;this.n33=t*S+x*f+y*T;this.n34=t*Q+x*ea+y*xa+q;this.n41=A*I+G*O+H*ka;this.n42=A*z+G*X+H*W;this.n43=A*S+G*f+H*T;this.n44=A*Q+G*ea+H*xa+E;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=
|
||||
return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,z=a.n41,G=a.n42,H=a.n43,E=a.n44,I=c.n11,A=c.n12,S=c.n13,Q=c.n14,O=c.n21,X=c.n22,
|
||||
f=c.n23,ea=c.n24,ka=c.n31,W=c.n32,T=c.n33,xa=c.n34;this.n11=b*I+d*O+e*ka;this.n12=b*A+d*X+e*W;this.n13=b*S+d*f+e*T;this.n14=b*Q+d*ea+e*xa+g;this.n21=h*I+k*O+j*ka;this.n22=h*A+k*X+j*W;this.n23=h*S+k*f+j*T;this.n24=h*Q+k*ea+j*xa+m;this.n31=t*I+x*O+y*ka;this.n32=t*A+x*X+y*W;this.n33=t*S+x*f+y*T;this.n34=t*Q+x*ea+y*xa+q;this.n41=z*I+G*O+H*ka;this.n42=z*A+G*X+H*W;this.n43=z*S+G*f+H*T;this.n44=z*Q+G*ea+H*xa+E;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=
|
||||
this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},
|
||||
determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,t=this.n33,x=this.n34,y=this.n41,q=this.n42,A=this.n43,G=this.n44;return d*h*m*y-b*k*m*y-d*g*t*y+c*k*t*y+b*g*x*y-c*h*x*y-d*h*j*q+b*k*j*q+d*e*t*q-a*k*t*q-b*e*x*q+a*h*x*q+d*g*j*A-c*k*j*A-d*e*m*A+a*k*m*A+c*e*x*A-a*g*x*A-b*g*j*G+c*h*j*G+b*e*m*G-a*h*m*G-c*e*t*G+a*g*t*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=
|
||||
determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,t=this.n33,x=this.n34,y=this.n41,q=this.n42,z=this.n43,G=this.n44;return d*h*m*y-b*k*m*y-d*g*t*y+c*k*t*y+b*g*x*y-c*h*x*y-d*h*j*q+b*k*j*q+d*e*t*q-a*k*t*q-b*e*x*q+a*h*x*q+d*g*j*z-c*k*j*z-d*e*m*z+a*k*m*z+c*e*x*z-a*g*x*z-b*g*j*G+c*h*j*G+b*e*m*G-a*h*m*G-c*e*t*G+a*g*t*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=
|
||||
a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;
|
||||
this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;
|
||||
a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},
|
||||
@@ -34,8 +34,8 @@ setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},
|
||||
a.z,j=e*g,m=e*h;this.set(j*g+b,j*h-d*k,j*k+d*h,0,j*h+d*k,m*h+b,m*k-d*g,0,j*k-d*h,m*k+d*g,e*k*k+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var e=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,k=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-c*e;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*e;return this},
|
||||
setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,e=a.w,g=c+c,h=b+b,k=d+d;a=c*g;var j=c*h;c*=k;var m=b*h;b*=k;d*=k;g*=e;h*=e;e*=k;this.n11=1-(m+d);this.n12=j-e;this.n13=c+h;this.n21=j+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+m);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14=
|
||||
a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,e=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
|
||||
THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,A=a.n41,G=a.n42,H=a.n43,E=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=j*q*G-m*y*G+m*x*H-k*q*H-j*x*E+k*y*E;c.n12=g*y*G-e*q*G-g*x*H+d*q*H+e*x*E-d*y*E;c.n13=e*m*G-g*j*G+g*k*H-d*m*H-e*k*E+d*j*E;c.n14=g*j*x-e*m*x-g*k*y+d*m*y+e*k*q-d*j*q;c.n21=m*y*A-j*q*A-m*t*H+h*q*H+j*t*E-h*y*E;c.n22=e*q*A-g*y*A+g*t*H-b*q*H-e*t*E+b*y*E;c.n23=g*j*A-e*m*A-g*h*H+b*m*H+e*h*E-b*j*E;
|
||||
c.n24=e*m*t-g*j*t+g*h*y-b*m*y-e*h*q+b*j*q;c.n31=k*q*A-m*x*A+m*t*G-h*q*G-k*t*E+h*x*E;c.n32=g*x*A-d*q*A-g*t*G+b*q*G+d*t*E-b*x*E;c.n33=e*m*A-g*k*A+g*h*G-b*m*G-d*h*E+b*k*E;c.n34=g*k*t-d*m*t-g*h*x+b*m*x+d*h*q-b*k*q;c.n41=j*x*A-k*y*A-j*t*G+h*y*G+k*t*H-h*x*H;c.n42=d*y*A-e*x*A+e*t*G-b*y*G-d*t*H+b*x*H;c.n43=e*k*A-d*j*A-e*h*G+b*j*G+d*h*H-b*k*H;c.n44=d*j*t-e*k*t+e*h*x-b*j*x-d*h*y+b*k*y;c.multiplyScalar(1/a.determinant());return c};
|
||||
THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,t=a.n31,x=a.n32,y=a.n33,q=a.n34,z=a.n41,G=a.n42,H=a.n43,E=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=j*q*G-m*y*G+m*x*H-k*q*H-j*x*E+k*y*E;c.n12=g*y*G-e*q*G-g*x*H+d*q*H+e*x*E-d*y*E;c.n13=e*m*G-g*j*G+g*k*H-d*m*H-e*k*E+d*j*E;c.n14=g*j*x-e*m*x-g*k*y+d*m*y+e*k*q-d*j*q;c.n21=m*y*z-j*q*z-m*t*H+h*q*H+j*t*E-h*y*E;c.n22=e*q*z-g*y*z+g*t*H-b*q*H-e*t*E+b*y*E;c.n23=g*j*z-e*m*z-g*h*H+b*m*H+e*h*E-b*j*E;
|
||||
c.n24=e*m*t-g*j*t+g*h*y-b*m*y-e*h*q+b*j*q;c.n31=k*q*z-m*x*z+m*t*G-h*q*G-k*t*E+h*x*E;c.n32=g*x*z-d*q*z-g*t*G+b*q*G+d*t*E-b*x*E;c.n33=e*m*z-g*k*z+g*h*G-b*m*G-d*h*E+b*k*E;c.n34=g*k*t-d*m*t-g*h*x+b*m*x+d*h*q-b*k*q;c.n41=j*x*z-k*y*z-j*t*G+h*y*G+k*t*H-h*x*H;c.n42=d*y*z-e*x*z+e*t*G-b*y*G-d*t*H+b*x*H;c.n43=e*k*z-d*j*z-e*h*G+b*j*G+d*h*H-b*k*H;c.n44=d*j*t-e*k*t+e*h*x-b*j*x-d*h*y+b*k*y;c.multiplyScalar(1/a.determinant());return c};
|
||||
THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,t=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*k;b[5]=a*j;b[6]=a*m;b[7]=a*t;b[8]=a*x;return c};
|
||||
THREE.Matrix4.makeFrustum=function(a,c,b,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*e/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var e;a=b*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*c,a*c,e,a,b,d)};
|
||||
THREE.Matrix4.makeOrtho=function(a,c,b,d,e,g){var h,k,j,m;h=new THREE.Matrix4;k=c-a;j=b-d;m=g-e;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((c+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((b+d)/j);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
|
||||
@@ -48,7 +48,7 @@ c,b)}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==undefined?
|
||||
THREE.Quaternion.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},setFromEuler:function(a){var c=0.5*Math.PI/360,b=a.x*c,d=a.y*c,e=a.z*c;a=Math.cos(d);d=Math.sin(d);c=Math.cos(-e);e=Math.sin(-e);var g=Math.cos(b);b=Math.sin(b);var h=a*c,k=d*e;this.w=h*g-k*b;this.x=h*b+k*g;this.y=d*c*g+a*e*b;this.z=a*e*g-d*c*b;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
|
||||
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var c=this.x,b=this.y,d=this.z,e=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=c*a+e*g+b*k-d*h;this.y=b*a+e*h+d*g-c*k;this.z=d*a+e*k+c*h-b*g;this.w=e*a-c*g-b*h-d*k;return this},
|
||||
multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,e=a.z,g=this.x,h=this.y,k=this.z,j=this.w,m=j*b+h*e-k*d,t=j*d+k*b-g*e,x=j*e+g*d-h*b;b=-g*b-h*d-k*e;c.x=m*j+b*-g+t*-k-x*-h;c.y=t*j+b*-h+x*-g-m*-k;c.z=x*j+b*-k+m*-h-t*-g;return c}};
|
||||
THREE.Quaternion.slerp=function(a,c,b,d){var e=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(e)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Quaternion.slerp=function(a,c,b,d){var e=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(e)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.001){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Face3=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
|
||||
THREE.Face4=function(a,c,b,d,e,g,h){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)};
|
||||
THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
|
||||
@@ -56,15 +56,15 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.f
|
||||
b.centroid.addSelf(this.vertices[b.d].position);b.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,b,d,e,g,h,k=new THREE.Vector3,j=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){k.set(0,0,0);c=0;for(b=g.vertexNormals.length;c<b;c++)k.addSelf(g.vertexNormals[c]);k.divideScalar(3)}else{c=this.vertices[g.a];b=this.vertices[g.b];h=this.vertices[g.c];k.sub(h.position,b.position);j.sub(c.position,b.position);k.crossSelf(j)}k.isZero()||
|
||||
k.normalize();g.normal.copy(k)}},computeVertexNormals:function(){var a,c,b,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)d[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];if(b instanceof THREE.Face3)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(b instanceof THREE.Face4)b.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=
|
||||
this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)d[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];if(b instanceof THREE.Face3){d[b.a].addSelf(b.normal);d[b.b].addSelf(b.normal);d[b.c].addSelf(b.normal)}else if(b instanceof THREE.Face4){d[b.a].addSelf(b.normal);d[b.b].addSelf(b.normal);d[b.c].addSelf(b.normal);d[b.d].addSelf(b.normal)}}a=0;for(c=this.vertices.length;a<c;a++)d[a].normalize();a=0;for(c=this.faces.length;a<c;a++){b=this.faces[a];if(b instanceof THREE.Face3){b.vertexNormals[0].copy(d[b.a]);
|
||||
b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c])}else if(b instanceof THREE.Face4){b.vertexNormals[0].copy(d[b.a]);b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c]);b.vertexNormals[3].copy(d[b.d])}}},computeTangents:function(){function a(oa,la,aa,P,M,da,sa){k=oa.vertices[la].position;j=oa.vertices[aa].position;m=oa.vertices[P].position;t=h[M];x=h[da];y=h[sa];q=j.x-k.x;A=m.x-k.x;G=j.y-k.y;H=m.y-k.y;E=j.z-k.z;I=m.z-k.z;z=x.u-t.u;S=y.u-t.u;Q=x.v-t.v;O=y.v-t.v;X=1/(z*O-S*
|
||||
Q);W.set((O*q-Q*A)*X,(O*G-Q*H)*X,(O*E-Q*I)*X);T.set((z*A-S*q)*X,(z*H-S*G)*X,(z*I-S*E)*X);ea[la].addSelf(W);ea[aa].addSelf(W);ea[P].addSelf(W);ka[la].addSelf(T);ka[aa].addSelf(T);ka[P].addSelf(T)}var c,b,d,e,g,h,k,j,m,t,x,y,q,A,G,H,E,I,z,S,Q,O,X,f,ea=[],ka=[],W=new THREE.Vector3,T=new THREE.Vector3,xa=new THREE.Vector3,ca=new THREE.Vector3,Da=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++){ea[c]=new THREE.Vector3;ka[c]=new THREE.Vector3}c=0;for(b=this.faces.length;c<b;c++){g=this.faces[c];
|
||||
b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c])}else if(b instanceof THREE.Face4){b.vertexNormals[0].copy(d[b.a]);b.vertexNormals[1].copy(d[b.b]);b.vertexNormals[2].copy(d[b.c]);b.vertexNormals[3].copy(d[b.d])}}},computeTangents:function(){function a(oa,la,aa,P,M,da,sa){k=oa.vertices[la].position;j=oa.vertices[aa].position;m=oa.vertices[P].position;t=h[M];x=h[da];y=h[sa];q=j.x-k.x;z=m.x-k.x;G=j.y-k.y;H=m.y-k.y;E=j.z-k.z;I=m.z-k.z;A=x.u-t.u;S=y.u-t.u;Q=x.v-t.v;O=y.v-t.v;X=1/(A*O-S*
|
||||
Q);W.set((O*q-Q*z)*X,(O*G-Q*H)*X,(O*E-Q*I)*X);T.set((A*z-S*q)*X,(A*H-S*G)*X,(A*I-S*E)*X);ea[la].addSelf(W);ea[aa].addSelf(W);ea[P].addSelf(W);ka[la].addSelf(T);ka[aa].addSelf(T);ka[P].addSelf(T)}var c,b,d,e,g,h,k,j,m,t,x,y,q,z,G,H,E,I,A,S,Q,O,X,f,ea=[],ka=[],W=new THREE.Vector3,T=new THREE.Vector3,xa=new THREE.Vector3,ca=new THREE.Vector3,Da=new THREE.Vector3;c=0;for(b=this.vertices.length;c<b;c++){ea[c]=new THREE.Vector3;ka[c]=new THREE.Vector3}c=0;for(b=this.faces.length;c<b;c++){g=this.faces[c];
|
||||
h=this.faceVertexUvs[0][c];if(g instanceof THREE.Face3)a(this,g.a,g.b,g.c,0,1,2);else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3)}}var ja=["a","b","c","d"];c=0;for(b=this.faces.length;c<b;c++){g=this.faces[c];for(d=0;d<g.vertexNormals.length;d++){Da.copy(g.vertexNormals[d]);e=g[ja[d]];f=ea[e];xa.copy(f);xa.subSelf(Da.multiplyScalar(Da.dot(f))).normalize();ca.cross(g.vertexNormals[d],f);e=ca.dot(ka[e]);e=e<0?-1:1;g.vertexTangents[d]=new THREE.Vector4(xa.x,xa.y,
|
||||
xa.z,e)}}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;c<b;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;
|
||||
if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;c<b;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere=
|
||||
{radius:a}}};THREE.GeometryIdCounter=0;
|
||||
THREE.Spline=function(a){function c(q,A,G,H,E,I,z){q=(G-q)*0.5;H=(H-A)*0.5;return(2*(A-G)+q+H)*z+(-3*(A-G)-2*q-H)*I+q*E+A}this.points=a;var b=[],d={x:0,y:0,z:0},e,g,h,k,j,m,t,x,y;this.initFromArray=function(q){this.points=[];for(var A=0;A<q.length;A++)this.points[A]={x:q[A][0],y:q[A][1],z:q[A][2]}};this.getPoint=function(q){e=(this.points.length-1)*q;g=Math.floor(e);h=e-g;b[0]=g==0?g:g-1;b[1]=g;b[2]=g>this.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;m=this.points[b[0]];t=this.points[b[1]];
|
||||
x=this.points[b[2]];y=this.points[b[3]];k=h*h;j=h*k;d.x=c(m.x,t.x,x.x,y.x,h,k,j);d.y=c(m.y,t.y,x.y,y.y,h,k,j);d.z=c(m.z,t.z,x.z,y.z,h,k,j);return d};this.getControlPointsArray=function(){var q,A,G=this.points.length,H=[];for(q=0;q<G;q++){A=this.points[q];H[q]=[A.x,A.y,A.z]}return H};this.getLength=function(q){var A,G,H=A=A=0,E=new THREE.Vector3,I=new THREE.Vector3,z=[],S=0;z[0]=0;q||(q=100);G=this.points.length*q;E.copy(this.points[0]);for(q=1;q<G;q++){A=q/G;position=this.getPoint(A);I.copy(position);
|
||||
S+=I.distanceTo(E);E.copy(position);A*=this.points.length-1;A=Math.floor(A);if(A!=H){z[A]=S;H=A}}z[z.length]=S;return{chunks:z,total:S}};this.reparametrizeByArcLength=function(q){var A,G,H,E,I,z,S=[],Q=new THREE.Vector3,O=this.getLength();S.push(Q.copy(this.points[0]).clone());for(A=1;A<this.points.length;A++){G=O.chunks[A]-O.chunks[A-1];z=Math.ceil(q*G/O.total);E=(A-1)/(this.points.length-1);I=A/(this.points.length-1);for(G=1;G<z-1;G++){H=E+G*(1/z)*(I-E);position=this.getPoint(H);S.push(Q.copy(position).clone())}S.push(Q.copy(this.points[A]).clone())}this.points=
|
||||
THREE.Spline=function(a){function c(q,z,G,H,E,I,A){q=(G-q)*0.5;H=(H-z)*0.5;return(2*(z-G)+q+H)*A+(-3*(z-G)-2*q-H)*I+q*E+z}this.points=a;var b=[],d={x:0,y:0,z:0},e,g,h,k,j,m,t,x,y;this.initFromArray=function(q){this.points=[];for(var z=0;z<q.length;z++)this.points[z]={x:q[z][0],y:q[z][1],z:q[z][2]}};this.getPoint=function(q){e=(this.points.length-1)*q;g=Math.floor(e);h=e-g;b[0]=g==0?g:g-1;b[1]=g;b[2]=g>this.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;m=this.points[b[0]];t=this.points[b[1]];
|
||||
x=this.points[b[2]];y=this.points[b[3]];k=h*h;j=h*k;d.x=c(m.x,t.x,x.x,y.x,h,k,j);d.y=c(m.y,t.y,x.y,y.y,h,k,j);d.z=c(m.z,t.z,x.z,y.z,h,k,j);return d};this.getControlPointsArray=function(){var q,z,G=this.points.length,H=[];for(q=0;q<G;q++){z=this.points[q];H[q]=[z.x,z.y,z.z]}return H};this.getLength=function(q){var z,G,H=z=z=0,E=new THREE.Vector3,I=new THREE.Vector3,A=[],S=0;A[0]=0;q||(q=100);G=this.points.length*q;E.copy(this.points[0]);for(q=1;q<G;q++){z=q/G;position=this.getPoint(z);I.copy(position);
|
||||
S+=I.distanceTo(E);E.copy(position);z*=this.points.length-1;z=Math.floor(z);if(z!=H){A[z]=S;H=z}}A[A.length]=S;return{chunks:A,total:S}};this.reparametrizeByArcLength=function(q){var z,G,H,E,I,A,S=[],Q=new THREE.Vector3,O=this.getLength();S.push(Q.copy(this.points[0]).clone());for(z=1;z<this.points.length;z++){G=O.chunks[z]-O.chunks[z-1];A=Math.ceil(q*G/O.total);E=(z-1)/(this.points.length-1);I=z/(this.points.length-1);for(G=1;G<A-1;G++){H=E+G*(1/A)*(I-E);position=this.getPoint(H);S.push(Q.copy(position).clone())}S.push(Q.copy(this.points[z]).clone())}this.points=
|
||||
S}};
|
||||
THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(e){for(var g=0;g<a.length;g++)a[g].update(e)};b.addToUpdate=function(e){a.indexOf(e)===-1&&a.push(e)};b.removeFromUpdate=function(e){e=a.indexOf(e);e!==-1&&a.splice(e,1)};b.add=function(e){c[e.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+e.name+" already exists in library. Overwriting.");c[e.name]=e;if(e.initialized!==!0){for(var g=0;g<e.hierarchy.length;g++){for(var h=0;h<e.hierarchy[g].keys.length;h++){if(e.hierarchy[g].keys[h].time<0)e.hierarchy[g].keys[h].time=
|
||||
0;if(e.hierarchy[g].keys[h].rot!==undefined&&!(e.hierarchy[g].keys[h].rot instanceof THREE.Quaternion)){var k=e.hierarchy[g].keys[h].rot;e.hierarchy[g].keys[h].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(e.hierarchy[g].keys[0].morphTargets!==undefined){k={};for(h=0;h<e.hierarchy[g].keys.length;h++)for(var j=0;j<e.hierarchy[g].keys[h].morphTargets.length;j++){var m=e.hierarchy[g].keys[h].morphTargets[j];k[m]=-1}e.hierarchy[g].usedMorphTargets=k;for(h=0;h<e.hierarchy[g].keys.length;h++){var t=
|
||||
@@ -75,7 +75,7 @@ THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=
|
||||
e instanceof THREE.Bone?e.skinMatrix:e.matrix}var g=e.animationCache.prevKey;e=e.animationCache.nextKey;g.pos=this.data.hierarchy[b].keys[0];g.rot=this.data.hierarchy[b].keys[0];g.scl=this.data.hierarchy[b].keys[0];e.pos=this.getNextKeyWith("pos",b,1);e.rot=this.getNextKeyWith("rot",b,1);e.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
|
||||
THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
|
||||
THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
|
||||
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,e,g,h,k,j,m,t=this.data.JIT.hierarchy,x,y;this.currentTime+=a*this.timeScale;y=this.currentTime;x=this.currentTime%=this.data.length;m=parseInt(Math.min(x*this.data.fps,this.data.length*this.data.fps),10);for(var q=0,A=this.hierarchy.length;q<A;q++){a=this.hierarchy[q];j=a.animationCache;if(this.JITCompile&&t[q][m]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=t[q][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
|
||||
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,e,g,h,k,j,m,t=this.data.JIT.hierarchy,x,y;this.currentTime+=a*this.timeScale;y=this.currentTime;x=this.currentTime%=this.data.length;m=parseInt(Math.min(x*this.data.fps,this.data.length*this.data.fps),10);for(var q=0,z=this.hierarchy.length;q<z;q++){a=this.hierarchy[q];j=a.animationCache;if(this.JITCompile&&t[q][m]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=t[q][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
|
||||
!1}else{a.matrix=t[q][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var G=0;G<3;G++){b=c[G];h=j.prevKey[b];k=j.nextKey[b];if(k.time<=y){if(x<y)if(this.loop){h=this.data.hierarchy[q].keys[0];for(k=this.getNextKeyWith(b,q,1);k.time<x;){h=k;k=this.getNextKeyWith(b,q,k.index+1)}}else{this.stop();return}else{do{h=k;k=this.getNextKeyWith(b,q,k.index+1)}while(k.time<
|
||||
x)}j.prevKey[b]=h;j.nextKey[b]=k}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(x-h.time)/(k.time-h.time);e=h[b];g=k[b];if(d<0||d>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+q);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
|
||||
this.getPrevKeyWith("pos",q,h.index-1).pos;this.points[1]=e;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",q,k.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);b.x=e[0];b.y=e[1];b.z=e[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(b===
|
||||
@@ -145,7 +145,7 @@ THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.
|
||||
THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var c=this.lights.indexOf(a);c!==-1&&this.lights.splice(c,1)}else if(a instanceof THREE.Sound){c=this.sounds.indexOf(a);c!==-1&&this.sounds.splice(c,1)}else if(!(a instanceof THREE.Camera)){c=this.objects.indexOf(a);if(c!==-1){this.objects.splice(c,1);this.__objectsRemoved.push(a)}}for(c=0;c<a.children.length;c++)this.removeChildRecurse(a.children[c])};
|
||||
THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,c,b){this.color=new THREE.Color(a);this.near=c||1;this.far=b||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c!==undefined?c:2.5E-4};
|
||||
THREE.Projector=function(){function a(){var W=j[k]=j[k]||new THREE.RenderableVertex;k++;return W}function c(W,T){return T.z-W.z}function b(W,T){var xa=0,ca=1,Da=W.z+W.w,ja=T.z+T.w,oa=-W.z+W.w,la=-T.z+T.w;if(Da>=0&&ja>=0&&oa>=0&&la>=0)return!0;else if(Da<0&&ja<0||oa<0&&la<0)return!1;else{if(Da<0)xa=Math.max(xa,Da/(Da-ja));else ja<0&&(ca=Math.min(ca,Da/(Da-ja)));if(oa<0)xa=Math.max(xa,oa/(oa-la));else la<0&&(ca=Math.min(ca,oa/(oa-la)));if(ca<xa)return!1;else{W.lerpSelf(T,xa);T.lerpSelf(W,1-ca);return!0}}}
|
||||
var d,e,g=[],h,k,j=[],m,t,x=[],y,q=[],A,G,H=[],E,I,z=[],S=new THREE.Vector4,Q=new THREE.Vector4,O=new THREE.Matrix4,X=new THREE.Matrix4,f=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ea=new THREE.Vector4,ka=new THREE.Vector4;this.projectVector=function(W,T){O.multiply(T.projectionMatrix,T.matrixWorldInverse);O.multiplyVector3(W);return W};this.unprojectVector=function(W,T){O.multiply(T.matrixWorld,THREE.Matrix4.makeInvert(T.projectionMatrix));
|
||||
var d,e,g=[],h,k,j=[],m,t,x=[],y,q=[],z,G,H=[],E,I,A=[],S=new THREE.Vector4,Q=new THREE.Vector4,O=new THREE.Matrix4,X=new THREE.Matrix4,f=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ea=new THREE.Vector4,ka=new THREE.Vector4;this.projectVector=function(W,T){O.multiply(T.projectionMatrix,T.matrixWorldInverse);O.multiplyVector3(W);return W};this.unprojectVector=function(W,T){O.multiply(T.matrixWorld,THREE.Matrix4.makeInvert(T.projectionMatrix));
|
||||
O.multiplyVector3(W);return W};this.projectObjects=function(W,T,xa){T=[];var ca,Da,ja;e=0;Da=W.objects;W=0;for(ca=Da.length;W<ca;W++){ja=Da[W];var oa;if(!(oa=!ja.visible))if(oa=ja instanceof THREE.Mesh){a:{oa=void 0;for(var la=ja.matrixWorld,aa=-ja.geometry.boundingSphere.radius*Math.max(ja.scale.x,Math.max(ja.scale.y,ja.scale.z)),P=0;P<6;P++){oa=f[P].x*la.n14+f[P].y*la.n24+f[P].z*la.n34+f[P].w;if(oa<=aa){oa=!1;break a}}oa=!0}oa=!oa}if(!oa){oa=g[e]=g[e]||new THREE.RenderableObject;e++;d=oa;S.copy(ja.position);
|
||||
O.multiplyVector3(S);d.object=ja;d.z=S.z;T.push(d)}}xa&&T.sort(c);return T};this.projectScene=function(W,T,xa){var ca=[],Da=T.near,ja=T.far,oa,la,aa,P,M,da,sa,ia,ta,ya,La,ab,n,C,p,o,w;I=G=y=t=0;T.matrixAutoUpdate&&T.updateMatrix();W.update(undefined,!1,T);O.multiply(T.projectionMatrix,T.matrixWorldInverse);f[0].set(O.n41-O.n11,O.n42-O.n12,O.n43-O.n13,O.n44-O.n14);f[1].set(O.n41+O.n11,O.n42+O.n12,O.n43+O.n13,O.n44+O.n14);f[2].set(O.n41+O.n21,O.n42+O.n22,O.n43+O.n23,O.n44+O.n24);f[3].set(O.n41-O.n21,
|
||||
O.n42-O.n22,O.n43-O.n23,O.n44-O.n24);f[4].set(O.n41-O.n31,O.n42-O.n32,O.n43-O.n33,O.n44-O.n34);f[5].set(O.n41+O.n31,O.n42+O.n32,O.n43+O.n33,O.n44+O.n34);for(oa=0;oa<6;oa++){ta=f[oa];ta.divideScalar(Math.sqrt(ta.x*ta.x+ta.y*ta.y+ta.z*ta.z))}ta=this.projectObjects(W,T,!0);W=0;for(oa=ta.length;W<oa;W++){ya=ta[W].object;if(ya.visible){La=ya.matrixWorld;ab=ya.matrixRotationWorld;n=ya.materials;C=ya.overdraw;k=0;if(ya instanceof THREE.Mesh){p=ya.geometry;P=p.vertices;o=p.faces;p=p.faceVertexUvs;la=0;for(aa=
|
||||
@@ -153,17 +153,17 @@ P.length;la<aa;la++){h=a();h.positionWorld.copy(P[la].position);La.multiplyVecto
|
||||
(da.positionScreen.y-M.positionScreen.y)-(sa.positionScreen.y-M.positionScreen.y)*(da.positionScreen.x-M.positionScreen.x)<0)){ia=x[t]=x[t]||new THREE.RenderableFace3;t++;m=ia;m.v1.copy(M);m.v2.copy(da);m.v3.copy(sa)}else continue}else if(aa instanceof THREE.Face4){M=j[aa.a];da=j[aa.b];sa=j[aa.c];ia=j[aa.d];if(M.visible&&da.visible&&sa.visible&&ia.visible&&(ya.doubleSided||ya.flipSided!=((ia.positionScreen.x-M.positionScreen.x)*(da.positionScreen.y-M.positionScreen.y)-(ia.positionScreen.y-M.positionScreen.y)*
|
||||
(da.positionScreen.x-M.positionScreen.x)<0||(da.positionScreen.x-sa.positionScreen.x)*(ia.positionScreen.y-sa.positionScreen.y)-(da.positionScreen.y-sa.positionScreen.y)*(ia.positionScreen.x-sa.positionScreen.x)<0))){w=q[y]=q[y]||new THREE.RenderableFace4;y++;m=w;m.v1.copy(M);m.v2.copy(da);m.v3.copy(sa);m.v4.copy(ia)}else continue}m.normalWorld.copy(aa.normal);ab.multiplyVector3(m.normalWorld);m.centroidWorld.copy(aa.centroid);La.multiplyVector3(m.centroidWorld);m.centroidScreen.copy(m.centroidWorld);
|
||||
O.multiplyVector3(m.centroidScreen);sa=aa.vertexNormals;M=0;for(da=sa.length;M<da;M++){ia=m.vertexNormalsWorld[M];ia.copy(sa[M]);ab.multiplyVector3(ia)}M=0;for(da=p.length;M<da;M++)if(w=p[M][P]){sa=0;for(ia=w.length;sa<ia;sa++)m.uvs[M][sa]=w[sa]}m.meshMaterials=n;m.faceMaterials=aa.materials;m.overdraw=C;m.z=m.centroidScreen.z;ca.push(m)}}else if(ya instanceof THREE.Line){X.multiply(O,La);P=ya.geometry.vertices;M=a();M.positionScreen.copy(P[0].position);X.multiplyVector4(M.positionScreen);la=1;for(aa=
|
||||
P.length;la<aa;la++){M=a();M.positionScreen.copy(P[la].position);X.multiplyVector4(M.positionScreen);da=j[k-2];ea.copy(M.positionScreen);ka.copy(da.positionScreen);if(b(ea,ka)){ea.multiplyScalar(1/ea.w);ka.multiplyScalar(1/ka.w);La=H[G]=H[G]||new THREE.RenderableLine;G++;A=La;A.v1.positionScreen.copy(ea);A.v2.positionScreen.copy(ka);A.z=Math.max(ea.z,ka.z);A.materials=ya.materials;ca.push(A)}}}else if(ya instanceof THREE.Particle){Q.set(ya.position.x,ya.position.y,ya.position.z,1);O.multiplyVector4(Q);
|
||||
Q.z/=Q.w;if(Q.z>0&&Q.z<1){La=z[I]=z[I]||new THREE.RenderableParticle;I++;E=La;E.x=Q.x/Q.w;E.y=Q.y/Q.w;E.z=Q.z;E.rotation=ya.rotation.z;E.scale.x=ya.scale.x*Math.abs(E.x-(Q.x+T.projectionMatrix.n11)/(Q.w+T.projectionMatrix.n14));E.scale.y=ya.scale.y*Math.abs(E.y-(Q.y+T.projectionMatrix.n22)/(Q.w+T.projectionMatrix.n24));E.materials=ya.materials;ca.push(E)}}}}xa&&ca.sort(c);return ca}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;d=k;e=b/2;g=d/2};this.render=function(h,k){var j,m,t,x,y,q,A,G;a=c.projectScene(h,k);j=0;for(m=a.length;j<m;j++){y=a[j];if(y instanceof THREE.RenderableParticle){A=y.x*e+e;G=y.y*g+g;t=0;for(x=y.material.length;t<x;t++){q=y.material[t];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=A+"px";q.style.top=G+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(Ca){if(y!=Ca)m.globalAlpha=y=Ca}function c(Ca){if(q!=Ca){switch(Ca){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=Ca}}var b=null,d=new THREE.Projector,e=document.createElement("canvas"),g,h,k,j,m=e.getContext("2d"),t=new THREE.Color(0),x=0,y=1,q=0,A=null,G=null,H=1,E,I,z,S,Q=new THREE.RenderableVertex,
|
||||
P.length;la<aa;la++){M=a();M.positionScreen.copy(P[la].position);X.multiplyVector4(M.positionScreen);da=j[k-2];ea.copy(M.positionScreen);ka.copy(da.positionScreen);if(b(ea,ka)){ea.multiplyScalar(1/ea.w);ka.multiplyScalar(1/ka.w);La=H[G]=H[G]||new THREE.RenderableLine;G++;z=La;z.v1.positionScreen.copy(ea);z.v2.positionScreen.copy(ka);z.z=Math.max(ea.z,ka.z);z.materials=ya.materials;ca.push(z)}}}else if(ya instanceof THREE.Particle){Q.set(ya.position.x,ya.position.y,ya.position.z,1);O.multiplyVector4(Q);
|
||||
Q.z/=Q.w;if(Q.z>0&&Q.z<1){La=A[I]=A[I]||new THREE.RenderableParticle;I++;E=La;E.x=Q.x/Q.w;E.y=Q.y/Q.w;E.z=Q.z;E.rotation=ya.rotation.z;E.scale.x=ya.scale.x*Math.abs(E.x-(Q.x+T.projectionMatrix.n11)/(Q.w+T.projectionMatrix.n14));E.scale.y=ya.scale.y*Math.abs(E.y-(Q.y+T.projectionMatrix.n22)/(Q.w+T.projectionMatrix.n24));E.materials=ya.materials;ca.push(E)}}}}xa&&ca.sort(c);return ca}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,k){b=h;d=k;e=b/2;g=d/2};this.render=function(h,k){var j,m,t,x,y,q,z,G;a=c.projectScene(h,k);j=0;for(m=a.length;j<m;j++){y=a[j];if(y instanceof THREE.RenderableParticle){z=y.x*e+e;G=y.y*g+g;t=0;for(x=y.material.length;t<x;t++){q=y.material[t];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=z+"px";q.style.top=G+"px"}}}}}};
|
||||
THREE.CanvasRenderer=function(){function a(Ca){if(y!=Ca)m.globalAlpha=y=Ca}function c(Ca){if(q!=Ca){switch(Ca){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}q=Ca}}var b=null,d=new THREE.Projector,e=document.createElement("canvas"),g,h,k,j,m=e.getContext("2d"),t=new THREE.Color(0),x=0,y=1,q=0,z=null,G=null,H=1,E,I,A,S,Q=new THREE.RenderableVertex,
|
||||
O=new THREE.RenderableVertex,X,f,ea,ka,W,T,xa,ca,Da,ja,oa,la,aa=new THREE.Color,P=new THREE.Color,M=new THREE.Color,da=new THREE.Color,sa=new THREE.Color,ia,ta,ya,La,ab,n,C,p,o,w,D=new THREE.Rectangle,B=new THREE.Rectangle,F=new THREE.Rectangle,Z=!1,N=new THREE.Color,K=new THREE.Color,ra=new THREE.Color,Ea=new THREE.Color,$=new THREE.Vector3,Aa,ma,Ga,Ma,wa,Ia,V=16;Aa=document.createElement("canvas");Aa.width=Aa.height=2;ma=Aa.getContext("2d");ma.fillStyle="rgba(0,0,0,1)";ma.fillRect(0,0,2,2);Ga=ma.getImageData(0,
|
||||
0,2,2);Ma=Ga.data;wa=document.createElement("canvas");wa.width=wa.height=V;Ia=wa.getContext("2d");Ia.translate(-V/2,-V/2);Ia.scale(V,V);V--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(Ca,Ba){g=Ca;h=Ba;k=g/2;j=h/2;e.width=g;e.height=h;D.set(-k,-j,k,j);y=1;q=0;G=A=null;H=1};this.setClearColor=function(Ca,Ba){t=Ca;x=Ba};this.setClearColorHex=function(Ca,Ba){t.setHex(Ca);x=Ba};this.clear=function(){m.setTransform(1,0,0,-1,k,j);if(!B.isEmpty()){B.inflate(1);
|
||||
0,2,2);Ma=Ga.data;wa=document.createElement("canvas");wa.width=wa.height=V;Ia=wa.getContext("2d");Ia.translate(-V/2,-V/2);Ia.scale(V,V);V--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(Ca,Ba){g=Ca;h=Ba;k=g/2;j=h/2;e.width=g;e.height=h;D.set(-k,-j,k,j);y=1;q=0;G=z=null;H=1};this.setClearColor=function(Ca,Ba){t=Ca;x=Ba};this.setClearColorHex=function(Ca,Ba){t.setHex(Ca);x=Ba};this.clear=function(){m.setTransform(1,0,0,-1,k,j);if(!B.isEmpty()){B.inflate(1);
|
||||
B.minSelf(D);if(t.hex==0&&x==0)m.clearRect(B.getX(),B.getY(),B.getWidth(),B.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b*255)+","+x+")";m.fillRect(B.getX(),B.getY(),B.getWidth(),B.getHeight())}B.empty()}};this.render=function(Ca,Ba){function Ya(J){var Y,U,fa,za=J.lights;K.setRGB(0,0,0);ra.setRGB(0,0,0);Ea.setRGB(0,0,0);J=0;for(Y=za.length;J<Y;J++){U=za[J];fa=U.color;if(U instanceof THREE.AmbientLight){K.r+=fa.r;K.g+=
|
||||
fa.g;K.b+=fa.b}else if(U instanceof THREE.DirectionalLight){ra.r+=fa.r;ra.g+=fa.g;ra.b+=fa.b}else if(U instanceof THREE.PointLight){Ea.r+=fa.r;Ea.g+=fa.g;Ea.b+=fa.b}}}function ua(J,Y,U,fa){var za,qa,pa,R,Ka=J.lights;J=0;for(za=Ka.length;J<za;J++){qa=Ka[J];pa=qa.color;R=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=U.dot(qa.position)*R;if(qa>0){fa.r+=pa.r*qa;fa.g+=pa.g*qa;fa.b+=pa.b*qa}}else if(qa instanceof THREE.PointLight){$.sub(qa.position,Y);$.normalize();qa=U.dot($)*R;if(qa>0){fa.r+=
|
||||
pa.r*qa;fa.g+=pa.g*qa;fa.b+=pa.b*qa}}}}function ga(J,Y,U){a(U.opacity);c(U.blending);var fa,za,qa,pa,R,Ka;if(U instanceof THREE.ParticleBasicMaterial){if(U.map){pa=U.map.image;R=pa.width>>1;Ka=pa.height>>1;U=Y.scale.x*k;qa=Y.scale.y*j;fa=U*R;za=qa*Ka;F.set(J.x-fa,J.y-za,J.x+fa,J.y+za);if(D.instersects(F)){m.save();m.translate(J.x,J.y);m.rotate(-Y.rotation);m.scale(U,-qa);m.translate(-R,-Ka);m.drawImage(pa,0,0);m.restore()}}}else if(U instanceof THREE.ParticleCanvasMaterial){if(Z){N.r=K.r+ra.r+Ea.r;
|
||||
N.g=K.g+ra.g+Ea.g;N.b=K.b+ra.b+Ea.b;aa.r=U.color.r*N.r;aa.g=U.color.g*N.g;aa.b=U.color.b*N.b;aa.updateStyleString()}else aa.__styleString=U.color.__styleString;fa=Y.scale.x*k;za=Y.scale.y*j;F.set(J.x-fa,J.y-za,J.x+fa,J.y+za);if(D.instersects(F)){m.save();m.translate(J.x,J.y);m.rotate(-Y.rotation);m.scale(fa,za);U.program(m,aa);m.restore()}}}function ha(J,Y,U,fa){a(fa.opacity);c(fa.blending);m.beginPath();m.moveTo(J.positionScreen.x,J.positionScreen.y);m.lineTo(Y.positionScreen.x,Y.positionScreen.y);
|
||||
m.closePath();if(fa instanceof THREE.LineBasicMaterial){aa.__styleString=fa.color.__styleString;J=fa.linewidth;if(H!=J)m.lineWidth=H=J;J=aa.__styleString;if(A!=J)m.strokeStyle=A=J;m.stroke();F.inflate(fa.linewidth*2)}}function na(J,Y,U,fa,za,qa,pa,R,Ka){a(R.opacity);c(R.blending);X=J.positionScreen.x;f=J.positionScreen.y;ea=Y.positionScreen.x;ka=Y.positionScreen.y;W=U.positionScreen.x;T=U.positionScreen.y;Sa(X,f,ea,ka,W,T);if(R instanceof THREE.MeshBasicMaterial)if(R.map){if(R.map.mapping instanceof
|
||||
m.closePath();if(fa instanceof THREE.LineBasicMaterial){aa.__styleString=fa.color.__styleString;J=fa.linewidth;if(H!=J)m.lineWidth=H=J;J=aa.__styleString;if(z!=J)m.strokeStyle=z=J;m.stroke();F.inflate(fa.linewidth*2)}}function na(J,Y,U,fa,za,qa,pa,R,Ka){a(R.opacity);c(R.blending);X=J.positionScreen.x;f=J.positionScreen.y;ea=Y.positionScreen.x;ka=Y.positionScreen.y;W=U.positionScreen.x;T=U.positionScreen.y;Sa(X,f,ea,ka,W,T);if(R instanceof THREE.MeshBasicMaterial)if(R.map){if(R.map.mapping instanceof
|
||||
THREE.UVMapping){La=pa.uvs[0];Ta(X,f,ea,ka,W,T,R.map.image,La[fa].u,La[fa].v,La[za].u,La[za].v,La[qa].u,La[qa].v)}}else if(R.envMap){if(R.envMap.mapping instanceof THREE.SphericalReflectionMapping){J=Ba.matrixWorldInverse;$.copy(pa.vertexNormalsWorld[0]);ab=($.x*J.n11+$.y*J.n12+$.z*J.n13)*0.5+0.5;n=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;$.copy(pa.vertexNormalsWorld[1]);C=($.x*J.n11+$.y*J.n12+$.z*J.n13)*0.5+0.5;p=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;$.copy(pa.vertexNormalsWorld[2]);o=($.x*J.n11+
|
||||
$.y*J.n12+$.z*J.n13)*0.5+0.5;w=-($.x*J.n21+$.y*J.n22+$.z*J.n23)*0.5+0.5;Ta(X,f,ea,ka,W,T,R.envMap.image,ab,n,C,p,o,w)}}else R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&&!R.wireframe){if(R.map.mapping instanceof THREE.UVMapping){La=pa.uvs[0];Ta(X,f,ea,ka,W,T,R.map.image,La[fa].u,La[fa].v,La[za].u,La[za].v,La[qa].u,La[qa].v)}c(THREE.SubtractiveBlending)}if(Z)if(!R.wireframe&&R.shading==THREE.SmoothShading&&
|
||||
pa.vertexNormalsWorld.length==3){P.r=M.r=da.r=K.r;P.g=M.g=da.g=K.g;P.b=M.b=da.b=K.b;ua(Ka,pa.v1.positionWorld,pa.vertexNormalsWorld[0],P);ua(Ka,pa.v2.positionWorld,pa.vertexNormalsWorld[1],M);ua(Ka,pa.v3.positionWorld,pa.vertexNormalsWorld[2],da);sa.r=(M.r+da.r)*0.5;sa.g=(M.g+da.g)*0.5;sa.b=(M.b+da.b)*0.5;ya=Ja(P,M,da,sa);Ta(X,f,ea,ka,W,T,ya,0,0,1,0,0,1)}else{N.r=K.r;N.g=K.g;N.b=K.b;ua(Ka,pa.centroidWorld,pa.normalWorld,N);aa.r=R.color.r*N.r;aa.g=R.color.g*N.g;aa.b=R.color.b*N.b;aa.updateStyleString();
|
||||
@@ -172,28 +172,28 @@ Oa(pa.normalWorld.x);aa.g=Oa(pa.normalWorld.y);aa.b=Oa(pa.normalWorld.z);aa.upda
|
||||
ja=za.positionScreen.y;oa=qa.positionScreen.x;la=qa.positionScreen.y;if(R instanceof THREE.MeshBasicMaterial){fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshLambertMaterial)if(Z)if(!R.wireframe&&R.shading==THREE.SmoothShading&&pa.vertexNormalsWorld.length==4){P.r=M.r=da.r=sa.r=K.r;P.g=M.g=da.g=sa.g=K.g;P.b=M.b=da.b=sa.b=K.b;ua(Ka,pa.v1.positionWorld,pa.vertexNormalsWorld[0],P);ua(Ka,pa.v2.positionWorld,pa.vertexNormalsWorld[1],
|
||||
M);ua(Ka,pa.v4.positionWorld,pa.vertexNormalsWorld[3],da);ua(Ka,pa.v3.positionWorld,pa.vertexNormalsWorld[2],sa);ya=Ja(P,M,da,sa);Sa(X,f,ea,ka,xa,ca);Ta(X,f,ea,ka,xa,ca,ya,0,0,1,0,0,1);Sa(Da,ja,W,T,oa,la);Ta(Da,ja,W,T,oa,la,ya,1,0,1,1,0,1)}else{N.r=K.r;N.g=K.g;N.b=K.b;ua(Ka,pa.centroidWorld,pa.normalWorld,N);aa.r=R.color.r*N.r;aa.g=R.color.g*N.g;aa.b=R.color.b*N.b;aa.updateStyleString();fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else{fb(X,f,
|
||||
ea,ka,W,T,xa,ca);R.wireframe?Na(R.color.__styleString,R.wireframeLinewidth):Xa(R.color.__styleString)}else if(R instanceof THREE.MeshNormalMaterial){aa.r=Oa(pa.normalWorld.x);aa.g=Oa(pa.normalWorld.y);aa.b=Oa(pa.normalWorld.z);aa.updateStyleString();fb(X,f,ea,ka,W,T,xa,ca);R.wireframe?Na(aa.__styleString,R.wireframeLinewidth):Xa(aa.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){ia=Ba.near;ta=Ba.far;P.r=P.g=P.b=1-Va(J.positionScreen.z,ia,ta);M.r=M.g=M.b=1-Va(Y.positionScreen.z,ia,ta);
|
||||
da.r=da.g=da.b=1-Va(fa.positionScreen.z,ia,ta);sa.r=sa.g=sa.b=1-Va(U.positionScreen.z,ia,ta);ya=Ja(P,M,da,sa);Sa(X,f,ea,ka,xa,ca);Ta(X,f,ea,ka,xa,ca,ya,0,0,1,0,0,1);Sa(Da,ja,W,T,oa,la);Ta(Da,ja,W,T,oa,la,ya,1,0,1,1,0,1)}}}function Sa(J,Y,U,fa,za,qa){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(J,Y);m.closePath()}function fb(J,Y,U,fa,za,qa,pa,R){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(pa,R);m.lineTo(J,Y);m.closePath()}function Na(J,Y){if(A!=J)m.strokeStyle=
|
||||
A=J;if(H!=Y)m.lineWidth=H=Y;m.stroke();F.inflate(Y*2)}function Xa(J){if(G!=J)m.fillStyle=G=J;m.fill()}function Ta(J,Y,U,fa,za,qa,pa,R,Ka,cb,Za,db,hb){var bb,eb;bb=pa.width-1;eb=pa.height-1;R*=bb;Ka*=eb;cb*=bb;Za*=eb;db*=bb;hb*=eb;U-=J;fa-=Y;za-=J;qa-=Y;cb-=R;Za-=Ka;db-=R;hb-=Ka;bb=cb*hb-db*Za;if(bb!=0){eb=1/bb;bb=(hb*U-Za*za)*eb;Za=(hb*fa-Za*qa)*eb;U=(cb*za-db*U)*eb;fa=(cb*qa-db*fa)*eb;J=J-bb*R-U*Ka;Y=Y-Za*R-fa*Ka;m.save();m.transform(bb,Za,U,fa,J,Y);m.clip();m.drawImage(pa,0,0);m.restore()}}function Ja(J,
|
||||
da.r=da.g=da.b=1-Va(fa.positionScreen.z,ia,ta);sa.r=sa.g=sa.b=1-Va(U.positionScreen.z,ia,ta);ya=Ja(P,M,da,sa);Sa(X,f,ea,ka,xa,ca);Ta(X,f,ea,ka,xa,ca,ya,0,0,1,0,0,1);Sa(Da,ja,W,T,oa,la);Ta(Da,ja,W,T,oa,la,ya,1,0,1,1,0,1)}}}function Sa(J,Y,U,fa,za,qa){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(J,Y);m.closePath()}function fb(J,Y,U,fa,za,qa,pa,R){m.beginPath();m.moveTo(J,Y);m.lineTo(U,fa);m.lineTo(za,qa);m.lineTo(pa,R);m.lineTo(J,Y);m.closePath()}function Na(J,Y){if(z!=J)m.strokeStyle=
|
||||
z=J;if(H!=Y)m.lineWidth=H=Y;m.stroke();F.inflate(Y*2)}function Xa(J){if(G!=J)m.fillStyle=G=J;m.fill()}function Ta(J,Y,U,fa,za,qa,pa,R,Ka,cb,Za,db,hb){var bb,eb;bb=pa.width-1;eb=pa.height-1;R*=bb;Ka*=eb;cb*=bb;Za*=eb;db*=bb;hb*=eb;U-=J;fa-=Y;za-=J;qa-=Y;cb-=R;Za-=Ka;db-=R;hb-=Ka;bb=cb*hb-db*Za;if(bb!=0){eb=1/bb;bb=(hb*U-Za*za)*eb;Za=(hb*fa-Za*qa)*eb;U=(cb*za-db*U)*eb;fa=(cb*qa-db*fa)*eb;J=J-bb*R-U*Ka;Y=Y-Za*R-fa*Ka;m.save();m.transform(bb,Za,U,fa,J,Y);m.clip();m.drawImage(pa,0,0);m.restore()}}function Ja(J,
|
||||
Y,U,fa){var za=~~(J.r*255),qa=~~(J.g*255);J=~~(J.b*255);var pa=~~(Y.r*255),R=~~(Y.g*255);Y=~~(Y.b*255);var Ka=~~(U.r*255),cb=~~(U.g*255);U=~~(U.b*255);var Za=~~(fa.r*255),db=~~(fa.g*255);fa=~~(fa.b*255);Ma[0]=za<0?0:za>255?255:za;Ma[1]=qa<0?0:qa>255?255:qa;Ma[2]=J<0?0:J>255?255:J;Ma[4]=pa<0?0:pa>255?255:pa;Ma[5]=R<0?0:R>255?255:R;Ma[6]=Y<0?0:Y>255?255:Y;Ma[8]=Ka<0?0:Ka>255?255:Ka;Ma[9]=cb<0?0:cb>255?255:cb;Ma[10]=U<0?0:U>255?255:U;Ma[12]=Za<0?0:Za>255?255:Za;Ma[13]=db<0?0:db>255?255:db;Ma[14]=fa<
|
||||
0?0:fa>255?255:fa;ma.putImageData(Ga,0,0);Ia.drawImage(Aa,0,0);return wa}function Va(J,Y,U){J=(J-Y)/(U-Y);return J*J*(3-2*J)}function Oa(J){J=(J+1)*0.5;return J<0?0:J>1?1:J}function L(J,Y){var U=Y.x-J.x,fa=Y.y-J.y,za=1/Math.sqrt(U*U+fa*fa);U*=za;fa*=za;Y.x+=U;Y.y+=fa;J.x-=U;J.y-=fa}var Qa,Ua,Fa,$a,Wa,Ha,Ra,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);b=d.projectScene(Ca,Ba,this.sortElements);(Z=Ca.lights.length>0)&&Ya(Ca);Qa=0;for(Ua=b.length;Qa<Ua;Qa++){Fa=b[Qa];F.empty();if(Fa instanceof
|
||||
THREE.RenderableParticle){E=Fa;E.x*=k;E.y*=j;$a=0;for(Wa=Fa.materials.length;$a<Wa;){va=Fa.materials[$a++];va.opacity!=0&&ga(E,Fa,va,Ca)}}else if(Fa instanceof THREE.RenderableLine){E=Fa.v1;I=Fa.v2;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;F.addPoint(E.positionScreen.x,E.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.materials.length;$a<Wa;){va=Fa.materials[$a++];va.opacity!=0&&ha(E,I,Fa,va,Ca)}}}else if(Fa instanceof
|
||||
THREE.RenderableFace3){E=Fa.v1;I=Fa.v2;z=Fa.v3;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;z.positionScreen.x*=k;z.positionScreen.y*=j;if(Fa.overdraw){L(E.positionScreen,I.positionScreen);L(I.positionScreen,z.positionScreen);L(z.positionScreen,E.positionScreen)}F.add3Points(E.positionScreen.x,E.positionScreen.y,I.positionScreen.x,I.positionScreen.y,z.positionScreen.x,z.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.meshMaterials.length;$a<Wa;){va=
|
||||
Fa.meshMaterials[$a++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(Ra=Fa.faceMaterials.length;Ha<Ra;)(va=Fa.faceMaterials[Ha++])&&va.opacity!=0&&na(E,I,z,0,1,2,Fa,va,Ca)}else va.opacity!=0&&na(E,I,z,0,1,2,Fa,va,Ca)}}}else if(Fa instanceof THREE.RenderableFace4){E=Fa.v1;I=Fa.v2;z=Fa.v3;S=Fa.v4;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;z.positionScreen.x*=k;z.positionScreen.y*=j;S.positionScreen.x*=k;S.positionScreen.y*=j;Q.positionScreen.copy(I.positionScreen);
|
||||
O.positionScreen.copy(S.positionScreen);if(Fa.overdraw){L(E.positionScreen,I.positionScreen);L(I.positionScreen,S.positionScreen);L(S.positionScreen,E.positionScreen);L(z.positionScreen,Q.positionScreen);L(z.positionScreen,O.positionScreen)}F.addPoint(E.positionScreen.x,E.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);F.addPoint(z.positionScreen.x,z.positionScreen.y);F.addPoint(S.positionScreen.x,S.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.meshMaterials.length;$a<
|
||||
Wa;){va=Fa.meshMaterials[$a++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(Ra=Fa.faceMaterials.length;Ha<Ra;)(va=Fa.faceMaterials[Ha++])&&va.opacity!=0&&Pa(E,I,z,S,Q,O,Fa,va,Ca)}else va.opacity!=0&&Pa(E,I,z,S,Q,O,Fa,va,Ca)}}}B.addRectangle(F)}m.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.RenderableFace3){E=Fa.v1;I=Fa.v2;A=Fa.v3;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;A.positionScreen.x*=k;A.positionScreen.y*=j;if(Fa.overdraw){L(E.positionScreen,I.positionScreen);L(I.positionScreen,A.positionScreen);L(A.positionScreen,E.positionScreen)}F.add3Points(E.positionScreen.x,E.positionScreen.y,I.positionScreen.x,I.positionScreen.y,A.positionScreen.x,A.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.meshMaterials.length;$a<Wa;){va=
|
||||
Fa.meshMaterials[$a++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(Ra=Fa.faceMaterials.length;Ha<Ra;)(va=Fa.faceMaterials[Ha++])&&va.opacity!=0&&na(E,I,A,0,1,2,Fa,va,Ca)}else va.opacity!=0&&na(E,I,A,0,1,2,Fa,va,Ca)}}}else if(Fa instanceof THREE.RenderableFace4){E=Fa.v1;I=Fa.v2;A=Fa.v3;S=Fa.v4;E.positionScreen.x*=k;E.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;A.positionScreen.x*=k;A.positionScreen.y*=j;S.positionScreen.x*=k;S.positionScreen.y*=j;Q.positionScreen.copy(I.positionScreen);
|
||||
O.positionScreen.copy(S.positionScreen);if(Fa.overdraw){L(E.positionScreen,I.positionScreen);L(I.positionScreen,S.positionScreen);L(S.positionScreen,E.positionScreen);L(A.positionScreen,Q.positionScreen);L(A.positionScreen,O.positionScreen)}F.addPoint(E.positionScreen.x,E.positionScreen.y);F.addPoint(I.positionScreen.x,I.positionScreen.y);F.addPoint(A.positionScreen.x,A.positionScreen.y);F.addPoint(S.positionScreen.x,S.positionScreen.y);if(D.instersects(F)){$a=0;for(Wa=Fa.meshMaterials.length;$a<
|
||||
Wa;){va=Fa.meshMaterials[$a++];if(va instanceof THREE.MeshFaceMaterial){Ha=0;for(Ra=Fa.faceMaterials.length;Ha<Ra;)(va=Fa.faceMaterials[Ha++])&&va.opacity!=0&&Pa(E,I,A,S,Q,O,Fa,va,Ca)}else va.opacity!=0&&Pa(E,I,A,S,Q,O,Fa,va,Ca)}}}B.addRectangle(F)}m.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function a(ja,oa,la){var aa,P,M,da;aa=0;for(P=ja.lights.length;aa<P;aa++){M=ja.lights[aa];if(M instanceof THREE.DirectionalLight){da=oa.normalWorld.dot(M.position)*M.intensity;if(da>0){la.r+=M.color.r*da;la.g+=M.color.g*da;la.b+=M.color.b*da}}else if(M instanceof THREE.PointLight){ea.sub(M.position,oa.centroidWorld);ea.normalize();da=oa.normalWorld.dot(ea)*M.intensity;if(da>0){la.r+=M.color.r*da;la.g+=M.color.g*da;la.b+=M.color.b*da}}}}function c(ja,oa,la,aa,P,M){T=d(xa++);
|
||||
T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+"z");if(P instanceof THREE.MeshBasicMaterial)z.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(M,aa,S);z.r=P.color.r*S.r;z.g=P.color.g*S.g;z.b=P.color.b*S.b;z.updateStyleString()}else z.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshDepthMaterial){f=
|
||||
1-P.__2near/(P.__farPlusNear-aa.z*P.__farMinusNear);z.setRGB(f,f,f)}else P instanceof THREE.MeshNormalMaterial&&z.setRGB(e(aa.normalWorld.x),e(aa.normalWorld.y),e(aa.normalWorld.z));P.wireframe?T.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+P.wireframeLinewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.wireframeLinecap+"; stroke-linejoin: "+P.wireframeLinejoin):T.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+P.opacity);k.appendChild(T)}
|
||||
function b(ja,oa,la,aa,P,M,da){T=d(xa++);T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)z.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(da,P,S);z.r=M.color.r*S.r;z.g=M.color.g*S.g;z.b=M.color.b*S.b;z.updateStyleString()}else z.__styleString=
|
||||
M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){f=1-M.__2near/(M.__farPlusNear-P.z*M.__farMinusNear);z.setRGB(f,f,f)}else M instanceof THREE.MeshNormalMaterial&&z.setRGB(e(P.normalWorld.x),e(P.normalWorld.y),e(P.normalWorld.z));M.wireframe?T.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):T.setAttribute("style","fill: "+
|
||||
z.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(T)}function d(ja){if(ka[ja]==null){ka[ja]=document.createElementNS("http://www.w3.org/2000/svg","path");Da==0&&ka[ja].setAttribute("shape-rendering","crispEdges")}return ka[ja]}function e(ja){return ja<0?Math.min((1+ja)*0.5,0.5):0.5+Math.min(ja*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,t,x,y,q,A,G,H=new THREE.Rectangle,E=new THREE.Rectangle,I=!1,z=new THREE.Color(16777215),
|
||||
T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+"z");if(P instanceof THREE.MeshBasicMaterial)A.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(M,aa,S);A.r=P.color.r*S.r;A.g=P.color.g*S.g;A.b=P.color.b*S.b;A.updateStyleString()}else A.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshDepthMaterial){f=
|
||||
1-P.__2near/(P.__farPlusNear-aa.z*P.__farMinusNear);A.setRGB(f,f,f)}else P instanceof THREE.MeshNormalMaterial&&A.setRGB(e(aa.normalWorld.x),e(aa.normalWorld.y),e(aa.normalWorld.z));P.wireframe?T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+P.wireframeLinewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.wireframeLinecap+"; stroke-linejoin: "+P.wireframeLinejoin):T.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+P.opacity);k.appendChild(T)}
|
||||
function b(ja,oa,la,aa,P,M,da){T=d(xa++);T.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+la.positionScreen.x+","+la.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)A.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(I){S.r=Q.r;S.g=Q.g;S.b=Q.b;a(da,P,S);A.r=M.color.r*S.r;A.g=M.color.g*S.g;A.b=M.color.b*S.b;A.updateStyleString()}else A.__styleString=
|
||||
M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){f=1-M.__2near/(M.__farPlusNear-P.z*M.__farMinusNear);A.setRGB(f,f,f)}else M instanceof THREE.MeshNormalMaterial&&A.setRGB(e(P.normalWorld.x),e(P.normalWorld.y),e(P.normalWorld.z));M.wireframe?T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+M.wireframeLinewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframeLinecap+"; stroke-linejoin: "+M.wireframeLinejoin):T.setAttribute("style","fill: "+
|
||||
A.__styleString+"; fill-opacity: "+M.opacity);k.appendChild(T)}function d(ja){if(ka[ja]==null){ka[ja]=document.createElementNS("http://www.w3.org/2000/svg","path");Da==0&&ka[ja].setAttribute("shape-rendering","crispEdges")}return ka[ja]}function e(ja){return ja<0?Math.min((1+ja)*0.5,0.5):0.5+Math.min(ja*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,t,x,y,q,z,G,H=new THREE.Rectangle,E=new THREE.Rectangle,I=!1,A=new THREE.Color(16777215),
|
||||
S=new THREE.Color(16777215),Q=new THREE.Color(0),O=new THREE.Color(0),X=new THREE.Color(0),f,ea=new THREE.Vector3,ka=[],W=[],T,xa,ca,Da=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ja){switch(ja){case "high":Da=1;break;case "low":Da=0}};this.setSize=function(ja,oa){j=ja;m=oa;t=j/2;x=m/2;k.setAttribute("viewBox",-t+" "+-x+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);H.set(-t,-x,t,x)};this.clear=function(){for(;k.childNodes.length>
|
||||
0;)k.removeChild(k.childNodes[0])};this.render=function(ja,oa){var la,aa,P,M,da,sa,ia,ta;this.autoClear&&this.clear();g=h.projectScene(ja,oa,this.sortElements);ca=xa=0;if(I=ja.lights.length>0){ia=ja.lights;Q.setRGB(0,0,0);O.setRGB(0,0,0);X.setRGB(0,0,0);la=0;for(aa=ia.length;la<aa;la++){P=ia[la];M=P.color;if(P instanceof THREE.AmbientLight){Q.r+=M.r;Q.g+=M.g;Q.b+=M.b}else if(P instanceof THREE.DirectionalLight){O.r+=M.r;O.g+=M.g;O.b+=M.b}else if(P instanceof THREE.PointLight){X.r+=M.r;X.g+=M.g;X.b+=
|
||||
M.b}}}la=0;for(aa=g.length;la<aa;la++){ia=g[la];E.empty();if(ia instanceof THREE.RenderableParticle){y=ia;y.x*=t;y.y*=-x;P=0;for(M=ia.materials.length;P<M;)P++}else if(ia instanceof THREE.RenderableLine){y=ia.v1;q=ia.v2;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(E)){P=0;for(M=ia.materials.length;P<M;)if((ta=ia.materials[P++])&&ta.opacity!=
|
||||
0){da=y;sa=q;var ya=ca++;if(W[ya]==null){W[ya]=document.createElementNS("http://www.w3.org/2000/svg","line");Da==0&&W[ya].setAttribute("shape-rendering","crispEdges")}T=W[ya];T.setAttribute("x1",da.positionScreen.x);T.setAttribute("y1",da.positionScreen.y);T.setAttribute("x2",sa.positionScreen.x);T.setAttribute("y2",sa.positionScreen.y);if(ta instanceof THREE.LineBasicMaterial){z.__styleString=ta.color.__styleString;T.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+
|
||||
ta.linewidth+"; stroke-opacity: "+ta.opacity+"; stroke-linecap: "+ta.linecap+"; stroke-linejoin: "+ta.linejoin);k.appendChild(T)}}}}else if(ia instanceof THREE.RenderableFace3){y=ia.v1;q=ia.v2;A=ia.v3;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;A.positionScreen.x*=t;A.positionScreen.y*=-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);E.addPoint(A.positionScreen.x,A.positionScreen.y);if(H.instersects(E)){P=
|
||||
0;for(M=ia.meshMaterials.length;P<M;){ta=ia.meshMaterials[P++];if(ta instanceof THREE.MeshFaceMaterial){da=0;for(sa=ia.faceMaterials.length;da<sa;)(ta=ia.faceMaterials[da++])&&ta.opacity!=0&&c(y,q,A,ia,ta,ja)}else ta&&ta.opacity!=0&&c(y,q,A,ia,ta,ja)}}}else if(ia instanceof THREE.RenderableFace4){y=ia.v1;q=ia.v2;A=ia.v3;G=ia.v4;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;A.positionScreen.x*=t;A.positionScreen.y*=-x;G.positionScreen.x*=t;G.positionScreen.y*=
|
||||
-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);E.addPoint(A.positionScreen.x,A.positionScreen.y);E.addPoint(G.positionScreen.x,G.positionScreen.y);if(H.instersects(E)){P=0;for(M=ia.meshMaterials.length;P<M;){ta=ia.meshMaterials[P++];if(ta instanceof THREE.MeshFaceMaterial){da=0;for(sa=ia.faceMaterials.length;da<sa;)(ta=ia.faceMaterials[da++])&&ta.opacity!=0&&b(y,q,A,G,ia,ta,ja)}else ta&&ta.opacity!=0&&b(y,q,A,G,ia,ta,ja)}}}}}};
|
||||
0){da=y;sa=q;var ya=ca++;if(W[ya]==null){W[ya]=document.createElementNS("http://www.w3.org/2000/svg","line");Da==0&&W[ya].setAttribute("shape-rendering","crispEdges")}T=W[ya];T.setAttribute("x1",da.positionScreen.x);T.setAttribute("y1",da.positionScreen.y);T.setAttribute("x2",sa.positionScreen.x);T.setAttribute("y2",sa.positionScreen.y);if(ta instanceof THREE.LineBasicMaterial){A.__styleString=ta.color.__styleString;T.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+
|
||||
ta.linewidth+"; stroke-opacity: "+ta.opacity+"; stroke-linecap: "+ta.linecap+"; stroke-linejoin: "+ta.linejoin);k.appendChild(T)}}}}else if(ia instanceof THREE.RenderableFace3){y=ia.v1;q=ia.v2;z=ia.v3;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;z.positionScreen.x*=t;z.positionScreen.y*=-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);E.addPoint(z.positionScreen.x,z.positionScreen.y);if(H.instersects(E)){P=
|
||||
0;for(M=ia.meshMaterials.length;P<M;){ta=ia.meshMaterials[P++];if(ta instanceof THREE.MeshFaceMaterial){da=0;for(sa=ia.faceMaterials.length;da<sa;)(ta=ia.faceMaterials[da++])&&ta.opacity!=0&&c(y,q,z,ia,ta,ja)}else ta&&ta.opacity!=0&&c(y,q,z,ia,ta,ja)}}}else if(ia instanceof THREE.RenderableFace4){y=ia.v1;q=ia.v2;z=ia.v3;G=ia.v4;y.positionScreen.x*=t;y.positionScreen.y*=-x;q.positionScreen.x*=t;q.positionScreen.y*=-x;z.positionScreen.x*=t;z.positionScreen.y*=-x;G.positionScreen.x*=t;G.positionScreen.y*=
|
||||
-x;E.addPoint(y.positionScreen.x,y.positionScreen.y);E.addPoint(q.positionScreen.x,q.positionScreen.y);E.addPoint(z.positionScreen.x,z.positionScreen.y);E.addPoint(G.positionScreen.x,G.positionScreen.y);if(H.instersects(E)){P=0;for(M=ia.meshMaterials.length;P<M;){ta=ia.meshMaterials[P++];if(ta instanceof THREE.MeshFaceMaterial){da=0;for(sa=ia.faceMaterials.length;da<sa;)(ta=ia.faceMaterials[da++])&&ta.opacity!=0&&b(y,q,z,G,ia,ta,ja)}else ta&&ta.opacity!=0&&b(y,q,z,G,ia,ta,ja)}}}}}};
|
||||
THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
|
||||
envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
|
||||
envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
|
||||
@@ -240,11 +240,11 @@ f.drawArrays(f.TRIANGLE_STRIP,0,w.__webGLVertexCount)}}function g(n,C){if(!n.__w
|
||||
f.bufferData(f.ARRAY_BUFFER,n.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(C.attributes.normal);f.vertexAttribPointer(C.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,n.count);n.count=0}function h(n){if(T!=n.doubleSided){n.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);T=n.doubleSided}if(xa!=n.flipSided){n.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);xa=n.flipSided}}function k(n){if(Da!=n){n?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);Da=n}}function j(n){P[0].set(n.n41-
|
||||
n.n11,n.n42-n.n12,n.n43-n.n13,n.n44-n.n14);P[1].set(n.n41+n.n11,n.n42+n.n12,n.n43+n.n13,n.n44+n.n14);P[2].set(n.n41+n.n21,n.n42+n.n22,n.n43+n.n23,n.n44+n.n24);P[3].set(n.n41-n.n21,n.n42-n.n22,n.n43-n.n23,n.n44-n.n24);P[4].set(n.n41-n.n31,n.n42-n.n32,n.n43-n.n33,n.n44-n.n34);P[5].set(n.n41+n.n31,n.n42+n.n32,n.n43+n.n33,n.n44+n.n34);var C;for(n=0;n<6;n++){C=P[n];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}}function m(n){for(var C=n.matrixWorld,p=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,
|
||||
Math.max(n.scale.y,n.scale.z)),o=0;o<6;o++){n=P[o].x*C.n14+P[o].y*C.n24+P[o].z*C.n34+P[o].w;if(n<=p)return!1}return!0}function t(n,C){n.list[n.count]=C;n.count+=1}function x(n){var C,p,o=n.object,w=n.opaque,D=n.transparent;D.count=0;n=w.count=0;for(C=o.materials.length;n<C;n++){p=o.materials[n];p.opacity&&p.opacity<1||p.blending!=THREE.NormalBlending?t(D,p):t(w,p)}}function y(n){var C,p,o,w,D=n.object,B=n.buffer,F=n.opaque,Z=n.transparent;Z.count=0;n=F.count=0;for(o=D.materials.length;n<o;n++){C=
|
||||
D.materials[n];if(C instanceof THREE.MeshFaceMaterial){C=0;for(p=B.materials.length;C<p;C++)(w=B.materials[C])&&(w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(Z,w):t(F,w))}else{w=C;w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(Z,w):t(F,w)}}}function q(n,C){return C.z-n.z}function A(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function G(n){function C(Ea){var $=
|
||||
D.materials[n];if(C instanceof THREE.MeshFaceMaterial){C=0;for(p=B.materials.length;C<p;C++)(w=B.materials[C])&&(w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(Z,w):t(F,w))}else{w=C;w.opacity&&w.opacity<1||w.blending!=THREE.NormalBlending?t(Z,w):t(F,w)}}}function q(n,C){return C.z-n.z}function z(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function G(n){function C(Ea){var $=
|
||||
[];p=0;for(o=Ea.length;p<o;p++)Ea[p]==undefined?$.push("undefined"):$.push(Ea[p].id);return $.join("_")}var p,o,w,D,B,F,Z,N,K={},ra=n.morphTargets!==undefined?n.morphTargets.length:0;n.geometryGroups={};w=0;for(D=n.faces.length;w<D;w++){B=n.faces[w];F=B.materials;Z=C(F);K[Z]==undefined&&(K[Z]={hash:Z,counter:0});N=K[Z].hash+"_"+K[Z].counter;n.geometryGroups[N]==undefined&&(n.geometryGroups[N]={faces:[],materials:F,vertices:0,numMorphTargets:ra});B=B instanceof THREE.Face3?3:4;if(n.geometryGroups[N].vertices+
|
||||
B>65535){K[Z].counter+=1;N=K[Z].hash+"_"+K[Z].counter;n.geometryGroups[N]==undefined&&(n.geometryGroups[N]={faces:[],materials:F,vertices:0,numMorphTargets:ra})}n.geometryGroups[N].faces.push(w);n.geometryGroups[N].vertices+=B}}function H(n,C,p){n.push({buffer:C,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function E(n){if(n!=ca){switch(n){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,
|
||||
f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}ca=n}}function I(n,C,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){f.texParameteri(n,f.TEXTURE_WRAP_S,O(C.wrapS));f.texParameteri(n,f.TEXTURE_WRAP_T,O(C.wrapT));f.texParameteri(n,f.TEXTURE_MAG_FILTER,
|
||||
O(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,O(C.minFilter));f.generateMipmap(n)}else{f.texParameteri(n,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_MAG_FILTER,Q(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,Q(C.minFilter))}}function z(n){if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=f.createFramebuffer();n.__webGLRenderbuffer=f.createRenderbuffer();n.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,
|
||||
O(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,O(C.minFilter));f.generateMipmap(n)}else{f.texParameteri(n,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(n,f.TEXTURE_MAG_FILTER,Q(C.magFilter));f.texParameteri(n,f.TEXTURE_MIN_FILTER,Q(C.minFilter))}}function A(n){if(n&&!n.__webGLFramebuffer){n.__webGLFramebuffer=f.createFramebuffer();n.__webGLRenderbuffer=f.createRenderbuffer();n.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,
|
||||
n.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,n.width,n.height);f.bindTexture(f.TEXTURE_2D,n.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,O(n.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,O(n.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,O(n.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,O(n.minFilter));f.texImage2D(f.TEXTURE_2D,0,O(n.format),n.width,n.height,0,O(n.format),O(n.type),null);f.bindFramebuffer(f.FRAMEBUFFER,
|
||||
n.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,n.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,n.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var C,p;if(n){C=n.__webGLFramebuffer;p=n.width;n=n.height}else{C=null;p=la;n=aa}if(C!=ka){f.bindFramebuffer(f.FRAMEBUFFER,C);f.viewport(ja,oa,p,n);ka=C}}function S(n,C){var p;if(n==
|
||||
"fragment")p=f.createShader(f.FRAGMENT_SHADER);else n=="vertex"&&(p=f.createShader(f.VERTEX_SHADER));f.shaderSource(p,C);f.compileShader(p);if(!f.getShaderParameter(p,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(p));console.error(C);return null}return p}function Q(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}}
|
||||
@@ -263,8 +263,8 @@ w=n.program;K=0;for(C=p.length;K<C;K++){B=p[K];w.uniforms[B]=f.getUniformLocatio
|
||||
D.tangent>=0&&f.enableVertexAttribArray(D.tangent);if(n.skinning&&D.skinVertexA>=0&&D.skinVertexB>=0&&D.skinIndex>=0&&D.skinWeight>=0){f.enableVertexAttribArray(D.skinVertexA);f.enableVertexAttribArray(D.skinVertexB);f.enableVertexAttribArray(D.skinIndex);f.enableVertexAttribArray(D.skinWeight)}if(n.morphTargets){n.numSupportedMorphTargets=0;if(D.morphTarget0>=0){f.enableVertexAttribArray(D.morphTarget0);n.numSupportedMorphTargets++}if(D.morphTarget1>=0){f.enableVertexAttribArray(D.morphTarget1);
|
||||
n.numSupportedMorphTargets++}if(D.morphTarget2>=0){f.enableVertexAttribArray(D.morphTarget2);n.numSupportedMorphTargets++}if(D.morphTarget3>=0){f.enableVertexAttribArray(D.morphTarget3);n.numSupportedMorphTargets++}if(D.morphTarget4>=0){f.enableVertexAttribArray(D.morphTarget4);n.numSupportedMorphTargets++}if(D.morphTarget5>=0){f.enableVertexAttribArray(D.morphTarget5);n.numSupportedMorphTargets++}if(D.morphTarget6>=0){f.enableVertexAttribArray(D.morphTarget6);n.numSupportedMorphTargets++}if(D.morphTarget7>=
|
||||
0){f.enableVertexAttribArray(D.morphTarget7);n.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(w=0;w<this.maxMorphTargets;w++)o.__webGLMorphTargetInfluences[w]=0}};this.render=function(n,C,p,o){var w,D,B,F,Z,N,K,ra,Ea=n.lights,$=n.fog;C.matrixAutoUpdate&&C.updateMatrix();n.update(undefined,!1,C);C.matrixWorldInverse.flattenToArray(sa);C.projectionMatrix.flattenToArray(da);M.multiply(C.projectionMatrix,C.matrixWorldInverse);j(M);this.initWebGLObjects(n);
|
||||
z(p);(this.autoClear||o)&&this.clear();Z=n.__webglObjects.length;for(o=0;o<Z;o++){w=n.__webglObjects[o];K=w.object;if(K.visible)if(!(K instanceof THREE.Mesh)||m(K)){K.matrixWorld.flattenToArray(K._objectMatrixArray);A(K,C);y(w);w.render=!0;if(this.sortObjects){ia.copy(K.position);M.multiplyVector3(ia);w.z=ia.z}}else w.render=!1;else w.render=!1}this.sortObjects&&n.__webglObjects.sort(q);N=n.__webglObjectsImmediate.length;for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){K.matrixAutoUpdate&&
|
||||
K.matrixWorld.flattenToArray(K._objectMatrixArray);A(K,C);x(w)}}E(THREE.NormalBlending);for(o=0;o<Z;o++){w=n.__webglObjects[o];if(w.render){K=w.object;ra=w.buffer;B=w.opaque;h(K);for(w=0;w<B.count;w++){F=B.list[w];k(F.depthTest);e(C,Ea,$,F,ra,K)}}}for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){B=w.opaque;h(K);for(w=0;w<B.count;w++){F=B.list[w];k(F.depthTest);D=d(C,Ea,$,F,K);K.render(function(Aa){g(Aa,D)})}}}for(o=0;o<Z;o++){w=n.__webglObjects[o];if(w.render){K=w.object;ra=
|
||||
A(p);(this.autoClear||o)&&this.clear();Z=n.__webglObjects.length;for(o=0;o<Z;o++){w=n.__webglObjects[o];K=w.object;if(K.visible)if(!(K instanceof THREE.Mesh)||m(K)){K.matrixWorld.flattenToArray(K._objectMatrixArray);z(K,C);y(w);w.render=!0;if(this.sortObjects){ia.copy(K.position);M.multiplyVector3(ia);w.z=ia.z}}else w.render=!1;else w.render=!1}this.sortObjects&&n.__webglObjects.sort(q);N=n.__webglObjectsImmediate.length;for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){K.matrixAutoUpdate&&
|
||||
K.matrixWorld.flattenToArray(K._objectMatrixArray);z(K,C);x(w)}}E(THREE.NormalBlending);for(o=0;o<Z;o++){w=n.__webglObjects[o];if(w.render){K=w.object;ra=w.buffer;B=w.opaque;h(K);for(w=0;w<B.count;w++){F=B.list[w];k(F.depthTest);e(C,Ea,$,F,ra,K)}}}for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){B=w.opaque;h(K);for(w=0;w<B.count;w++){F=B.list[w];k(F.depthTest);D=d(C,Ea,$,F,K);K.render(function(Aa){g(Aa,D)})}}}for(o=0;o<Z;o++){w=n.__webglObjects[o];if(w.render){K=w.object;ra=
|
||||
w.buffer;B=w.transparent;h(K);for(w=0;w<B.count;w++){F=B.list[w];E(F.blending);k(F.depthTest);e(C,Ea,$,F,ra,K)}}}for(o=0;o<N;o++){w=n.__webglObjectsImmediate[o];K=w.object;if(K.visible){B=w.transparent;h(K);for(w=0;w<B.count;w++){F=B.list[w];E(F.blending);k(F.depthTest);D=d(C,Ea,$,F,K);K.render(function(Aa){g(Aa,D)})}}}if(p&&p.minFilter!==THREE.NearestFilter&&p.minFilter!==THREE.LinearFilter){f.bindTexture(f.TEXTURE_2D,p.__webGLTexture);f.generateMipmap(f.TEXTURE_2D);f.bindTexture(f.TEXTURE_2D,null)}};
|
||||
this.initWebGLObjects=function(n){if(!n.__webglObjects){n.__webglObjects=[];n.__webglObjectsImmediate=[]}for(;n.__objectsAdded.length;){var C=n.__objectsAdded[0],p=n,o=void 0,w=void 0,D=void 0;if(C._modelViewMatrix==undefined){C._modelViewMatrix=new THREE.Matrix4;C._normalMatrixArray=new Float32Array(9);C._modelViewMatrixArray=new Float32Array(16);C._objectMatrixArray=new Float32Array(16);C.matrixWorld.flattenToArray(C._objectMatrixArray)}if(C instanceof THREE.Mesh){w=C.geometry;w.geometryGroups==
|
||||
undefined&&G(w);for(o in w.geometryGroups){D=w.geometryGroups[o];if(!D.__webGLVertexBuffer){var B=D;B.__webGLVertexBuffer=f.createBuffer();B.__webGLNormalBuffer=f.createBuffer();B.__webGLTangentBuffer=f.createBuffer();B.__webGLColorBuffer=f.createBuffer();B.__webGLUVBuffer=f.createBuffer();B.__webGLUV2Buffer=f.createBuffer();B.__webGLSkinVertexABuffer=f.createBuffer();B.__webGLSkinVertexBBuffer=f.createBuffer();B.__webGLSkinIndicesBuffer=f.createBuffer();B.__webGLSkinWeightsBuffer=f.createBuffer();
|
||||
@@ -301,21 +301,21 @@ THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.posi
|
||||
THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;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.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
|
||||
THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;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.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
|
||||
THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
|
||||
var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,d=a.vertices.length,e=b?c.geometry:c,g=a.vertices,h=e.vertices,k=a.faces,j=e.faces,m=a.faceVertexUvs[0];e=e.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var t=0,x=h.length;t<x;t++){var y=new THREE.Vertex(h[t].position.clone());b&&c.matrix.multiplyVector3(y.position);g.push(y)}t=0;for(x=j.length;t<x;t++){h=j[t];var q,A=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof
|
||||
THREE.Face4&&(q=new THREE.Face4(h.a+d,h.b+d,h.c+d,h.d+d));q.centroid.copy(h.centroid);q.normal.copy(h.normal);b=0;for(g=A.length;b<g;b++){y=A[b];q.vertexNormals.push(y.clone())}q.materials=h.materials.slice();k.push(q)}t=0;for(x=e.length;t<x;t++){d=e[t];k=[];b=0;for(g=d.length;b<g;b++)k.push(new THREE.UV(d[b].u,d[b].v));m.push(k)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,e=new THREE.Texture(d,c);d.onload=function(){e.needsUpdate=!0;b&&b(this)};d.src=a;return e},loadTextureCube:function(a,
|
||||
c,b){var d,e=[],g=new THREE.Texture(e,c);c=e.loadCount=0;for(d=a.length;c<d;++c){e[c]=new Image;e[c].onload=function(){e.loadCount+=1;if(e.loadCount==6)g.needsUpdate=!0;b&&b(this)};e[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,c,b,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(e){function g(){for(t in X.objects)if(!ca.objects[t]){G=X.objects[t];if(z=ca.geometries[G.geometry]){O=[];for(i=0;i<G.materials.length;i++)O[i]=ca.materials[G.materials[i]];H=G.position;r=G.rotation;s=
|
||||
G.scale;object=new THREE.Mesh(z,O);object.position.set(H[0],H[1],H[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=G.visible;ca.scene.addObject(object);ca.objects[t]=object}}}function h(Da){return function(ja){ca.geometries[Da]=ja;g();ka-=1;k()}}function k(){d({total_models:T,total_textures:xa,loaded_models:T-ka,loaded_textures:xa-W},ca);ka==0&&W==0&&b(ca)}var j,m,t,x,y,q,A,G,H,E,I,z,S,Q,O,X,f,ea,ka,W,T,xa,ca;X=e.data;f=new THREE.BinaryLoader;ea=new THREE.JSONLoader;
|
||||
W=ka=0;ca={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};e=function(){W-=1;k()};for(y in X.cameras){E=X.cameras[y];if(E.type=="perspective")S=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho"){S=new THREE.Camera;S.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far)}H=E.position;E=E.target;S.position.set(H[0],H[1],H[2]);S.target.position.set(E[0],E[1],E[2]);ca.cameras[y]=S}for(x in X.lights){y=
|
||||
X.lights[x];if(y.type=="directional"){H=y.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],H[2]);light.position.normalize()}else if(y.type=="point"){H=y.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}E=y.color;i=y.intensity||1;light.color.setRGB(E[0]*i,E[1]*i,E[2]*i);ca.scene.addLight(light);ca.lights[x]=light}for(q in X.fogs){x=X.fogs[q];if(x.type=="linear")Q=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(Q=new THREE.FogExp2(0,x.density));E=x.color;
|
||||
Q.color.setRGB(E[0],E[1],E[2]);ca.fogs[q]=Q}if(ca.cameras&&X.defaults.camera)ca.currentCamera=ca.cameras[X.defaults.camera];if(ca.fogs&&X.defaults.fog)ca.scene.fog=ca.fogs[X.defaults.fog];E=X.defaults.bgcolor;ca.bgColor=new THREE.Color;ca.bgColor.setRGB(E[0],E[1],E[2]);ca.bgColorAlpha=X.defaults.bgalpha;for(j in X.geometries){q=X.geometries[j];if(q.type=="bin_mesh"||q.type=="ascii_mesh")ka+=1}T=ka;for(j in X.geometries){q=X.geometries[j];if(q.type=="cube"){z=new Cube(q.width,q.height,q.depth,q.segmentsWidth,
|
||||
q.segmentsHeight,q.segmentsDepth,null,q.flipped,q.sides);ca.geometries[j]=z}else if(q.type=="plane"){z=new Plane(q.width,q.height,q.segmentsWidth,q.segmentsHeight);ca.geometries[j]=z}else if(q.type=="sphere"){z=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);ca.geometries[j]=z}else if(q.type=="cylinder"){z=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);ca.geometries[j]=z}else if(q.type=="torus"){z=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);ca.geometries[j]=
|
||||
z}else if(q.type=="icosahedron"){z=new Icosahedron(q.subdivisions);ca.geometries[j]=z}else if(q.type=="bin_mesh")f.load({model:q.url,callback:h(j)});else q.type=="ascii_mesh"&&ea.load({model:q.url,callback:h(j)})}for(A in X.textures){j=X.textures[A];W+=j.url instanceof Array?j.url.length:1}xa=W;for(A in X.textures){j=X.textures[A];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)q=ImageUtils.loadTextureCube(j.url,j.mapping,e);else{q=ImageUtils.loadTexture(j.url,
|
||||
j.mapping,e);if(THREE[j.minFilter]!=undefined)q.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)q.magFilter=THREE[j.magFilter]}ca.textures[A]=q}for(m in X.materials){A=X.materials[m];for(I in A.parameters)if(I=="envMap"||I=="map"||I=="lightMap")A.parameters[I]=ca.textures[A.parameters[I]];else if(I=="shading")A.parameters[I]=A.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")A.parameters[I]=THREE[A.parameters[I]]?THREE[A.parameters[I]]:THREE.NormalBlending;
|
||||
else I=="combine"&&(A.parameters[I]=A.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);A=new THREE[A.type](A.parameters);ca.materials[m]=A}g();c(ca)}},addMesh:function(a,c,b,d,e,g,h,k,j,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=d;c.position.y=e;c.position.z=g;c.rotation.x=h;c.rotation.y=k;c.rotation.z=j;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,b){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,
|
||||
vertexShader:d.vertexShader,uniforms:d.uniforms});c=new THREE.Mesh(new Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);return c},addPanoramaCube:function(a,c,b){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));
|
||||
d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));c=new THREE.Mesh(new Cube(c,c,c,1,1,d,!0),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var d=c/2;c=new Plane(c,c);var e=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,c,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,c,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,c,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));
|
||||
SceneUtils.addMesh(a,c,1,0,d,0,g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,d,e=a.children.length;for(d=0;d<e;d++){b=a.children[d];c(b);SceneUtils.traverseHierarchy(b,c)}}},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}},fragmentShader:"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}",
|
||||
var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,d=a.vertices.length,e=b?c.geometry:c,g=a.vertices,h=e.vertices,k=a.faces,j=e.faces,m=a.faceVertexUvs[0];e=e.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var t=0,x=h.length;t<x;t++){var y=new THREE.Vertex(h[t].position.clone());b&&c.matrix.multiplyVector3(y.position);g.push(y)}t=0;for(x=j.length;t<x;t++){h=j[t];var q,z,G=h.vertexNormals;y=h.vertexColors;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+
|
||||
d);else h instanceof THREE.Face4&&(q=new THREE.Face4(h.a+d,h.b+d,h.c+d,h.d+d));q.normal.copy(h.normal);b=0;for(g=G.length;b<g;b++){z=G[b];q.vertexNormals.push(z.clone())}q.color.copy(h.color);b=0;for(g=y.length;b<g;b++){z=y[b];q.vertexColors.push(z.clone())}q.materials=h.materials.slice();q.centroid.copy(h.centroid);k.push(q)}t=0;for(x=e.length;t<x;t++){d=e[t];k=[];b=0;for(g=d.length;b<g;b++)k.push(new THREE.UV(d[b].u,d[b].v));m.push(k)}}},ImageUtils={loadTexture:function(a,c,b){var d=new Image,e=
|
||||
new THREE.Texture(d,c);d.onload=function(){e.needsUpdate=!0;b&&b(this)};d.src=a;return e},loadTextureCube:function(a,c,b){var d,e=[],g=new THREE.Texture(e,c);c=e.loadCount=0;for(d=a.length;c<d;++c){e[c]=new Image;e[c].onload=function(){e.loadCount+=1;if(e.loadCount==6)g.needsUpdate=!0;b&&b(this)};e[c].src=a[c]}return g}},SceneUtils={loadScene:function(a,c,b,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(e){function g(){for(t in X.objects)if(!ca.objects[t]){G=X.objects[t];if(A=ca.geometries[G.geometry]){O=
|
||||
[];for(i=0;i<G.materials.length;i++)O[i]=ca.materials[G.materials[i]];H=G.position;r=G.rotation;s=G.scale;object=new THREE.Mesh(A,O);object.position.set(H[0],H[1],H[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=G.visible;ca.scene.addObject(object);ca.objects[t]=object}}}function h(Da){return function(ja){ca.geometries[Da]=ja;g();ka-=1;k()}}function k(){d({total_models:T,total_textures:xa,loaded_models:T-ka,loaded_textures:xa-W},ca);ka==0&&W==0&&b(ca)}var j,
|
||||
m,t,x,y,q,z,G,H,E,I,A,S,Q,O,X,f,ea,ka,W,T,xa,ca;X=e.data;f=new THREE.BinaryLoader;ea=new THREE.JSONLoader;W=ka=0;ca={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};e=function(){W-=1;k()};for(y in X.cameras){E=X.cameras[y];if(E.type=="perspective")S=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho"){S=new THREE.Camera;S.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far)}H=E.position;E=E.target;
|
||||
S.position.set(H[0],H[1],H[2]);S.target.position.set(E[0],E[1],E[2]);ca.cameras[y]=S}for(x in X.lights){y=X.lights[x];if(y.type=="directional"){H=y.direction;light=new THREE.DirectionalLight;light.position.set(H[0],H[1],H[2]);light.position.normalize()}else if(y.type=="point"){H=y.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}E=y.color;i=y.intensity||1;light.color.setRGB(E[0]*i,E[1]*i,E[2]*i);ca.scene.addLight(light);ca.lights[x]=light}for(q in X.fogs){x=X.fogs[q];if(x.type==
|
||||
"linear")Q=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(Q=new THREE.FogExp2(0,x.density));E=x.color;Q.color.setRGB(E[0],E[1],E[2]);ca.fogs[q]=Q}if(ca.cameras&&X.defaults.camera)ca.currentCamera=ca.cameras[X.defaults.camera];if(ca.fogs&&X.defaults.fog)ca.scene.fog=ca.fogs[X.defaults.fog];E=X.defaults.bgcolor;ca.bgColor=new THREE.Color;ca.bgColor.setRGB(E[0],E[1],E[2]);ca.bgColorAlpha=X.defaults.bgalpha;for(j in X.geometries){q=X.geometries[j];if(q.type=="bin_mesh"||q.type=="ascii_mesh")ka+=
|
||||
1}T=ka;for(j in X.geometries){q=X.geometries[j];if(q.type=="cube"){A=new Cube(q.width,q.height,q.depth,q.segmentsWidth,q.segmentsHeight,q.segmentsDepth,null,q.flipped,q.sides);ca.geometries[j]=A}else if(q.type=="plane"){A=new Plane(q.width,q.height,q.segmentsWidth,q.segmentsHeight);ca.geometries[j]=A}else if(q.type=="sphere"){A=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);ca.geometries[j]=A}else if(q.type=="cylinder"){A=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);
|
||||
ca.geometries[j]=A}else if(q.type=="torus"){A=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);ca.geometries[j]=A}else if(q.type=="icosahedron"){A=new Icosahedron(q.subdivisions);ca.geometries[j]=A}else if(q.type=="bin_mesh")f.load({model:q.url,callback:h(j)});else q.type=="ascii_mesh"&&ea.load({model:q.url,callback:h(j)})}for(z in X.textures){j=X.textures[z];W+=j.url instanceof Array?j.url.length:1}xa=W;for(z in X.textures){j=X.textures[z];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=
|
||||
new THREE[j.mapping];if(j.url instanceof Array)q=ImageUtils.loadTextureCube(j.url,j.mapping,e);else{q=ImageUtils.loadTexture(j.url,j.mapping,e);if(THREE[j.minFilter]!=undefined)q.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)q.magFilter=THREE[j.magFilter]}ca.textures[z]=q}for(m in X.materials){z=X.materials[m];for(I in z.parameters)if(I=="envMap"||I=="map"||I=="lightMap")z.parameters[I]=ca.textures[z.parameters[I]];else if(I=="shading")z.parameters[I]=z.parameters[I]=="flat"?THREE.FlatShading:
|
||||
THREE.SmoothShading;else if(I=="blending")z.parameters[I]=THREE[z.parameters[I]]?THREE[z.parameters[I]]:THREE.NormalBlending;else I=="combine"&&(z.parameters[I]=z.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);z=new THREE[z.type](z.parameters);ca.materials[m]=z}g();c(ca)}},addMesh:function(a,c,b,d,e,g,h,k,j,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=d;c.position.y=e;c.position.z=g;c.rotation.x=h;c.rotation.y=k;c.rotation.z=j;a.addObject(c);return c},
|
||||
addPanoramaCubeWebGL:function(a,c,b){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,vertexShader:d.vertexShader,uniforms:d.uniforms});c=new THREE.Mesh(new Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);return c},addPanoramaCube:function(a,c,b){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
|
||||
d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));c=new THREE.Mesh(new Cube(c,c,c,1,1,d,!0),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var d=c/2;c=new Plane(c,c);var e=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,c,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,
|
||||
c,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,c,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,c,1,0,d,0,g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,c,1,0,-d,0,-g,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,d,e=a.children.length;
|
||||
for(d=0;d<e;d++){b=a.children[d];c(b);SceneUtils.traverseHierarchy(b,c)}}},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}},fragmentShader:"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}",
|
||||
vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
|
||||
normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
|
||||
uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragmentShader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
|
||||
@@ -325,7 +325,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
|
||||
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
|
||||
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
|
||||
fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,d,e,g=2*Math.ceil(a*3)+1;g>25&&(g=25);e=(g-1)*0.5;b=Array(g);for(c=d=0;c<g;++c){b[c]=Math.exp(-((c-e)*(c-e))/(2*a*a));d+=b[c]}for(c=0;c<g;++c)b[c]/=d;return b}};
|
||||
THREE.QuakeCamera=function(a){function c(b,d){return function(){d.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
|
||||
THREE.QuakeCamera=function(a){function c(b,d){return function(){d.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
|
||||
a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=
|
||||
this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=
|
||||
!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
|
||||
@@ -333,34 +333,34 @@ this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBack
|
||||
var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var d=this.position;b.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=d.y+100*Math.cos(this.phi);b.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},
|
||||
!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
|
||||
THREE.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};
|
||||
THREE.PathCamera=function(a){function c(m,t,x,y){var q={name:x,fps:0.6,length:y,hierarchy:[]},A,G=t.getControlPointsArray(),H=t.getLength(),E=G.length,I=0;A=E-1;t={parent:-1,keys:[]};t.keys[0]={time:0,pos:G[0],rot:[0,0,0,1],scl:[1,1,1]};t.keys[A]={time:y,pos:G[A],rot:[0,0,0,1],scl:[1,1,1]};for(A=1;A<E-1;A++){I=y*H.chunks[A]/H.total;t.keys[A]={time:I,pos:G[A]}}q.hierarchy[0]=t;THREE.AnimationHandler.add(q);return new THREE.Animation(m,x,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(m,t){var x,
|
||||
THREE.PathCamera=function(a){function c(m,t,x,y){var q={name:x,fps:0.6,length:y,hierarchy:[]},z,G=t.getControlPointsArray(),H=t.getLength(),E=G.length,I=0;z=E-1;t={parent:-1,keys:[]};t.keys[0]={time:0,pos:G[0],rot:[0,0,0,1],scl:[1,1,1]};t.keys[z]={time:y,pos:G[z],rot:[0,0,0,1],scl:[1,1,1]};for(z=1;z<E-1;z++){I=y*H.chunks[z]/H.total;t.keys[z]={time:I,pos:G[z]}}q.hierarchy[0]=t;THREE.AnimationHandler.add(q);return new THREE.Animation(m,x,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(m,t){var x,
|
||||
y,q=new THREE.Geometry;for(x=0;x<m.points.length*t;x++){y=x/(m.points.length*t);y=m.getPoint(y);q.vertices[x]=new THREE.Vertex(new THREE.Vector3(y.x,y.y,y.z))}return q}function d(m,t){var x=b(t,10),y=b(t,10),q=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(x,q);particleObj=new THREE.ParticleSystem(y,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);m.addChild(lineObj);particleObj.scale.set(1,1,1);m.addChild(particleObj);y=new Sphere(1,
|
||||
16,8);q=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<t.points.length;i++){x=new THREE.Mesh(y,q);x.position.copy(t.points[i]);x.updateMatrix();m.addChild(x)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
|
||||
16,8);q=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<t.points.length;i++){x=new THREE.Mesh(y,q);x.position.copy(t.points[i]);x.updateMatrix();m.addChild(x)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
|
||||
!0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
|
||||
if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
|
||||
this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var e=Math.PI*2,g=Math.PI/180;this.update=function(m,t,x){var y,q;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*g;this.theta=this.lon*g;y=this.phi%e;this.phi=y>=0?y:y+e;y=this.verticalAngleMap.srcRange;q=this.verticalAngleMap.dstRange;
|
||||
this.phi=(this.phi-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.horizontalAngleMap.srcRange;q=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,m,t,x)};this.onMouseMove=function(m){this.mouseX=m.clientX-this.windowHalfX;this.mouseY=m.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
|
||||
this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(j,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
|
||||
c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(m,t){return function(){t.apply(m,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
|
||||
var Cube=function(a,c,b,d,e,g,h,k,j){function m(H,E,I,z,S,Q,O,X){var f,ea,ka=d||1,W=e||1,T=S/2,xa=Q/2,ca=t.vertices.length;if(H=="x"&&E=="y"||H=="y"&&E=="x")f="z";else if(H=="x"&&E=="z"||H=="z"&&E=="x"){f="y";W=g||1}else if(H=="z"&&E=="y"||H=="y"&&E=="z"){f="x";ka=g||1}var Da=ka+1,ja=W+1;S/=ka;var oa=Q/W;for(ea=0;ea<ja;ea++)for(Q=0;Q<Da;Q++){var la=new THREE.Vector3;la[H]=(Q*S-T)*I;la[E]=(ea*oa-xa)*z;la[f]=O;t.vertices.push(new THREE.Vertex(la))}for(ea=0;ea<W;ea++)for(Q=0;Q<ka;Q++){t.faces.push(new THREE.Face4(Q+
|
||||
Da*ea+ca,Q+Da*(ea+1)+ca,Q+1+Da*(ea+1)+ca,Q+1+Da*ea+ca,null,null,X));t.faceVertexUvs[0].push([new THREE.UV(Q/ka,ea/W),new THREE.UV(Q/ka,(ea+1)/W),new THREE.UV((Q+1)/ka,(ea+1)/W),new THREE.UV((Q+1)/ka,ea/W)])}}THREE.Geometry.call(this);var t=this,x=a/2,y=c/2,q=b/2;k=k?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var A=0;A<6;A++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var G in j)this.sides[G]!=
|
||||
undefined&&(this.sides[G]=j[G]);this.sides.px&&m("z","y",1*k,-1,b,c,-x,this.materials[0]);this.sides.nx&&m("z","y",-1*k,-1,b,c,x,this.materials[1]);this.sides.py&&m("x","z",1*k,1,a,b,y,this.materials[2]);this.sides.ny&&m("x","z",1*k,-1,a,b,-y,this.materials[3]);this.sides.pz&&m("x","y",1*k,-1,a,c,q,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,a,c,-q,this.materials[5]);(function(){for(var H=[],E=[],I=0,z=t.vertices.length;I<z;I++){for(var S=t.vertices[I],Q=!1,O=0,X=H.length;O<X;O++){var f=H[O];
|
||||
if(S.position.x==f.position.x&&S.position.y==f.position.y&&S.position.z==f.position.z){E[I]=O;Q=!0;break}}if(!Q){E[I]=H.length;H.push(new THREE.Vertex(S.position.clone()))}}I=0;for(z=t.faces.length;I<z;I++){S=t.faces[I];S.a=E[S.a];S.b=E[S.b];S.c=E[S.c];S.d=E[S.d]}t.vertices=H})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
||||
var Cube=function(a,c,b,d,e,g,h,k,j){function m(H,E,I,A,S,Q,O,X){var f,ea,ka=d||1,W=e||1,T=S/2,xa=Q/2,ca=t.vertices.length;if(H=="x"&&E=="y"||H=="y"&&E=="x")f="z";else if(H=="x"&&E=="z"||H=="z"&&E=="x"){f="y";W=g||1}else if(H=="z"&&E=="y"||H=="y"&&E=="z"){f="x";ka=g||1}var Da=ka+1,ja=W+1;S/=ka;var oa=Q/W;for(ea=0;ea<ja;ea++)for(Q=0;Q<Da;Q++){var la=new THREE.Vector3;la[H]=(Q*S-T)*I;la[E]=(ea*oa-xa)*A;la[f]=O;t.vertices.push(new THREE.Vertex(la))}for(ea=0;ea<W;ea++)for(Q=0;Q<ka;Q++){t.faces.push(new THREE.Face4(Q+
|
||||
Da*ea+ca,Q+Da*(ea+1)+ca,Q+1+Da*(ea+1)+ca,Q+1+Da*ea+ca,null,null,X));t.faceVertexUvs[0].push([new THREE.UV(Q/ka,ea/W),new THREE.UV(Q/ka,(ea+1)/W),new THREE.UV((Q+1)/ka,(ea+1)/W),new THREE.UV((Q+1)/ka,ea/W)])}}THREE.Geometry.call(this);var t=this,x=a/2,y=c/2,q=b/2;k=k?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var z=0;z<6;z++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var G in j)this.sides[G]!=
|
||||
undefined&&(this.sides[G]=j[G]);this.sides.px&&m("z","y",1*k,-1,b,c,-x,this.materials[0]);this.sides.nx&&m("z","y",-1*k,-1,b,c,x,this.materials[1]);this.sides.py&&m("x","z",1*k,1,a,b,y,this.materials[2]);this.sides.ny&&m("x","z",1*k,-1,a,b,-y,this.materials[3]);this.sides.pz&&m("x","y",1*k,-1,a,c,q,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,a,c,-q,this.materials[5]);(function(){for(var H=[],E=[],I=0,A=t.vertices.length;I<A;I++){for(var S=t.vertices[I],Q=!1,O=0,X=H.length;O<X;O++){var f=H[O];
|
||||
if(S.position.x==f.position.x&&S.position.y==f.position.y&&S.position.z==f.position.z){E[I]=O;Q=!0;break}}if(!Q){E[I]=H.length;H.push(new THREE.Vertex(S.position.clone()))}}I=0;for(A=t.faces.length;I<A;I++){S=t.faces[I];S.a=E[S.a];S.b=E[S.b];S.c=E[S.c];S.d=E[S.d]}t.vertices=H})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
||||
var Cylinder=function(a,c,b,d,e,g){function h(t,x,y){k.vertices.push(new THREE.Vertex(new THREE.Vector3(t,x,y)))}THREE.Geometry.call(this);var k=this,j=Math.PI,m=d/2;for(d=0;d<a;d++)h(Math.sin(2*j*d/a)*c,Math.cos(2*j*d/a)*c,-m);for(d=0;d<a;d++)h(Math.sin(2*j*d/a)*b,Math.cos(2*j*d/a)*b,m);for(d=0;d<a;d++)k.faces.push(new THREE.Face4(d,d+a,a+(d+1)%a,(d+1)%a));if(b>0){h(0,0,-m-(g||0));for(d=a;d<a+a/2;d++)k.faces.push(new THREE.Face4(2*a,(2*d-2*a)%a,(2*d-2*a+1)%a,(2*d-2*a+2)%a))}if(c>0){h(0,0,m+(e||0));
|
||||
for(d=a+a/2;d<2*a;d++)k.faces.push(new THREE.Face4(2*a+1,(2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
||||
var Icosahedron=function(a){function c(x,y,q){var A=Math.sqrt(x*x+y*y+q*q);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(x/A,y/A,q/A)))-1}function b(x,y,q,A){A.faces.push(new THREE.Face3(x,y,q))}function d(x,y){var q=e.vertices[x].position,A=e.vertices[y].position;return c((q.x+A.x)/2,(q.y+A.y)/2,(q.z+A.z)/2)}var e=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
|
||||
var Icosahedron=function(a){function c(x,y,q){var z=Math.sqrt(x*x+y*y+q*q);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(x/z,y/z,q/z)))-1}function b(x,y,q,z){z.faces.push(new THREE.Face3(x,y,q))}function d(x,y){var q=e.vertices[x].position,z=e.vertices[y].position;return c((q.x+z.x)/2,(q.y+z.y)/2,(q.z+z.z)/2)}var e=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
|
||||
1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=d(g.faces[k].a,g.faces[k].b),m=d(g.faces[k].b,g.faces[k].c),t=d(g.faces[k].c,g.faces[k].a);b(g.faces[k].a,j,t,h);b(g.faces[k].b,m,j,h);b(g.faces[k].c,
|
||||
t,m,h);b(j,m,t,h)}g.faces=h.faces}e.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
|
||||
function Lathe(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;for(var d=[],e=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));d[k]=a[k].clone();e[k]=this.vertices.length-1}for(var j=(new THREE.Matrix4).setRotationZ(c),m=0;m<=this.angle+0.0010;m+=c){for(k=0;k<d.length;k++)if(m<this.angle){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;m==0&&(h=e);for(k=
|
||||
function Lathe(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;for(var d=[],e=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));d[k]=a[k].clone();e[k]=this.vertices.length-1}for(var j=(new THREE.Matrix4).setRotationZ(c),m=0;m<=this.angle+0.001;m+=c){for(k=0;k<d.length;k++)if(m<this.angle){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;m==0&&(h=e);for(k=
|
||||
0;k<e.length-1;k++){this.faces.push(new THREE.Face4(g[k],g[k+1],e[k+1],e[k]));this.faceVertexUvs[0].push([new THREE.UV(m/b,k/a.length),new THREE.UV(m/b,(k+1)/a.length),new THREE.UV((m-c)/b,(k+1)/a.length),new THREE.UV((m-c)/b,k/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
|
||||
var Plane=function(a,c,b,d){THREE.Geometry.call(this);var e,g=a/2,h=c/2;b=b||1;d=d||1;var k=b+1,j=d+1;a/=b;var m=c/d;for(e=0;e<j;e++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-g,-(e*m-h),0)));for(e=0;e<d;e++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+k*e,c+k*(e+1),c+1+k*(e+1),c+1+k*e));this.faceVertexUvs[0].push([new THREE.UV(c/b,e/d),new THREE.UV(c/b,(e+1)/d),new THREE.UV((c+1)/b,(e+1)/d),new THREE.UV((c+1)/b,e/d)])}this.computeCentroids();this.computeFaceNormals()};
|
||||
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
||||
var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){d=b/h;var k=a*Math.cos(d*e),j=a*Math.sin(d*e),m=[],t=0;for(d=0;d<g;d++){var x=2*d/g,y=j*Math.sin(x*e);x=j*Math.cos(x*e);(b==0||b==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);m.push(t)}c.push(m)}var q,A,G;e=c.length;for(b=0;b<e;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){m=d==g-1;h=c[b][m?0:d+1];k=c[b][m?g-1:d];j=c[b-1][m?g-1:d];m=c[b-1][m?
|
||||
0:d+1];y=b/(e-1);q=(b-1)/(e-1);A=(d+1)/g;x=d/g;t=new THREE.UV(1-A,y);y=new THREE.UV(1-x,y);x=new THREE.UV(1-x,q);var H=new THREE.UV(1-A,q);if(b<c.length-1){q=this.vertices[h].position.clone();A=this.vertices[k].position.clone();G=this.vertices[j].position.clone();q.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,y,x])}if(b>1){q=this.vertices[h].position.clone();
|
||||
A=this.vertices[j].position.clone();G=this.vertices[m].position.clone();q.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){d=b/h;var k=a*Math.cos(d*e),j=a*Math.sin(d*e),m=[],t=0;for(d=0;d<g;d++){var x=2*d/g,y=j*Math.sin(x*e);x=j*Math.cos(x*e);(b==0||b==h)&&d>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);m.push(t)}c.push(m)}var q,z,G;e=c.length;for(b=0;b<e;b++){g=c[b].length;if(b>0)for(d=0;d<g;d++){m=d==g-1;h=c[b][m?0:d+1];k=c[b][m?g-1:d];j=c[b-1][m?g-1:d];m=c[b-1][m?
|
||||
0:d+1];y=b/(e-1);q=(b-1)/(e-1);z=(d+1)/g;x=d/g;t=new THREE.UV(1-z,y);y=new THREE.UV(1-x,y);x=new THREE.UV(1-x,q);var H=new THREE.UV(1-z,q);if(b<c.length-1){q=this.vertices[h].position.clone();z=this.vertices[k].position.clone();G=this.vertices[j].position.clone();q.normalize();z.normalize();G.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,y,x])}if(b>1){q=this.vertices[h].position.clone();
|
||||
z=this.vertices[j].position.clone();G=this.vertices[m].position.clone();q.normalize();z.normalize();G.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([t,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
|
||||
1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
|
||||
var TorusKnot=function(a,c,b,d,e,g,h){function k(x,y,q,A,G,H){y=q/A*x;q=Math.cos(y);return new THREE.Vector3(G*(2+q)*0.5*Math.cos(x),G*(2+q)*Math.sin(x)*0.5,H*G*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var j=
|
||||
var TorusKnot=function(a,c,b,d,e,g,h){function k(x,y,q,z,G,H){y=q/z*x;q=Math.cos(y);return new THREE.Vector3(G*(2+q)*0.5*Math.cos(x),G*(2+q)*Math.sin(x)*0.5,H*G*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var j=
|
||||
a/this.segmentsR*2*this.p*Math.PI;h=c/this.segmentsT*2*Math.PI;e=k(j,h,this.q,this.p,this.radius,this.heightScale);j=k(j+0.01,h,this.q,this.p,this.radius,this.heightScale);b.x=j.x-e.x;b.y=j.y-e.y;b.z=j.z-e.z;d.x=j.x+e.x;d.y=j.y+e.y;d.z=j.z+e.z;g.cross(b,d);d.cross(g,b);g.normalize();d.normalize();j=this.tube*Math.cos(h);h=this.tube*Math.sin(h);e.x+=j*d.x+h*g.x;e.y+=j*d.y+h*g.y;e.z+=j*d.z+h*g.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=
|
||||
0;c<this.segmentsT;++c){g=(a+1)%this.segmentsR;h=(c+1)%this.segmentsT;e=this.grid[a][c];b=this.grid[g][c];d=this.grid[a][h];g=this.grid[g][h];h=new THREE.UV(a/this.segmentsR,c/this.segmentsT);j=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var m=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT),t=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face3(e,b,d));this.faceVertexUvs[0].push([h,j,m]);this.faces.push(new THREE.Face3(g,d,b));this.faceVertexUvs[0].push([t,
|
||||
m,j])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null};
|
||||
@@ -370,38 +370,38 @@ k.image.width=t;k.image.height=x;k.image.getContext("2d").drawImage(this,0,0,t,x
|
||||
(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&c){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);g.lightMap.sourceFile=a.mapLightmap;d(g.lightMap,c+"/"+a.mapLightmap)}return new THREE[e](g)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
|
||||
THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
|
||||
THREE.JSONLoader.prototype={load:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(e){THREE.JSONLoader.prototype.createModel(e.data,b,d)};c.postMessage(a)},createModel:function(a,c,b){var d=function(e){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,e);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");
|
||||
else{var h,k,j,m,t,x,y,q,A,G,H=a.faces;q=a.vertices;var E=a.normals,I=a.colors,z=0;for(h=0;h<a.uvs.length;h++)a.uvs[h].length&&z++;for(h=0;h<z;h++){g.faceUvs[h]=[];g.faceVertexUvs[h]=[]}j=0;for(m=q.length;j<m;){A=new THREE.Vertex;A.position.x=q[j++];A.position.y=q[j++];A.position.z=q[j++];g.vertices.push(A)}j=0;for(m=H.length;j<m;){t=H[j++];x=t&1;h=t&2;y=t&4;k=t&8;q=t&16;A=t&32;G=t&64;t&=128;if(x){x=new THREE.Face4;x.a=H[j++];x.b=H[j++];x.c=H[j++];x.d=H[j++];nVertices=4}else{x=new THREE.Face3;x.a=
|
||||
H[j++];x.b=H[j++];x.c=H[j++];nVertices=3}if(h){materialIndex=H[j++];x.materials=g.materials[materialIndex]}if(y)for(h=0;h<z;h++){uvLayer=a.uvs[h];uvIndex=H[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];g.faceUvs[h].push(new THREE.UV(u,v))}if(k)for(h=0;h<z;h++){uvLayer=a.uvs[h];uvs=[];for(k=0;k<nVertices;k++){uvIndex=H[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];uvs[k]=new THREE.UV(u,v)}k=g.faces.length;g.faceVertexUvs[h][k]=uvs}if(q){normalIndex=H[j++]*3;normal=new THREE.Vector3;normal.x=
|
||||
E[normalIndex++];normal.y=E[normalIndex++];normal.z=E[normalIndex];x.normal=normal}if(A)for(h=0;h<nVertices;h++){normalIndex=H[j++]*3;normal=new THREE.Vector3;normal.x=E[normalIndex++];normal.y=E[normalIndex++];normal.z=E[normalIndex];x.vertexNormals.push(normal)}if(G){color=new THREE.Color(H[j++]);x.color=color}if(t)for(h=0;h<nVertices;h++){colorIndex=H[j++];color=new THREE.Color(I[colorIndex]);x.vertexColors.push(color)}g.faces.push(x)}}})();(function(){var h,k,j,m;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<
|
||||
else{var h,k,j,m,t,x,y,q,z,G,H=a.faces;q=a.vertices;var E=a.normals,I=a.colors,A=0;for(h=0;h<a.uvs.length;h++)a.uvs[h].length&&A++;for(h=0;h<A;h++){g.faceUvs[h]=[];g.faceVertexUvs[h]=[]}j=0;for(m=q.length;j<m;){z=new THREE.Vertex;z.position.x=q[j++];z.position.y=q[j++];z.position.z=q[j++];g.vertices.push(z)}j=0;for(m=H.length;j<m;){t=H[j++];x=t&1;h=t&2;y=t&4;k=t&8;q=t&16;z=t&32;G=t&64;t&=128;if(x){x=new THREE.Face4;x.a=H[j++];x.b=H[j++];x.c=H[j++];x.d=H[j++];nVertices=4}else{x=new THREE.Face3;x.a=
|
||||
H[j++];x.b=H[j++];x.c=H[j++];nVertices=3}if(h){materialIndex=H[j++];x.materials=g.materials[materialIndex]}if(y)for(h=0;h<A;h++){uvLayer=a.uvs[h];uvIndex=H[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];g.faceUvs[h].push(new THREE.UV(u,v))}if(k)for(h=0;h<A;h++){uvLayer=a.uvs[h];uvs=[];for(k=0;k<nVertices;k++){uvIndex=H[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];uvs[k]=new THREE.UV(u,v)}k=g.faces.length;g.faceVertexUvs[h][k]=uvs}if(q){normalIndex=H[j++]*3;normal=new THREE.Vector3;normal.x=
|
||||
E[normalIndex++];normal.y=E[normalIndex++];normal.z=E[normalIndex];x.normal=normal}if(z)for(h=0;h<nVertices;h++){normalIndex=H[j++]*3;normal=new THREE.Vector3;normal.x=E[normalIndex++];normal.y=E[normalIndex++];normal.z=E[normalIndex];x.vertexNormals.push(normal)}if(G){color=new THREE.Color(H[j++]);x.color=color}if(t)for(h=0;h<nVertices;h++){colorIndex=H[j++];color=new THREE.Color(I[colorIndex]);x.vertexColors.push(color)}g.faces.push(x)}}})();(function(){var h,k,j,m;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<
|
||||
k;h+=2){j=a.skinWeights[h];m=a.skinWeights[h+1];g.skinWeights.push(new THREE.Vector4(j,m,0,0))}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=2){j=a.skinIndices[h];m=a.skinIndices[h+1];g.skinIndices.push(new THREE.Vector4(j,m,0,0))}}g.bones=a.bones;g.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var h,k,j,m;h=0;for(k=a.morphTargets.length;h<k;h++){g.morphTargets[h]={};g.morphTargets[h].name=a.morphTargets[h].name;g.morphTargets[h].vertices=[];dstVertices=g.morphTargets[h].vertices;
|
||||
srcVertices=a.morphTargets[h].vertices;j=0;for(m=srcVertices.length;j<m;j+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[j],srcVertices[j+1],srcVertices[j+2])))}}})();this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;c(new d(b))}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;
|
||||
THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
|
||||
THREE.BinaryLoader.prototype={load:function(a){var c=a.model,b=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c),e=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.BinaryLoader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,b,e,d,g)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};
|
||||
c.postMessage(a)},loadAjaxBuffers:function(a,c,b,d,e,g){var h=new XMLHttpRequest,k=d+"/"+a,j=0;h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,b,e,c):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(g){j==0&&(j=h.getResponseHeader("Content-Length"));g({total:j,loaded:h.responseText.length})}}else h.readyState==2&&(j=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
|
||||
h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(a,c,b,d){var e=function(g){function h(p,o){var w=t(p,o),D=t(p,o+1),B=t(p,o+2),F=t(p,o+3),Z=(F<<1&255|B>>7)-127;w|=(B&127)<<16|D<<8;if(w==0&&Z==-127)return 0;return(1-2*(F>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,Z)}function k(p,o){var w=t(p,o),D=t(p,o+1),B=t(p,o+2);return(t(p,o+3)<<24)+(B<<16)+(D<<8)+w}function j(p,o){var w=t(p,o);return(t(p,o+1)<<8)+w}function m(p,o){var w=t(p,o);return w>127?w-256:w}function t(p,
|
||||
o){return p.charCodeAt(o)&255}function x(p){var o,w,D;o=k(a,p);w=k(a,p+O);D=k(a,p+X);p=j(a,p+f);THREE.BinaryLoader.prototype.f3(E,o,w,D,p)}function y(p){var o,w,D,B,F,Z;o=k(a,p);w=k(a,p+O);D=k(a,p+X);B=j(a,p+f);F=k(a,p+ea);Z=k(a,p+ka);p=k(a,p+W);THREE.BinaryLoader.prototype.f3n(E,S,o,w,D,B,F,Z,p)}function q(p){var o,w,D,B;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca);p=j(a,p+Da);THREE.BinaryLoader.prototype.f4(E,o,w,D,B,p)}function A(p){var o,w,D,B,F,Z,N,K;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca);
|
||||
F=j(a,p+Da);Z=k(a,p+ja);N=k(a,p+oa);K=k(a,p+la);p=k(a,p+aa);THREE.BinaryLoader.prototype.f4n(E,S,o,w,D,B,F,Z,N,K,p)}function G(p){var o,w;o=k(a,p);w=k(a,p+P);p=k(a,p+M);THREE.BinaryLoader.prototype.uv3(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[p*2],Q[p*2+1])}function H(p){var o,w,D;o=k(a,p);w=k(a,p+da);D=k(a,p+sa);p=k(a,p+ia);THREE.BinaryLoader.prototype.uv4(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[D*2],Q[D*2+1],Q[p*2],Q[p*2+1])}var E=this,I=0,z,S=[],Q=[],O,X,f,ea,ka,W,T,xa,
|
||||
ca,Da,ja,oa,la,aa,P,M,da,sa,ia,ta,ya,La,ab,n,C;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,d,g);z={signature:a.substr(I,8),header_bytes:t(a,I+8),vertex_coordinate_bytes:t(a,I+9),normal_coordinate_bytes:t(a,I+10),uv_coordinate_bytes:t(a,I+11),vertex_index_bytes:t(a,I+12),normal_index_bytes:t(a,I+13),uv_index_bytes:t(a,I+14),material_index_bytes:t(a,I+15),nvertices:k(a,I+16),nnormals:k(a,I+16+4),nuvs:k(a,I+16+8),ntri_flat:k(a,I+16+12),ntri_smooth:k(a,I+16+16),ntri_flat_uv:k(a,
|
||||
I+16+20),ntri_smooth_uv:k(a,I+16+24),nquad_flat:k(a,I+16+28),nquad_smooth:k(a,I+16+32),nquad_flat_uv:k(a,I+16+36),nquad_smooth_uv:k(a,I+16+40)};I+=z.header_bytes;O=z.vertex_index_bytes;X=z.vertex_index_bytes*2;f=z.vertex_index_bytes*3;ea=z.vertex_index_bytes*3+z.material_index_bytes;ka=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes;W=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*2;T=z.vertex_index_bytes;xa=z.vertex_index_bytes*2;ca=z.vertex_index_bytes*3;Da=
|
||||
z.vertex_index_bytes*4;ja=z.vertex_index_bytes*4+z.material_index_bytes;oa=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes;la=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*2;aa=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*3;P=z.uv_index_bytes;M=z.uv_index_bytes*2;da=z.uv_index_bytes;sa=z.uv_index_bytes*2;ia=z.uv_index_bytes*3;g=z.vertex_index_bytes*3+z.material_index_bytes;C=z.vertex_index_bytes*4+z.material_index_bytes;ta=z.ntri_flat*
|
||||
g;ya=z.ntri_smooth*(g+z.normal_index_bytes*3);La=z.ntri_flat_uv*(g+z.uv_index_bytes*3);ab=z.ntri_smooth_uv*(g+z.normal_index_bytes*3+z.uv_index_bytes*3);n=z.nquad_flat*C;g=z.nquad_smooth*(C+z.normal_index_bytes*4);C=z.nquad_flat_uv*(C+z.uv_index_bytes*4);I+=function(p){for(var o,w,D,B=z.vertex_coordinate_bytes*3,F=p+z.nvertices*B;p<F;p+=B){o=h(a,p);w=h(a,p+z.vertex_coordinate_bytes);D=h(a,p+z.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(E,o,w,D)}return z.nvertices*B}(I);I+=function(p){for(var o,
|
||||
w,D,B=z.normal_coordinate_bytes*3,F=p+z.nnormals*B;p<F;p+=B){o=m(a,p);w=m(a,p+z.normal_coordinate_bytes);D=m(a,p+z.normal_coordinate_bytes*2);S.push(o/127,w/127,D/127)}return z.nnormals*B}(I);I+=function(p){for(var o,w,D=z.uv_coordinate_bytes*2,B=p+z.nuvs*D;p<B;p+=D){o=h(a,p);w=h(a,p+z.uv_coordinate_bytes);Q.push(o,w)}return z.nuvs*D}(I);ta=I+ta;ya=ta+ya;La=ya+La;ab=La+ab;n=ab+n;g=n+g;C=g+C;(function(p){var o,w=z.vertex_index_bytes*3+z.material_index_bytes,D=w+z.uv_index_bytes*3,B=p+z.ntri_flat_uv*
|
||||
D;for(o=p;o<B;o+=D){x(o);G(o+w)}return B-p})(ya);(function(p){var o,w=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*3,D=w+z.uv_index_bytes*3,B=p+z.ntri_smooth_uv*D;for(o=p;o<B;o+=D){y(o);G(o+w)}return B-p})(La);(function(p){var o,w=z.vertex_index_bytes*4+z.material_index_bytes,D=w+z.uv_index_bytes*4,B=p+z.nquad_flat_uv*D;for(o=p;o<B;o+=D){q(o);H(o+w)}return B-p})(g);(function(p){var o,w=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*4,D=w+z.uv_index_bytes*
|
||||
4,B=p+z.nquad_smooth_uv*D;for(o=p;o<B;o+=D){A(o);H(o+w)}return B-p})(C);(function(p){var o,w=z.vertex_index_bytes*3+z.material_index_bytes,D=p+z.ntri_flat*w;for(o=p;o<D;o+=w)x(o);return D-p})(I);(function(p){var o,w=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*3,D=p+z.ntri_smooth*w;for(o=p;o<D;o+=w)y(o);return D-p})(ta);(function(p){var o,w=z.vertex_index_bytes*4+z.material_index_bytes,D=p+z.nquad_flat*w;for(o=p;o<D;o+=w)q(o);return D-p})(ab);(function(p){var o,w=z.vertex_index_bytes*
|
||||
4+z.material_index_bytes+z.normal_index_bytes*4,D=p+z.nquad_smooth*w;for(o=p;o<D;o+=w)A(o);return D-p})(n);this.computeCentroids();this.computeFaceNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(b))},v:function(a,c,b,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,b,d)))},f3:function(a,c,b,d,e){a.faces.push(new THREE.Face3(c,b,d,null,null,a.materials[e]))},f4:function(a,c,b,d,e,g){a.faces.push(new THREE.Face4(c,b,d,e,null,null,a.materials[g]))},f3n:function(a,c,
|
||||
b,d,e,g,h,k,j){g=a.materials[g];var m=c[k*3],t=c[k*3+1];k=c[k*3+2];var x=c[j*3],y=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(b,d,e,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,t,k),new THREE.Vector3(x,y,j)],null,g))},f4n:function(a,c,b,d,e,g,h,k,j,m,t){h=a.materials[h];var x=c[j*3],y=c[j*3+1];j=c[j*3+2];var q=c[m*3],A=c[m*3+1];m=c[m*3+2];var G=c[t*3],H=c[t*3+1];t=c[t*3+2];a.faces.push(new THREE.Face4(b,d,e,g,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(x,
|
||||
y,j),new THREE.Vector3(q,A,m),new THREE.Vector3(G,H,t)],null,h))},uv3:function(a,c,b,d,e,g,h){var k=[];k.push(new THREE.UV(c,b));k.push(new THREE.UV(d,e));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,c,b,d,e,g,h,k,j){var m=[];m.push(new THREE.UV(c,b));m.push(new THREE.UV(d,e));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
|
||||
o){return p.charCodeAt(o)&255}function x(p){var o,w,D;o=k(a,p);w=k(a,p+O);D=k(a,p+X);p=j(a,p+f);THREE.BinaryLoader.prototype.f3(E,o,w,D,p)}function y(p){var o,w,D,B,F,Z;o=k(a,p);w=k(a,p+O);D=k(a,p+X);B=j(a,p+f);F=k(a,p+ea);Z=k(a,p+ka);p=k(a,p+W);THREE.BinaryLoader.prototype.f3n(E,S,o,w,D,B,F,Z,p)}function q(p){var o,w,D,B;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca);p=j(a,p+Da);THREE.BinaryLoader.prototype.f4(E,o,w,D,B,p)}function z(p){var o,w,D,B,F,Z,N,K;o=k(a,p);w=k(a,p+T);D=k(a,p+xa);B=k(a,p+ca);
|
||||
F=j(a,p+Da);Z=k(a,p+ja);N=k(a,p+oa);K=k(a,p+la);p=k(a,p+aa);THREE.BinaryLoader.prototype.f4n(E,S,o,w,D,B,F,Z,N,K,p)}function G(p){var o,w;o=k(a,p);w=k(a,p+P);p=k(a,p+M);THREE.BinaryLoader.prototype.uv3(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[p*2],Q[p*2+1])}function H(p){var o,w,D;o=k(a,p);w=k(a,p+da);D=k(a,p+sa);p=k(a,p+ia);THREE.BinaryLoader.prototype.uv4(E.faceVertexUvs[0],Q[o*2],Q[o*2+1],Q[w*2],Q[w*2+1],Q[D*2],Q[D*2+1],Q[p*2],Q[p*2+1])}var E=this,I=0,A,S=[],Q=[],O,X,f,ea,ka,W,T,xa,
|
||||
ca,Da,ja,oa,la,aa,P,M,da,sa,ia,ta,ya,La,ab,n,C;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,d,g);A={signature:a.substr(I,8),header_bytes:t(a,I+8),vertex_coordinate_bytes:t(a,I+9),normal_coordinate_bytes:t(a,I+10),uv_coordinate_bytes:t(a,I+11),vertex_index_bytes:t(a,I+12),normal_index_bytes:t(a,I+13),uv_index_bytes:t(a,I+14),material_index_bytes:t(a,I+15),nvertices:k(a,I+16),nnormals:k(a,I+16+4),nuvs:k(a,I+16+8),ntri_flat:k(a,I+16+12),ntri_smooth:k(a,I+16+16),ntri_flat_uv:k(a,
|
||||
I+16+20),ntri_smooth_uv:k(a,I+16+24),nquad_flat:k(a,I+16+28),nquad_smooth:k(a,I+16+32),nquad_flat_uv:k(a,I+16+36),nquad_smooth_uv:k(a,I+16+40)};I+=A.header_bytes;O=A.vertex_index_bytes;X=A.vertex_index_bytes*2;f=A.vertex_index_bytes*3;ea=A.vertex_index_bytes*3+A.material_index_bytes;ka=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;W=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;T=A.vertex_index_bytes;xa=A.vertex_index_bytes*2;ca=A.vertex_index_bytes*3;Da=
|
||||
A.vertex_index_bytes*4;ja=A.vertex_index_bytes*4+A.material_index_bytes;oa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;la=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;aa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;P=A.uv_index_bytes;M=A.uv_index_bytes*2;da=A.uv_index_bytes;sa=A.uv_index_bytes*2;ia=A.uv_index_bytes*3;g=A.vertex_index_bytes*3+A.material_index_bytes;C=A.vertex_index_bytes*4+A.material_index_bytes;ta=A.ntri_flat*
|
||||
g;ya=A.ntri_smooth*(g+A.normal_index_bytes*3);La=A.ntri_flat_uv*(g+A.uv_index_bytes*3);ab=A.ntri_smooth_uv*(g+A.normal_index_bytes*3+A.uv_index_bytes*3);n=A.nquad_flat*C;g=A.nquad_smooth*(C+A.normal_index_bytes*4);C=A.nquad_flat_uv*(C+A.uv_index_bytes*4);I+=function(p){for(var o,w,D,B=A.vertex_coordinate_bytes*3,F=p+A.nvertices*B;p<F;p+=B){o=h(a,p);w=h(a,p+A.vertex_coordinate_bytes);D=h(a,p+A.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(E,o,w,D)}return A.nvertices*B}(I);I+=function(p){for(var o,
|
||||
w,D,B=A.normal_coordinate_bytes*3,F=p+A.nnormals*B;p<F;p+=B){o=m(a,p);w=m(a,p+A.normal_coordinate_bytes);D=m(a,p+A.normal_coordinate_bytes*2);S.push(o/127,w/127,D/127)}return A.nnormals*B}(I);I+=function(p){for(var o,w,D=A.uv_coordinate_bytes*2,B=p+A.nuvs*D;p<B;p+=D){o=h(a,p);w=h(a,p+A.uv_coordinate_bytes);Q.push(o,w)}return A.nuvs*D}(I);ta=I+ta;ya=ta+ya;La=ya+La;ab=La+ab;n=ab+n;g=n+g;C=g+C;(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes,D=w+A.uv_index_bytes*3,B=p+A.ntri_flat_uv*
|
||||
D;for(o=p;o<B;o+=D){x(o);G(o+w)}return B-p})(ya);(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,D=w+A.uv_index_bytes*3,B=p+A.ntri_smooth_uv*D;for(o=p;o<B;o+=D){y(o);G(o+w)}return B-p})(La);(function(p){var o,w=A.vertex_index_bytes*4+A.material_index_bytes,D=w+A.uv_index_bytes*4,B=p+A.nquad_flat_uv*D;for(o=p;o<B;o+=D){q(o);H(o+w)}return B-p})(g);(function(p){var o,w=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*4,D=w+A.uv_index_bytes*
|
||||
4,B=p+A.nquad_smooth_uv*D;for(o=p;o<B;o+=D){z(o);H(o+w)}return B-p})(C);(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes,D=p+A.ntri_flat*w;for(o=p;o<D;o+=w)x(o);return D-p})(I);(function(p){var o,w=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,D=p+A.ntri_smooth*w;for(o=p;o<D;o+=w)y(o);return D-p})(ta);(function(p){var o,w=A.vertex_index_bytes*4+A.material_index_bytes,D=p+A.nquad_flat*w;for(o=p;o<D;o+=w)q(o);return D-p})(ab);(function(p){var o,w=A.vertex_index_bytes*
|
||||
4+A.material_index_bytes+A.normal_index_bytes*4,D=p+A.nquad_smooth*w;for(o=p;o<D;o+=w)z(o);return D-p})(n);this.computeCentroids();this.computeFaceNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(b))},v:function(a,c,b,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,b,d)))},f3:function(a,c,b,d,e){a.faces.push(new THREE.Face3(c,b,d,null,null,a.materials[e]))},f4:function(a,c,b,d,e,g){a.faces.push(new THREE.Face4(c,b,d,e,null,null,a.materials[g]))},f3n:function(a,c,
|
||||
b,d,e,g,h,k,j){g=a.materials[g];var m=c[k*3],t=c[k*3+1];k=c[k*3+2];var x=c[j*3],y=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(b,d,e,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,t,k),new THREE.Vector3(x,y,j)],null,g))},f4n:function(a,c,b,d,e,g,h,k,j,m,t){h=a.materials[h];var x=c[j*3],y=c[j*3+1];j=c[j*3+2];var q=c[m*3],z=c[m*3+1];m=c[m*3+2];var G=c[t*3],H=c[t*3+1];t=c[t*3+2];a.faces.push(new THREE.Face4(b,d,e,g,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(x,
|
||||
y,j),new THREE.Vector3(q,z,m),new THREE.Vector3(G,H,t)],null,h))},uv3:function(a,c,b,d,e,g,h){var k=[];k.push(new THREE.UV(c,b));k.push(new THREE.UV(d,e));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,c,b,d,e,g,h,k,j){var m=[];m.push(new THREE.UV(c,b));m.push(new THREE.UV(d,e));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
|
||||
THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
|
||||
0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,d,e){return b+(d-b)*e};this.VIntX=function(b,d,e,g,h,k,j,m,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=j;d[g+2]=m;e[g]=this.lerp(t[b],t[b+3],h);e[g+1]=this.lerp(t[b+1],t[b+4],h);e[g+2]=this.lerp(t[b+2],t[b+5],h)};this.VIntY=function(b,d,e,g,h,k,j,m,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=k;d[g+1]=j+h*this.delta;d[g+
|
||||
2]=m;d=b+this.yd*3;e[g]=this.lerp(t[b],t[d],h);e[g+1]=this.lerp(t[b+1],t[d+1],h);e[g+2]=this.lerp(t[b+2],t[d+2],h)};this.VIntZ=function(b,d,e,g,h,k,j,m,t,x){h=(h-t)/(x-t);t=this.normal_cache;d[g]=k;d[g+1]=j;d[g+2]=m+h*this.delta;d=b+this.zd*3;e[g]=this.lerp(t[b],t[d],h);e[g+1]=this.lerp(t[b+1],t[d+1],h);e[g+2]=this.lerp(t[b+2],t[d+2],h)};this.compNorm=function(b){var d=b*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[b-1]-this.field[b+1];this.normal_cache[d+1]=this.field[b-this.yd]-
|
||||
this.field[b+this.yd];this.normal_cache[d+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,d,e,g,h,k){var j=g+1,m=g+this.yd,t=g+this.zd,x=j+this.yd,y=j+this.zd,q=g+this.yd+this.zd,A=j+this.yd+this.zd,G=0,H=this.field[g],E=this.field[j],I=this.field[m],z=this.field[x],S=this.field[t],Q=this.field[y],O=this.field[q],X=this.field[A];H<h&&(G|=1);E<h&&(G|=2);I<h&&(G|=8);z<h&&(G|=4);S<h&&(G|=16);Q<h&&(G|=32);O<h&&(G|=128);X<h&&(G|=64);var f=THREE.edgeTable[G];if(f==0)return 0;
|
||||
var ea=this.delta,ka=b+ea,W=d+ea;ea=e+ea;if(f&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,b,d,e,H,E)}if(f&2){this.compNorm(j);this.compNorm(x);this.VIntY(j*3,this.vlist,this.nlist,3,h,ka,d,e,E,z)}if(f&4){this.compNorm(m);this.compNorm(x);this.VIntX(m*3,this.vlist,this.nlist,6,h,b,W,e,I,z)}if(f&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,b,d,e,H,I)}if(f&16){this.compNorm(t);this.compNorm(y);this.VIntX(t*3,this.vlist,this.nlist,12,
|
||||
h,b,d,ea,S,Q)}if(f&32){this.compNorm(y);this.compNorm(A);this.VIntY(y*3,this.vlist,this.nlist,15,h,ka,d,ea,Q,X)}if(f&64){this.compNorm(q);this.compNorm(A);this.VIntX(q*3,this.vlist,this.nlist,18,h,b,W,ea,O,X)}if(f&128){this.compNorm(t);this.compNorm(q);this.VIntY(t*3,this.vlist,this.nlist,21,h,b,d,ea,S,O)}if(f&256){this.compNorm(g);this.compNorm(t);this.VIntZ(g*3,this.vlist,this.nlist,24,h,b,d,e,H,S)}if(f&512){this.compNorm(j);this.compNorm(y);this.VIntZ(j*3,this.vlist,this.nlist,27,h,ka,d,e,E,Q)}if(f&
|
||||
1024){this.compNorm(x);this.compNorm(A);this.VIntZ(x*3,this.vlist,this.nlist,30,h,ka,W,e,z,X)}if(f&2048){this.compNorm(m);this.compNorm(q);this.VIntZ(m*3,this.vlist,this.nlist,33,h,b,W,e,I,O)}G<<=4;for(h=g=0;THREE.triTable[G+h]!=-1;){b=G+h;d=b+1;e=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[d],3*THREE.triTable[e],k);h+=3;g++}return g};this.posnormtriv=function(b,d,e,g,h,k){var j=this.count*3;this.positionArray[j]=b[e];this.positionArray[j+1]=b[e+1];this.positionArray[j+
|
||||
this.field[b+this.yd];this.normal_cache[d+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,d,e,g,h,k){var j=g+1,m=g+this.yd,t=g+this.zd,x=j+this.yd,y=j+this.zd,q=g+this.yd+this.zd,z=j+this.yd+this.zd,G=0,H=this.field[g],E=this.field[j],I=this.field[m],A=this.field[x],S=this.field[t],Q=this.field[y],O=this.field[q],X=this.field[z];H<h&&(G|=1);E<h&&(G|=2);I<h&&(G|=8);A<h&&(G|=4);S<h&&(G|=16);Q<h&&(G|=32);O<h&&(G|=128);X<h&&(G|=64);var f=THREE.edgeTable[G];if(f==0)return 0;
|
||||
var ea=this.delta,ka=b+ea,W=d+ea;ea=e+ea;if(f&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,b,d,e,H,E)}if(f&2){this.compNorm(j);this.compNorm(x);this.VIntY(j*3,this.vlist,this.nlist,3,h,ka,d,e,E,A)}if(f&4){this.compNorm(m);this.compNorm(x);this.VIntX(m*3,this.vlist,this.nlist,6,h,b,W,e,I,A)}if(f&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,b,d,e,H,I)}if(f&16){this.compNorm(t);this.compNorm(y);this.VIntX(t*3,this.vlist,this.nlist,12,
|
||||
h,b,d,ea,S,Q)}if(f&32){this.compNorm(y);this.compNorm(z);this.VIntY(y*3,this.vlist,this.nlist,15,h,ka,d,ea,Q,X)}if(f&64){this.compNorm(q);this.compNorm(z);this.VIntX(q*3,this.vlist,this.nlist,18,h,b,W,ea,O,X)}if(f&128){this.compNorm(t);this.compNorm(q);this.VIntY(t*3,this.vlist,this.nlist,21,h,b,d,ea,S,O)}if(f&256){this.compNorm(g);this.compNorm(t);this.VIntZ(g*3,this.vlist,this.nlist,24,h,b,d,e,H,S)}if(f&512){this.compNorm(j);this.compNorm(y);this.VIntZ(j*3,this.vlist,this.nlist,27,h,ka,d,e,E,Q)}if(f&
|
||||
1024){this.compNorm(x);this.compNorm(z);this.VIntZ(x*3,this.vlist,this.nlist,30,h,ka,W,e,A,X)}if(f&2048){this.compNorm(m);this.compNorm(q);this.VIntZ(m*3,this.vlist,this.nlist,33,h,b,W,e,I,O)}G<<=4;for(h=g=0;THREE.triTable[G+h]!=-1;){b=G+h;d=b+1;e=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[d],3*THREE.triTable[e],k);h+=3;g++}return g};this.posnormtriv=function(b,d,e,g,h,k){var j=this.count*3;this.positionArray[j]=b[e];this.positionArray[j+1]=b[e+1];this.positionArray[j+
|
||||
2]=b[e+2];this.positionArray[j+3]=b[g];this.positionArray[j+4]=b[g+1];this.positionArray[j+5]=b[g+2];this.positionArray[j+6]=b[h];this.positionArray[j+7]=b[h+1];this.positionArray[j+8]=b[h+2];this.normalArray[j]=d[e];this.normalArray[j+1]=d[e+1];this.normalArray[j+2]=d[e+2];this.normalArray[j+3]=d[g];this.normalArray[j+4]=d[g+1];this.normalArray[j+5]=d[g+2];this.normalArray[j+6]=d[h];this.normalArray[j+7]=d[h+1];this.normalArray[j+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=
|
||||
this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;b(this)}};this.addBall=function(b,d,e,g,h){var k=this.size*Math.sqrt(g/h),j=e*this.size,m=d*this.size,t=b*this.size,x=Math.floor(j-k);x<1&&(x=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var y=Math.floor(m-k);y<1&&(y=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var q=Math.floor(t-
|
||||
k);q<1&&(q=1);k=Math.floor(t+k);k>this.size-1&&(k=this.size-1);for(var A,G,H,E,I,z;x<j;x++){t=this.size2*x;G=x/this.size-e;I=G*G;for(G=y;G<m;G++){H=t+this.size*G;A=G/this.size-d;z=A*A;for(A=q;A<k;A++){E=A/this.size-b;E=g/(1.0E-6+E*E+z+I)-h;E>0&&(this.field[H+A]+=E)}}}};this.addPlaneX=function(b,d){var e,g,h,k,j,m=this.size,t=this.yd,x=this.zd,y=this.field,q=m*Math.sqrt(b/d);q>m&&(q=m);for(e=0;e<q;e++){g=e/m;g*=g;k=b/(1.0E-4+g)-d;if(k>0)for(g=0;g<m;g++){j=e+g*t;for(h=0;h<m;h++)y[x*h+j]+=k}}};this.addPlaneY=
|
||||
function(b,d){var e,g,h,k,j,m,t=this.size,x=this.yd,y=this.zd,q=this.field,A=t*Math.sqrt(b/d);A>t&&(A=t);for(g=0;g<A;g++){e=g/t;e*=e;k=b/(1.0E-4+e)-d;if(k>0){j=g*x;for(e=0;e<t;e++){m=j+e;for(h=0;h<t;h++)q[y*h+m]+=k}}}};this.addPlaneZ=function(b,d){var e,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/d);dist>size&&(dist=size);for(h=0;h<dist;h++){e=h/size;e*=e;k=b/(1.0E-4+e)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(e=0;e<size;e++)field[m+e]+=k}}}};this.reset=
|
||||
k);q<1&&(q=1);k=Math.floor(t+k);k>this.size-1&&(k=this.size-1);for(var z,G,H,E,I,A;x<j;x++){t=this.size2*x;G=x/this.size-e;I=G*G;for(G=y;G<m;G++){H=t+this.size*G;z=G/this.size-d;A=z*z;for(z=q;z<k;z++){E=z/this.size-b;E=g/(1.0E-6+E*E+A+I)-h;E>0&&(this.field[H+z]+=E)}}}};this.addPlaneX=function(b,d){var e,g,h,k,j,m=this.size,t=this.yd,x=this.zd,y=this.field,q=m*Math.sqrt(b/d);q>m&&(q=m);for(e=0;e<q;e++){g=e/m;g*=g;k=b/(1.0E-4+g)-d;if(k>0)for(g=0;g<m;g++){j=e+g*t;for(h=0;h<m;h++)y[x*h+j]+=k}}};this.addPlaneY=
|
||||
function(b,d){var e,g,h,k,j,m,t=this.size,x=this.yd,y=this.zd,q=this.field,z=t*Math.sqrt(b/d);z>t&&(z=t);for(g=0;g<z;g++){e=g/t;e*=e;k=b/(1.0E-4+e)-d;if(k>0){j=g*x;for(e=0;e<t;e++){m=j+e;for(h=0;h<t;h++)q[y*h+m]+=k}}}};this.addPlaneZ=function(b,d){var e,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/d);dist>size&&(dist=size);for(h=0;h<dist;h++){e=h/size;e*=e;k=b/(1.0E-4+e)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(e=0;e<size;e++)field[m+e]+=k}}}};this.reset=
|
||||
function(){var b;for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var d,e,g,h,k,j,m,t,x,y=this.size-2;for(h=1;h<y;h++){x=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<y;g++){t=x+this.size*g;j=(g-this.halfsize)/this.halfsize;for(e=1;e<y;e++){k=(e-this.halfsize)/this.halfsize;d=t+e;this.polygonize(k,j,m,d,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,d=new THREE.Geometry;this.render(function(e){var g,h,k,
|
||||
j,m,t,x,y;for(g=0;g<e.count;g++){m=g*3;x=m+1;y=m+2;h=e.positionArray[m];k=e.positionArray[x];j=e.positionArray[y];t=new THREE.Vector3(h,k,j);h=e.normalArray[m];k=e.normalArray[x];j=e.normalArray[y];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(t,m);d.vertices.push(m)}nfaces=e.count/3;for(g=0;g<nfaces;g++){m=(b+g)*3;x=m+1;y=m+2;t=d.vertices[m].normal;h=d.vertices[x].normal;k=d.vertices[y].normal;m=new THREE.Face3(m,x,y,[t,h,k]);d.faces.push(m)}b+=nfaces;e.count=0});return d};this.init(a)};
|
||||
THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// ThreeCanvas.js r37 - http://github.com/mrdoob/three.js
|
||||
var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
|
||||
THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,d,f,g,j,h;if(c==0)e=d=f=0;else{g=Math.floor(a*6);j=a*6-g;a=c*(1-b);h=c*(1-b*j);b=c*(1-b*(1-j));switch(g){case 1:e=h;d=c;f=a;break;case 2:e=a;d=c;f=b;break;case 3:e=a;d=h;f=c;break;case 4:e=b;d=a;f=c;break;case 5:e=c;d=a;f=h;break;case 6:case 0:e=c;d=b;f=a}}this.r=e;this.g=d;this.b=f;if(this.autoUpdate){this.updateHex();
|
||||
this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
|
||||
THREE.Vector2=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,d,f,g,j,h;if(c==0)e=d=f=0;else{g=Math.floor(a*6);j=a*6-g;a=c*(1-b);h=c*(1-b*j);b=c*(1-b*(1-j));switch(g){case 1:e=h;d=c;f=a;break;case 2:e=a;d=c;f=b;break;case 3:e=a;d=h;f=c;break;case 4:e=b;d=a;f=c;break;case 5:e=c;d=a;
|
||||
f=h;break;case 6:case 0:e=c;d=b;f=a}}this.r=e;this.g=d;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*
|
||||
255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
|
||||
this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
|
||||
THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
|
||||
@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
|
||||
THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,j=e*d;this.w=g*f-j*c;this.x=g*c+j*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
|
||||
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,d=this.w,f=a.x,g=a.y,j=a.z;a=a.w;this.x=b*a+d*f+c*j-e*g;this.y=c*a+d*g+e*f-b*j;this.z=e*a+d*j+b*g-c*f;this.w=d*a-b*f-c*g-e*j;return this},
|
||||
multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,j=this.z,h=this.w,i=h*c+g*d-j*e,l=h*e+j*c-f*d,m=h*d+f*e-g*c;c=-f*c-g*e-j*d;b.x=i*h+c*-f+l*-j-m*-g;b.y=l*h+c*-g+m*-f-i*-j;b.z=m*h+c*-j+i*-g-l*-f;return b}};
|
||||
THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);if(Math.abs(g)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);if(Math.abs(g)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Face3=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};
|
||||
THREE.Face4=function(a,b,c,e,d,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// ThreeDOM.js r37 - http://github.com/mrdoob/three.js
|
||||
var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
|
||||
THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,d,g,f,i,h;if(c==0)e=d=g=0;else{f=Math.floor(a*6);i=a*6-f;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(f){case 1:e=h;d=c;g=a;break;case 2:e=a;d=c;g=b;break;case 3:e=a;d=h;g=c;break;case 4:e=b;d=a;g=c;break;case 5:e=c;d=a;g=h;break;case 6:case 0:e=c;d=b;g=a}}this.r=e;this.g=d;this.b=g;if(this.autoUpdate){this.updateHex();
|
||||
this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
|
||||
THREE.Vector2=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,d,g,f,i,h;if(c==0)e=d=g=0;else{f=Math.floor(a*6);i=a*6-f;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(f){case 1:e=h;d=c;g=a;break;case 2:e=a;d=c;g=b;break;case 3:e=a;d=h;g=c;break;case 4:e=b;d=a;g=c;break;case 5:e=c;d=a;
|
||||
g=h;break;case 6:case 0:e=c;d=b;g=a}}this.r=e;this.g=d;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*
|
||||
255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
|
||||
this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
|
||||
THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
|
||||
@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
|
||||
THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
|
||||
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this},
|
||||
multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,m=h*e+i*c-g*d,l=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+m*-i-l*-f;b.y=m*h+c*-f+l*-g-j*-i;b.z=l*h+c*-i+j*-f-m*-g;return b}};
|
||||
THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
|
||||
THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};
|
||||
|
||||
+39
-39
@@ -1,19 +1,19 @@
|
||||
// ThreeExtras.js r37 - http://github.com/mrdoob/three.js
|
||||
var GeometryUtils={merge:function(a,e){var b=e instanceof THREE.Mesh,c=a.vertices.length,g=b?e.geometry:e,f=a.vertices,d=g.vertices,h=a.faces,j=g.faces,l=a.faceVertexUvs[0];g=g.faceVertexUvs[0];b&&e.matrixAutoUpdate&&e.updateMatrix();for(var k=0,o=d.length;k<o;k++){var q=new THREE.Vertex(d[k].position.clone());b&&e.matrix.multiplyVector3(q.position);f.push(q)}k=0;for(o=j.length;k<o;k++){d=j[k];var m,t=d.vertexNormals;if(d instanceof THREE.Face3)m=new THREE.Face3(d.a+c,d.b+c,d.c+c);else d instanceof
|
||||
THREE.Face4&&(m=new THREE.Face4(d.a+c,d.b+c,d.c+c,d.d+c));m.centroid.copy(d.centroid);m.normal.copy(d.normal);b=0;for(f=t.length;b<f;b++){q=t[b];m.vertexNormals.push(q.clone())}m.materials=d.materials.slice();h.push(m)}k=0;for(o=g.length;k<o;k++){c=g[k];h=[];b=0;for(f=c.length;b<f;b++)h.push(new THREE.UV(c[b].u,c[b].v));l.push(h)}}},ImageUtils={loadTexture:function(a,e,b){var c=new Image,g=new THREE.Texture(c,e);c.onload=function(){g.needsUpdate=!0;b&&b(this)};c.src=a;return g},loadTextureCube:function(a,
|
||||
e,b){var c,g=[],f=new THREE.Texture(g,e);e=g.loadCount=0;for(c=a.length;e<c;++e){g[e]=new Image;g[e].onload=function(){g.loadCount+=1;if(g.loadCount==6)f.needsUpdate=!0;b&&b(this)};g[e].src=a[e]}return f}},SceneUtils={loadScene:function(a,e,b,c){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(k in F.objects)if(!E.objects[k]){B=F.objects[k];if(n=E.geometries[B.geometry]){M=[];for(i=0;i<B.materials.length;i++)M[i]=E.materials[B.materials[i]];z=B.position;r=B.rotation;s=B.scale;
|
||||
object=new THREE.Mesh(n,M);object.position.set(z[0],z[1],z[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;E.scene.addObject(object);E.objects[k]=object}}}function d(O){return function(U){E.geometries[O]=U;f();K-=1;h()}}function h(){c({total_models:P,total_textures:Q,loaded_models:P-K,loaded_textures:Q-L},E);K==0&&L==0&&b(E)}var j,l,k,o,q,m,t,B,z,x,y,n,H,D,M,F,J,I,K,L,P,Q,E;F=g.data;J=new THREE.BinaryLoader;I=new THREE.JSONLoader;L=K=0;E={scene:new THREE.Scene,
|
||||
geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};g=function(){L-=1;h()};for(q in F.cameras){x=F.cameras[q];if(x.type=="perspective")H=new THREE.Camera(x.fov,x.aspect,x.near,x.far);else if(x.type=="ortho"){H=new THREE.Camera;H.projectionMatrix=THREE.Matrix4.makeOrtho(x.left,x.right,x.top,x.bottom,x.near,x.far)}z=x.position;x=x.target;H.position.set(z[0],z[1],z[2]);H.target.position.set(x[0],x[1],x[2]);E.cameras[q]=H}for(o in F.lights){q=F.lights[o];if(q.type=="directional"){z=
|
||||
q.direction;light=new THREE.DirectionalLight;light.position.set(z[0],z[1],z[2]);light.position.normalize()}else if(q.type=="point"){z=q.position;light=new THREE.PointLight;light.position.set(z[0],z[1],z[2])}x=q.color;i=q.intensity||1;light.color.setRGB(x[0]*i,x[1]*i,x[2]*i);E.scene.addLight(light);E.lights[o]=light}for(m in F.fogs){o=F.fogs[m];if(o.type=="linear")D=new THREE.Fog(0,o.near,o.far);else o.type=="exp2"&&(D=new THREE.FogExp2(0,o.density));x=o.color;D.color.setRGB(x[0],x[1],x[2]);E.fogs[m]=
|
||||
D}if(E.cameras&&F.defaults.camera)E.currentCamera=E.cameras[F.defaults.camera];if(E.fogs&&F.defaults.fog)E.scene.fog=E.fogs[F.defaults.fog];x=F.defaults.bgcolor;E.bgColor=new THREE.Color;E.bgColor.setRGB(x[0],x[1],x[2]);E.bgColorAlpha=F.defaults.bgalpha;for(j in F.geometries){m=F.geometries[j];if(m.type=="bin_mesh"||m.type=="ascii_mesh")K+=1}P=K;for(j in F.geometries){m=F.geometries[j];if(m.type=="cube"){n=new Cube(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,
|
||||
m.sides);E.geometries[j]=n}else if(m.type=="plane"){n=new Plane(m.width,m.height,m.segmentsWidth,m.segmentsHeight);E.geometries[j]=n}else if(m.type=="sphere"){n=new Sphere(m.radius,m.segmentsWidth,m.segmentsHeight);E.geometries[j]=n}else if(m.type=="cylinder"){n=new Cylinder(m.numSegs,m.topRad,m.botRad,m.height,m.topOffset,m.botOffset);E.geometries[j]=n}else if(m.type=="torus"){n=new Torus(m.radius,m.tube,m.segmentsR,m.segmentsT);E.geometries[j]=n}else if(m.type=="icosahedron"){n=new Icosahedron(m.subdivisions);
|
||||
E.geometries[j]=n}else if(m.type=="bin_mesh")J.load({model:m.url,callback:d(j)});else m.type=="ascii_mesh"&&I.load({model:m.url,callback:d(j)})}for(t in F.textures){j=F.textures[t];L+=j.url instanceof Array?j.url.length:1}Q=L;for(t in F.textures){j=F.textures[t];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)m=ImageUtils.loadTextureCube(j.url,j.mapping,g);else{m=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.minFilter]!=undefined)m.minFilter=
|
||||
THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)m.magFilter=THREE[j.magFilter]}E.textures[t]=m}for(l in F.materials){t=F.materials[l];for(y in t.parameters)if(y=="envMap"||y=="map"||y=="lightMap")t.parameters[y]=E.textures[t.parameters[y]];else if(y=="shading")t.parameters[y]=t.parameters[y]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(y=="blending")t.parameters[y]=THREE[t.parameters[y]]?THREE[t.parameters[y]]:THREE.NormalBlending;else y=="combine"&&(t.parameters[y]=t.parameters[y]==
|
||||
"MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);t=new THREE[t.type](t.parameters);E.materials[l]=t}f();e(E)}},addMesh:function(a,e,b,c,g,f,d,h,j,l){e=new THREE.Mesh(e,l);e.scale.x=e.scale.y=e.scale.z=b;e.position.x=c;e.position.y=g;e.position.z=f;e.rotation.x=d;e.rotation.y=h;e.rotation.z=j;a.addObject(e);return e},addPanoramaCubeWebGL:function(a,e,b){var c=ShaderUtils.lib.cube;c.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,
|
||||
uniforms:c.uniforms});e=new THREE.Mesh(new Cube(e,e,e,1,1,1,null,!0),b);a.addObject(e);return e},addPanoramaCube:function(a,e,b){var c=[];c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));
|
||||
e=new THREE.Mesh(new Cube(e,e,e,1,1,c,!0),new THREE.MeshFaceMaterial);a.addObject(e);return e},addPanoramaCubePlanes:function(a,e,b){var c=e/2;e=new Plane(e,e);var g=Math.PI,f=Math.PI/2;SceneUtils.addMesh(a,e,1,0,0,-c,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,e,1,-c,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,e,1,c,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,
|
||||
e,1,0,c,0,f,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,e,1,0,-c,0,-f,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,e){SceneUtils.traverseHierarchy(a,function(b){b.visible=e})},traverseHierarchy:function(a,e){var b,c,g=a.children.length;for(c=0;c<g;c++){b=a.children[c];e(b);SceneUtils.traverseHierarchy(b,e)}}},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}},fragmentShader:"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}",
|
||||
var GeometryUtils={merge:function(a,e){var b=e instanceof THREE.Mesh,c=a.vertices.length,g=b?e.geometry:e,f=a.vertices,d=g.vertices,h=a.faces,j=g.faces,l=a.faceVertexUvs[0];g=g.faceVertexUvs[0];b&&e.matrixAutoUpdate&&e.updateMatrix();for(var k=0,o=d.length;k<o;k++){var q=new THREE.Vertex(d[k].position.clone());b&&e.matrix.multiplyVector3(q.position);f.push(q)}k=0;for(o=j.length;k<o;k++){d=j[k];var m,t,A=d.vertexNormals;q=d.vertexColors;if(d instanceof THREE.Face3)m=new THREE.Face3(d.a+c,d.b+c,d.c+
|
||||
c);else d instanceof THREE.Face4&&(m=new THREE.Face4(d.a+c,d.b+c,d.c+c,d.d+c));m.normal.copy(d.normal);b=0;for(f=A.length;b<f;b++){t=A[b];m.vertexNormals.push(t.clone())}m.color.copy(d.color);b=0;for(f=q.length;b<f;b++){t=q[b];m.vertexColors.push(t.clone())}m.materials=d.materials.slice();m.centroid.copy(d.centroid);h.push(m)}k=0;for(o=g.length;k<o;k++){c=g[k];h=[];b=0;for(f=c.length;b<f;b++)h.push(new THREE.UV(c[b].u,c[b].v));l.push(h)}}},ImageUtils={loadTexture:function(a,e,b){var c=new Image,g=
|
||||
new THREE.Texture(c,e);c.onload=function(){g.needsUpdate=!0;b&&b(this)};c.src=a;return g},loadTextureCube:function(a,e,b){var c,g=[],f=new THREE.Texture(g,e);e=g.loadCount=0;for(c=a.length;e<c;++e){g[e]=new Image;g[e].onload=function(){g.loadCount+=1;if(g.loadCount==6)f.needsUpdate=!0;b&&b(this)};g[e].src=a[e]}return f}},SceneUtils={loadScene:function(a,e,b,c){a=new Worker(a);a.postMessage(0);a.onmessage=function(g){function f(){for(k in F.objects)if(!E.objects[k]){A=F.objects[k];if(n=E.geometries[A.geometry]){M=
|
||||
[];for(i=0;i<A.materials.length;i++)M[i]=E.materials[A.materials[i]];z=A.position;r=A.rotation;s=A.scale;object=new THREE.Mesh(n,M);object.position.set(z[0],z[1],z[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;E.scene.addObject(object);E.objects[k]=object}}}function d(O){return function(U){E.geometries[O]=U;f();K-=1;h()}}function h(){c({total_models:P,total_textures:Q,loaded_models:P-K,loaded_textures:Q-L},E);K==0&&L==0&&b(E)}var j,l,k,o,q,m,t,A,
|
||||
z,x,y,n,H,D,M,F,J,I,K,L,P,Q,E;F=g.data;J=new THREE.BinaryLoader;I=new THREE.JSONLoader;L=K=0;E={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};g=function(){L-=1;h()};for(q in F.cameras){x=F.cameras[q];if(x.type=="perspective")H=new THREE.Camera(x.fov,x.aspect,x.near,x.far);else if(x.type=="ortho"){H=new THREE.Camera;H.projectionMatrix=THREE.Matrix4.makeOrtho(x.left,x.right,x.top,x.bottom,x.near,x.far)}z=x.position;x=x.target;H.position.set(z[0],
|
||||
z[1],z[2]);H.target.position.set(x[0],x[1],x[2]);E.cameras[q]=H}for(o in F.lights){q=F.lights[o];if(q.type=="directional"){z=q.direction;light=new THREE.DirectionalLight;light.position.set(z[0],z[1],z[2]);light.position.normalize()}else if(q.type=="point"){z=q.position;light=new THREE.PointLight;light.position.set(z[0],z[1],z[2])}x=q.color;i=q.intensity||1;light.color.setRGB(x[0]*i,x[1]*i,x[2]*i);E.scene.addLight(light);E.lights[o]=light}for(m in F.fogs){o=F.fogs[m];if(o.type=="linear")D=new THREE.Fog(0,
|
||||
o.near,o.far);else o.type=="exp2"&&(D=new THREE.FogExp2(0,o.density));x=o.color;D.color.setRGB(x[0],x[1],x[2]);E.fogs[m]=D}if(E.cameras&&F.defaults.camera)E.currentCamera=E.cameras[F.defaults.camera];if(E.fogs&&F.defaults.fog)E.scene.fog=E.fogs[F.defaults.fog];x=F.defaults.bgcolor;E.bgColor=new THREE.Color;E.bgColor.setRGB(x[0],x[1],x[2]);E.bgColorAlpha=F.defaults.bgalpha;for(j in F.geometries){m=F.geometries[j];if(m.type=="bin_mesh"||m.type=="ascii_mesh")K+=1}P=K;for(j in F.geometries){m=F.geometries[j];
|
||||
if(m.type=="cube"){n=new Cube(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides);E.geometries[j]=n}else if(m.type=="plane"){n=new Plane(m.width,m.height,m.segmentsWidth,m.segmentsHeight);E.geometries[j]=n}else if(m.type=="sphere"){n=new Sphere(m.radius,m.segmentsWidth,m.segmentsHeight);E.geometries[j]=n}else if(m.type=="cylinder"){n=new Cylinder(m.numSegs,m.topRad,m.botRad,m.height,m.topOffset,m.botOffset);E.geometries[j]=n}else if(m.type=="torus"){n=
|
||||
new Torus(m.radius,m.tube,m.segmentsR,m.segmentsT);E.geometries[j]=n}else if(m.type=="icosahedron"){n=new Icosahedron(m.subdivisions);E.geometries[j]=n}else if(m.type=="bin_mesh")J.load({model:m.url,callback:d(j)});else m.type=="ascii_mesh"&&I.load({model:m.url,callback:d(j)})}for(t in F.textures){j=F.textures[t];L+=j.url instanceof Array?j.url.length:1}Q=L;for(t in F.textures){j=F.textures[t];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)m=
|
||||
ImageUtils.loadTextureCube(j.url,j.mapping,g);else{m=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.minFilter]!=undefined)m.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)m.magFilter=THREE[j.magFilter]}E.textures[t]=m}for(l in F.materials){t=F.materials[l];for(y in t.parameters)if(y=="envMap"||y=="map"||y=="lightMap")t.parameters[y]=E.textures[t.parameters[y]];else if(y=="shading")t.parameters[y]=t.parameters[y]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(y=="blending")t.parameters[y]=
|
||||
THREE[t.parameters[y]]?THREE[t.parameters[y]]:THREE.NormalBlending;else y=="combine"&&(t.parameters[y]=t.parameters[y]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);t=new THREE[t.type](t.parameters);E.materials[l]=t}f();e(E)}},addMesh:function(a,e,b,c,g,f,d,h,j,l){e=new THREE.Mesh(e,l);e.scale.x=e.scale.y=e.scale.z=b;e.position.x=c;e.position.y=g;e.position.z=f;e.rotation.x=d;e.rotation.y=h;e.rotation.z=j;a.addObject(e);return e},addPanoramaCubeWebGL:function(a,e,b){var c=ShaderUtils.lib.cube;
|
||||
c.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,uniforms:c.uniforms});e=new THREE.Mesh(new Cube(e,e,e,1,1,1,null,!0),b);a.addObject(e);return e},addPanoramaCube:function(a,e,b){var c=[];c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));
|
||||
c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));e=new THREE.Mesh(new Cube(e,e,e,1,1,c,!0),new THREE.MeshFaceMaterial);a.addObject(e);return e},addPanoramaCubePlanes:function(a,e,b){var c=e/2;e=new Plane(e,e);var g=Math.PI,f=Math.PI/2;SceneUtils.addMesh(a,e,1,0,0,-c,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,e,1,-c,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));
|
||||
SceneUtils.addMesh(a,e,1,c,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,e,1,0,c,0,f,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,e,1,0,-c,0,-f,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,e){SceneUtils.traverseHierarchy(a,function(b){b.visible=e})},traverseHierarchy:function(a,e){var b,c,g=a.children.length;for(c=0;c<g;c++){b=a.children[c];e(b);SceneUtils.traverseHierarchy(b,
|
||||
e)}}},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}},fragmentShader:"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}",
|
||||
vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
|
||||
normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
|
||||
uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragmentShader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
|
||||
@@ -23,7 +23,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
|
||||
film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
|
||||
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
|
||||
fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var e,b,c,g,f=2*Math.ceil(a*3)+1;f>25&&(f=25);g=(f-1)*0.5;b=Array(f);for(e=c=0;e<f;++e){b[e]=Math.exp(-((e-g)*(e-g))/(2*a*a));c+=b[e]}for(e=0;e<f;++e)b[e]/=c;return b}};
|
||||
THREE.QuakeCamera=function(a){function e(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
|
||||
THREE.QuakeCamera=function(a){function e(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
|
||||
a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=
|
||||
this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(!this.dragToLook)switch(b.button){case 0:this.moveForward=
|
||||
!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
|
||||
@@ -31,9 +31,9 @@ this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBack
|
||||
var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var c=this.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},
|
||||
!1);this.domElement.addEventListener("mousemove",e(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",e(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",e(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",e(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",e(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
|
||||
THREE.QuakeCamera.prototype.translate=function(a,e){this.matrix.rotateAxis(e);if(this.noFly)e.y=0;this.position.addSelf(e.multiplyScalar(a));this.target.position.addSelf(e.multiplyScalar(a))};
|
||||
THREE.PathCamera=function(a){function e(l,k,o,q){var m={name:o,fps:0.6,length:q,hierarchy:[]},t,B=k.getControlPointsArray(),z=k.getLength(),x=B.length,y=0;t=x-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:B[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[t]={time:q,pos:B[t],rot:[0,0,0,1],scl:[1,1,1]};for(t=1;t<x-1;t++){y=q*z.chunks[t]/z.total;k.keys[t]={time:y,pos:B[t]}}m.hierarchy[0]=k;THREE.AnimationHandler.add(m);return new THREE.Animation(l,o,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(l,k){var o,
|
||||
THREE.PathCamera=function(a){function e(l,k,o,q){var m={name:o,fps:0.6,length:q,hierarchy:[]},t,A=k.getControlPointsArray(),z=k.getLength(),x=A.length,y=0;t=x-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:A[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[t]={time:q,pos:A[t],rot:[0,0,0,1],scl:[1,1,1]};for(t=1;t<x-1;t++){y=q*z.chunks[t]/z.total;k.keys[t]={time:y,pos:A[t]}}m.hierarchy[0]=k;THREE.AnimationHandler.add(m);return new THREE.Animation(l,o,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(l,k){var o,
|
||||
q,m=new THREE.Geometry;for(o=0;o<l.points.length*k;o++){q=o/(l.points.length*k);q=l.getPoint(q);m.vertices[o]=new THREE.Vertex(new THREE.Vector3(q.x,q.y,q.z))}return m}function c(l,k){var o=b(k,10),q=b(k,10),m=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(o,m);particleObj=new THREE.ParticleSystem(q,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);l.addChild(lineObj);particleObj.scale.set(1,1,1);l.addChild(particleObj);q=new Sphere(1,
|
||||
16,8);m=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){o=new THREE.Mesh(q,m);o.position.copy(k.points[i]);o.updateMatrix();l.addChild(o)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
|
||||
16,8);m=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){o=new THREE.Mesh(q,m);o.position.copy(k.points[i]);o.updateMatrix();l.addChild(o)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
|
||||
!0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
|
||||
if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
|
||||
this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,f=Math.PI/180;this.update=function(l,k,o){var q,m;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*f;this.theta=this.lon*f;q=this.phi%g;this.phi=q>=0?q:q+g;q=this.verticalAngleMap.srcRange;m=this.verticalAngleMap.dstRange;
|
||||
@@ -41,24 +41,24 @@ this.phi=(this.phi-q[0])*(m[1]-m[0])/(q[1]-q[0])+m[0];q=this.horizontalAngleMap.
|
||||
this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var d=new THREE.MeshLambertMaterial({color:65280}),h=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,d);a.position.set(0,10,0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
|
||||
e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&c(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(l,k){return function(){k.apply(l,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
|
||||
var Cube=function(a,e,b,c,g,f,d,h,j){function l(z,x,y,n,H,D,M,F){var J,I,K=c||1,L=g||1,P=H/2,Q=D/2,E=k.vertices.length;if(z=="x"&&x=="y"||z=="y"&&x=="x")J="z";else if(z=="x"&&x=="z"||z=="z"&&x=="x"){J="y";L=f||1}else if(z=="z"&&x=="y"||z=="y"&&x=="z"){J="x";K=f||1}var O=K+1,U=L+1;H/=K;var $=D/L;for(I=0;I<U;I++)for(D=0;D<O;D++){var T=new THREE.Vector3;T[z]=(D*H-P)*y;T[x]=(I*$-Q)*n;T[J]=M;k.vertices.push(new THREE.Vertex(T))}for(I=0;I<L;I++)for(D=0;D<K;D++){k.faces.push(new THREE.Face4(D+O*I+E,D+O*
|
||||
(I+1)+E,D+1+O*(I+1)+E,D+1+O*I+E,null,null,F));k.faceVertexUvs[0].push([new THREE.UV(D/K,I/L),new THREE.UV(D/K,(I+1)/L),new THREE.UV((D+1)/K,(I+1)/L),new THREE.UV((D+1)/K,I/L)])}}THREE.Geometry.call(this);var k=this,o=a/2,q=e/2,m=b/2;h=h?-1:1;if(d!==undefined)if(d instanceof Array)this.materials=d;else{this.materials=[];for(var t=0;t<6;t++)this.materials.push([d])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var B in j)this.sides[B]!=undefined&&(this.sides[B]=
|
||||
j[B]);this.sides.px&&l("z","y",1*h,-1,b,e,-o,this.materials[0]);this.sides.nx&&l("z","y",-1*h,-1,b,e,o,this.materials[1]);this.sides.py&&l("x","z",1*h,1,a,b,q,this.materials[2]);this.sides.ny&&l("x","z",1*h,-1,a,b,-q,this.materials[3]);this.sides.pz&&l("x","y",1*h,-1,a,e,m,this.materials[4]);this.sides.nz&&l("x","y",-1*h,-1,a,e,-m,this.materials[5]);(function(){for(var z=[],x=[],y=0,n=k.vertices.length;y<n;y++){for(var H=k.vertices[y],D=!1,M=0,F=z.length;M<F;M++){var J=z[M];if(H.position.x==J.position.x&&
|
||||
(I+1)+E,D+1+O*(I+1)+E,D+1+O*I+E,null,null,F));k.faceVertexUvs[0].push([new THREE.UV(D/K,I/L),new THREE.UV(D/K,(I+1)/L),new THREE.UV((D+1)/K,(I+1)/L),new THREE.UV((D+1)/K,I/L)])}}THREE.Geometry.call(this);var k=this,o=a/2,q=e/2,m=b/2;h=h?-1:1;if(d!==undefined)if(d instanceof Array)this.materials=d;else{this.materials=[];for(var t=0;t<6;t++)this.materials.push([d])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var A in j)this.sides[A]!=undefined&&(this.sides[A]=
|
||||
j[A]);this.sides.px&&l("z","y",1*h,-1,b,e,-o,this.materials[0]);this.sides.nx&&l("z","y",-1*h,-1,b,e,o,this.materials[1]);this.sides.py&&l("x","z",1*h,1,a,b,q,this.materials[2]);this.sides.ny&&l("x","z",1*h,-1,a,b,-q,this.materials[3]);this.sides.pz&&l("x","y",1*h,-1,a,e,m,this.materials[4]);this.sides.nz&&l("x","y",-1*h,-1,a,e,-m,this.materials[5]);(function(){for(var z=[],x=[],y=0,n=k.vertices.length;y<n;y++){for(var H=k.vertices[y],D=!1,M=0,F=z.length;M<F;M++){var J=z[M];if(H.position.x==J.position.x&&
|
||||
H.position.y==J.position.y&&H.position.z==J.position.z){x[y]=M;D=!0;break}}if(!D){x[y]=z.length;z.push(new THREE.Vertex(H.position.clone()))}}y=0;for(n=k.faces.length;y<n;y++){H=k.faces[y];H.a=x[H.a];H.b=x[H.b];H.c=x[H.c];H.d=x[H.d]}k.vertices=z})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
|
||||
var Cylinder=function(a,e,b,c,g,f){function d(k,o,q){h.vertices.push(new THREE.Vertex(new THREE.Vector3(k,o,q)))}THREE.Geometry.call(this);var h=this,j=Math.PI,l=c/2;for(c=0;c<a;c++)d(Math.sin(2*j*c/a)*e,Math.cos(2*j*c/a)*e,-l);for(c=0;c<a;c++)d(Math.sin(2*j*c/a)*b,Math.cos(2*j*c/a)*b,l);for(c=0;c<a;c++)h.faces.push(new THREE.Face4(c,c+a,a+(c+1)%a,(c+1)%a));if(b>0){d(0,0,-l-(f||0));for(c=a;c<a+a/2;c++)h.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(e>0){d(0,0,l+(g||0));
|
||||
for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2*a+1)%a+a,(2*c-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
|
||||
var Icosahedron=function(a){function e(o,q,m){var t=Math.sqrt(o*o+q*q+m*m);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(o/t,q/t,m/t)))-1}function b(o,q,m,t){t.faces.push(new THREE.Face3(o,q,m))}function c(o,q){var m=g.vertices[o].position,t=g.vertices[q].position;return e((m.x+t.x)/2,(m.y+t.y)/2,(m.z+t.z)/2)}var g=this,f=new THREE.Geometry,d;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;e(-1,a,0);e(1,a,0);e(-1,-a,0);e(1,-a,0);e(0,-1,a);e(0,1,a);e(0,-1,-a);e(0,
|
||||
1,-a);e(a,0,-1);e(a,0,1);e(-a,0,-1);e(-a,0,1);b(0,11,5,f);b(0,5,1,f);b(0,1,7,f);b(0,7,10,f);b(0,10,11,f);b(1,5,9,f);b(5,11,4,f);b(11,10,2,f);b(10,7,6,f);b(7,1,8,f);b(3,9,4,f);b(3,4,2,f);b(3,2,6,f);b(3,6,8,f);b(3,8,9,f);b(4,9,5,f);b(2,4,11,f);b(6,2,10,f);b(8,6,7,f);b(9,8,1,f);for(a=0;a<this.subdivisions;a++){d=new THREE.Geometry;for(var h in f.faces){var j=c(f.faces[h].a,f.faces[h].b),l=c(f.faces[h].b,f.faces[h].c),k=c(f.faces[h].c,f.faces[h].a);b(f.faces[h].a,j,k,d);b(f.faces[h].b,l,j,d);b(f.faces[h].c,
|
||||
k,l,d);b(j,l,k,d)}f.faces=d.faces}g.faces=f.faces;delete f;delete d;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
|
||||
function Lathe(a,e,b){THREE.Geometry.call(this);this.steps=e||12;this.angle=b||2*Math.PI;e=this.angle/this.steps;for(var c=[],g=[],f=[],d=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));c[h]=a[h].clone();g[h]=this.vertices.length-1}for(var j=(new THREE.Matrix4).setRotationZ(e),l=0;l<=this.angle+0.0010;l+=e){for(h=0;h<c.length;h++)if(l<this.angle){c[h]=j.multiplyVector3(c[h].clone());this.vertices.push(new THREE.Vertex(c[h]));f[h]=this.vertices.length-1}else f=d;l==0&&(d=g);for(h=
|
||||
function Lathe(a,e,b){THREE.Geometry.call(this);this.steps=e||12;this.angle=b||2*Math.PI;e=this.angle/this.steps;for(var c=[],g=[],f=[],d=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));c[h]=a[h].clone();g[h]=this.vertices.length-1}for(var j=(new THREE.Matrix4).setRotationZ(e),l=0;l<=this.angle+0.001;l+=e){for(h=0;h<c.length;h++)if(l<this.angle){c[h]=j.multiplyVector3(c[h].clone());this.vertices.push(new THREE.Vertex(c[h]));f[h]=this.vertices.length-1}else f=d;l==0&&(d=g);for(h=
|
||||
0;h<g.length-1;h++){this.faces.push(new THREE.Face4(f[h],f[h+1],g[h+1],g[h]));this.faceVertexUvs[0].push([new THREE.UV(l/b,h/a.length),new THREE.UV(l/b,(h+1)/a.length),new THREE.UV((l-e)/b,(h+1)/a.length),new THREE.UV((l-e)/b,h/a.length)])}g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
|
||||
var Plane=function(a,e,b,c){THREE.Geometry.call(this);var g,f=a/2,d=e/2;b=b||1;c=c||1;var h=b+1,j=c+1;a/=b;var l=e/c;for(g=0;g<j;g++)for(e=0;e<h;e++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(e*a-f,-(g*l-d),0)));for(g=0;g<c;g++)for(e=0;e<b;e++){this.faces.push(new THREE.Face4(e+h*g,e+h*(g+1),e+1+h*(g+1),e+1+h*g));this.faceVertexUvs[0].push([new THREE.UV(e/b,g/c),new THREE.UV(e/b,(g+1)/c),new THREE.UV((e+1)/b,(g+1)/c),new THREE.UV((e+1)/b,g/c)])}this.computeCentroids();this.computeFaceNormals()};
|
||||
Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
|
||||
var Sphere=function(a,e,b){THREE.Geometry.call(this);var c,g=Math.PI,f=Math.max(3,e||8),d=Math.max(2,b||6);e=[];for(b=0;b<d+1;b++){c=b/d;var h=a*Math.cos(c*g),j=a*Math.sin(c*g),l=[],k=0;for(c=0;c<f;c++){var o=2*c/f,q=j*Math.sin(o*g);o=j*Math.cos(o*g);(b==0||b==d)&&c>0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,h,q)))-1);l.push(k)}e.push(l)}var m,t,B;g=e.length;for(b=0;b<g;b++){f=e[b].length;if(b>0)for(c=0;c<f;c++){l=c==f-1;d=e[b][l?0:c+1];h=e[b][l?f-1:c];j=e[b-1][l?f-1:c];l=e[b-1][l?
|
||||
0:c+1];q=b/(g-1);m=(b-1)/(g-1);t=(c+1)/f;o=c/f;k=new THREE.UV(1-t,q);q=new THREE.UV(1-o,q);o=new THREE.UV(1-o,m);var z=new THREE.UV(1-t,m);if(b<e.length-1){m=this.vertices[d].position.clone();t=this.vertices[h].position.clone();B=this.vertices[j].position.clone();m.normalize();t.normalize();B.normalize();this.faces.push(new THREE.Face3(d,h,j,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(B.x,B.y,B.z)]));this.faceVertexUvs[0].push([k,q,o])}if(b>1){m=this.vertices[d].position.clone();
|
||||
t=this.vertices[j].position.clone();B=this.vertices[l].position.clone();m.normalize();t.normalize();B.normalize();this.faces.push(new THREE.Face3(d,j,l,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(B.x,B.y,B.z)]));this.faceVertexUvs[0].push([k,o,z])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
var Sphere=function(a,e,b){THREE.Geometry.call(this);var c,g=Math.PI,f=Math.max(3,e||8),d=Math.max(2,b||6);e=[];for(b=0;b<d+1;b++){c=b/d;var h=a*Math.cos(c*g),j=a*Math.sin(c*g),l=[],k=0;for(c=0;c<f;c++){var o=2*c/f,q=j*Math.sin(o*g);o=j*Math.cos(o*g);(b==0||b==d)&&c>0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,h,q)))-1);l.push(k)}e.push(l)}var m,t,A;g=e.length;for(b=0;b<g;b++){f=e[b].length;if(b>0)for(c=0;c<f;c++){l=c==f-1;d=e[b][l?0:c+1];h=e[b][l?f-1:c];j=e[b-1][l?f-1:c];l=e[b-1][l?
|
||||
0:c+1];q=b/(g-1);m=(b-1)/(g-1);t=(c+1)/f;o=c/f;k=new THREE.UV(1-t,q);q=new THREE.UV(1-o,q);o=new THREE.UV(1-o,m);var z=new THREE.UV(1-t,m);if(b<e.length-1){m=this.vertices[d].position.clone();t=this.vertices[h].position.clone();A=this.vertices[j].position.clone();m.normalize();t.normalize();A.normalize();this.faces.push(new THREE.Face3(d,h,j,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(A.x,A.y,A.z)]));this.faceVertexUvs[0].push([k,q,o])}if(b>1){m=this.vertices[d].position.clone();
|
||||
t=this.vertices[j].position.clone();A=this.vertices[l].position.clone();m.normalize();t.normalize();A.normalize();this.faces.push(new THREE.Face3(d,j,l,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(A.x,A.y,A.z)]));this.faceVertexUvs[0].push([k,o,z])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
|
||||
var Torus=function(a,e,b,c){this.radius=a||100;this.tube=e||40;this.segmentsR=b||8;this.segmentsT=c||6;a=[];THREE.Geometry.call(this);for(e=0;e<=this.segmentsR;++e)for(b=0;b<=this.segmentsT;++b){c=b/this.segmentsT*2*Math.PI;var g=e/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(c),(this.radius+this.tube*Math.cos(g))*Math.sin(c),this.tube*Math.sin(g))));a.push([b/this.segmentsT,1-e/this.segmentsR])}for(e=1;e<=this.segmentsR;++e)for(b=
|
||||
1;b<=this.segmentsT;++b){c=(this.segmentsT+1)*e+b;g=(this.segmentsT+1)*e+b-1;var f=(this.segmentsT+1)*(e-1)+b-1,d=(this.segmentsT+1)*(e-1)+b;this.faces.push(new THREE.Face4(c,g,f,d));this.faceVertexUvs[0].push([new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[d][0],a[d][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
|
||||
var TorusKnot=function(a,e,b,c,g,f,d){function h(o,q,m,t,B,z){q=m/t*o;m=Math.cos(q);return new THREE.Vector3(B*(2+m)*0.5*Math.cos(o),B*(2+m)*Math.sin(o)*0.5,z*B*Math.sin(q)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=e||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=g||2;this.q=f||3;this.heightScale=d||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(e=0;e<this.segmentsT;++e){var j=
|
||||
var TorusKnot=function(a,e,b,c,g,f,d){function h(o,q,m,t,A,z){q=m/t*o;m=Math.cos(q);return new THREE.Vector3(A*(2+m)*0.5*Math.cos(o),A*(2+m)*Math.sin(o)*0.5,z*A*Math.sin(q)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=e||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=g||2;this.q=f||3;this.heightScale=d||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(e=0;e<this.segmentsT;++e){var j=
|
||||
a/this.segmentsR*2*this.p*Math.PI;d=e/this.segmentsT*2*Math.PI;g=h(j,d,this.q,this.p,this.radius,this.heightScale);j=h(j+0.01,d,this.q,this.p,this.radius,this.heightScale);b.x=j.x-g.x;b.y=j.y-g.y;b.z=j.z-g.z;c.x=j.x+g.x;c.y=j.y+g.y;c.z=j.z+g.z;f.cross(b,c);c.cross(f,b);f.normalize();c.normalize();j=this.tube*Math.cos(d);d=this.tube*Math.sin(d);g.x+=j*c.x+d*f.x;g.y+=j*c.y+d*f.y;g.z+=j*c.z+d*f.z;this.grid[a][e]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,g.z)))-1}}for(a=0;a<this.segmentsR;++a)for(e=
|
||||
0;e<this.segmentsT;++e){f=(a+1)%this.segmentsR;d=(e+1)%this.segmentsT;g=this.grid[a][e];b=this.grid[f][e];c=this.grid[a][d];f=this.grid[f][d];d=new THREE.UV(a/this.segmentsR,e/this.segmentsT);j=new THREE.UV((a+1)/this.segmentsR,e/this.segmentsT);var l=new THREE.UV(a/this.segmentsR,(e+1)/this.segmentsT),k=new THREE.UV((a+1)/this.segmentsR,(e+1)/this.segmentsT);this.faces.push(new THREE.Face3(g,b,c));this.faceVertexUvs[0].push([d,j,l]);this.faces.push(new THREE.Face3(f,c,b));this.faceVertexUvs[0].push([k,
|
||||
l,j])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null};
|
||||
@@ -68,37 +68,37 @@ h.image.width=k;h.image.height=o;h.image.getContext("2d").drawImage(this,0,0,k,o
|
||||
(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;f.color=d;f.opacity=a.transparency}else if(a.DbgColor)f.color=a.DbgColor;if(a.mapLightmap&&e){d=document.createElement("canvas");f.lightMap=new THREE.Texture(d);f.lightMap.sourceFile=a.mapLightmap;c(f.lightMap,e+"/"+a.mapLightmap)}return new THREE[g](f)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
|
||||
THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
|
||||
THREE.JSONLoader.prototype={load:function(a){var e=a.model,b=a.callback,c=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(e);a=(new Date).getTime();e=new Worker(e);e.onmessage=function(g){THREE.JSONLoader.prototype.createModel(g.data,b,c)};e.postMessage(a)},createModel:function(a,e,b){var c=function(g){var f=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(f,a.materials,g);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");
|
||||
else{var d,h,j,l,k,o,q,m,t,B,z=a.faces;m=a.vertices;var x=a.normals,y=a.colors,n=0;for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&n++;for(d=0;d<n;d++){f.faceUvs[d]=[];f.faceVertexUvs[d]=[]}j=0;for(l=m.length;j<l;){t=new THREE.Vertex;t.position.x=m[j++];t.position.y=m[j++];t.position.z=m[j++];f.vertices.push(t)}j=0;for(l=z.length;j<l;){k=z[j++];o=k&1;d=k&2;q=k&4;h=k&8;m=k&16;t=k&32;B=k&64;k&=128;if(o){o=new THREE.Face4;o.a=z[j++];o.b=z[j++];o.c=z[j++];o.d=z[j++];nVertices=4}else{o=new THREE.Face3;o.a=
|
||||
else{var d,h,j,l,k,o,q,m,t,A,z=a.faces;m=a.vertices;var x=a.normals,y=a.colors,n=0;for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&n++;for(d=0;d<n;d++){f.faceUvs[d]=[];f.faceVertexUvs[d]=[]}j=0;for(l=m.length;j<l;){t=new THREE.Vertex;t.position.x=m[j++];t.position.y=m[j++];t.position.z=m[j++];f.vertices.push(t)}j=0;for(l=z.length;j<l;){k=z[j++];o=k&1;d=k&2;q=k&4;h=k&8;m=k&16;t=k&32;A=k&64;k&=128;if(o){o=new THREE.Face4;o.a=z[j++];o.b=z[j++];o.c=z[j++];o.d=z[j++];nVertices=4}else{o=new THREE.Face3;o.a=
|
||||
z[j++];o.b=z[j++];o.c=z[j++];nVertices=3}if(d){materialIndex=z[j++];o.materials=f.materials[materialIndex]}if(q)for(d=0;d<n;d++){uvLayer=a.uvs[d];uvIndex=z[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];f.faceUvs[d].push(new THREE.UV(u,v))}if(h)for(d=0;d<n;d++){uvLayer=a.uvs[d];uvs=[];for(h=0;h<nVertices;h++){uvIndex=z[j++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];uvs[h]=new THREE.UV(u,v)}h=f.faces.length;f.faceVertexUvs[d][h]=uvs}if(m){normalIndex=z[j++]*3;normal=new THREE.Vector3;normal.x=
|
||||
x[normalIndex++];normal.y=x[normalIndex++];normal.z=x[normalIndex];o.normal=normal}if(t)for(d=0;d<nVertices;d++){normalIndex=z[j++]*3;normal=new THREE.Vector3;normal.x=x[normalIndex++];normal.y=x[normalIndex++];normal.z=x[normalIndex];o.vertexNormals.push(normal)}if(B){color=new THREE.Color(z[j++]);o.color=color}if(k)for(d=0;d<nVertices;d++){colorIndex=z[j++];color=new THREE.Color(y[colorIndex]);o.vertexColors.push(color)}f.faces.push(o)}}})();(function(){var d,h,j,l;if(a.skinWeights){d=0;for(h=a.skinWeights.length;d<
|
||||
x[normalIndex++];normal.y=x[normalIndex++];normal.z=x[normalIndex];o.normal=normal}if(t)for(d=0;d<nVertices;d++){normalIndex=z[j++]*3;normal=new THREE.Vector3;normal.x=x[normalIndex++];normal.y=x[normalIndex++];normal.z=x[normalIndex];o.vertexNormals.push(normal)}if(A){color=new THREE.Color(z[j++]);o.color=color}if(k)for(d=0;d<nVertices;d++){colorIndex=z[j++];color=new THREE.Color(y[colorIndex]);o.vertexColors.push(color)}f.faces.push(o)}}})();(function(){var d,h,j,l;if(a.skinWeights){d=0;for(h=a.skinWeights.length;d<
|
||||
h;d+=2){j=a.skinWeights[d];l=a.skinWeights[d+1];f.skinWeights.push(new THREE.Vector4(j,l,0,0))}}if(a.skinIndices){d=0;for(h=a.skinIndices.length;d<h;d+=2){j=a.skinIndices[d];l=a.skinIndices[d+1];f.skinIndices.push(new THREE.Vector4(j,l,0,0))}}f.bones=a.bones;f.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var d,h,j,l;d=0;for(h=a.morphTargets.length;d<h;d++){f.morphTargets[d]={};f.morphTargets[d].name=a.morphTargets[d].name;f.morphTargets[d].vertices=[];dstVertices=f.morphTargets[d].vertices;
|
||||
srcVertices=a.morphTargets[d].vertices;j=0;for(l=srcVertices.length;j<l;j+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[j],srcVertices[j+1],srcVertices[j+2])))}}})();this.computeCentroids();this.computeFaceNormals()};c.prototype=new THREE.Geometry;c.prototype.constructor=c;e(new c(b))}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;
|
||||
THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
|
||||
THREE.BinaryLoader.prototype={load:function(a){var e=a.model,b=a.callback,c=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(e),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(e);a=(new Date).getTime();e=new Worker(e);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;e.onmessage=function(d){THREE.BinaryLoader.prototype.loadAjaxBuffers(d.data.buffers,d.data.materials,b,g,c,f)};e.onerror=function(d){alert("worker.onerror: "+d.message+"\n"+d.data);d.preventDefault()};
|
||||
e.postMessage(a)},loadAjaxBuffers:function(a,e,b,c,g,f){var d=new XMLHttpRequest,h=c+"/"+a,j=0;d.onreadystatechange=function(){if(d.readyState==4)d.status==200||d.status==0?THREE.BinaryLoader.prototype.createBinModel(d.responseText,b,g,e):alert("Couldn't load ["+h+"] ["+d.status+"]");else if(d.readyState==3){if(f){j==0&&(j=d.getResponseHeader("Content-Length"));f({total:j,loaded:d.responseText.length})}}else d.readyState==2&&(j=d.getResponseHeader("Content-Length"))};d.open("GET",h,!0);d.overrideMimeType("text/plain; charset=x-user-defined");
|
||||
d.setRequestHeader("Content-Type","text/plain");d.send(null)},createBinModel:function(a,e,b,c){var g=function(f){function d(p,w){var A=k(p,w),C=k(p,w+1),G=k(p,w+2),N=k(p,w+3),R=(N<<1&255|G>>7)-127;A|=(G&127)<<16|C<<8;if(A==0&&R==-127)return 0;return(1-2*(N>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,R)}function h(p,w){var A=k(p,w),C=k(p,w+1),G=k(p,w+2);return(k(p,w+3)<<24)+(G<<16)+(C<<8)+A}function j(p,w){var A=k(p,w);return(k(p,w+1)<<8)+A}function l(p,w){var A=k(p,w);return A>127?A-256:A}function k(p,
|
||||
w){return p.charCodeAt(w)&255}function o(p){var w,A,C;w=h(a,p);A=h(a,p+M);C=h(a,p+F);p=j(a,p+J);THREE.BinaryLoader.prototype.f3(x,w,A,C,p)}function q(p){var w,A,C,G,N,R;w=h(a,p);A=h(a,p+M);C=h(a,p+F);G=j(a,p+J);N=h(a,p+I);R=h(a,p+K);p=h(a,p+L);THREE.BinaryLoader.prototype.f3n(x,H,w,A,C,G,N,R,p)}function m(p){var w,A,C,G;w=h(a,p);A=h(a,p+P);C=h(a,p+Q);G=h(a,p+E);p=j(a,p+O);THREE.BinaryLoader.prototype.f4(x,w,A,C,G,p)}function t(p){var w,A,C,G,N,R,aa,ba;w=h(a,p);A=h(a,p+P);C=h(a,p+Q);G=h(a,p+E);N=j(a,
|
||||
p+O);R=h(a,p+U);aa=h(a,p+$);ba=h(a,p+T);p=h(a,p+ca);THREE.BinaryLoader.prototype.f4n(x,H,w,A,C,G,N,R,aa,ba,p)}function B(p){var w,A;w=h(a,p);A=h(a,p+da);p=h(a,p+ea);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],D[w*2],D[w*2+1],D[A*2],D[A*2+1],D[p*2],D[p*2+1])}function z(p){var w,A,C;w=h(a,p);A=h(a,p+fa);C=h(a,p+ga);p=h(a,p+ha);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],D[w*2],D[w*2+1],D[A*2],D[A*2+1],D[C*2],D[C*2+1],D[p*2],D[p*2+1])}var x=this,y=0,n,H=[],D=[],M,F,J,I,K,L,P,Q,E,O,U,
|
||||
d.setRequestHeader("Content-Type","text/plain");d.send(null)},createBinModel:function(a,e,b,c){var g=function(f){function d(p,w){var B=k(p,w),C=k(p,w+1),G=k(p,w+2),N=k(p,w+3),R=(N<<1&255|G>>7)-127;B|=(G&127)<<16|C<<8;if(B==0&&R==-127)return 0;return(1-2*(N>>7))*(1+B*Math.pow(2,-23))*Math.pow(2,R)}function h(p,w){var B=k(p,w),C=k(p,w+1),G=k(p,w+2);return(k(p,w+3)<<24)+(G<<16)+(C<<8)+B}function j(p,w){var B=k(p,w);return(k(p,w+1)<<8)+B}function l(p,w){var B=k(p,w);return B>127?B-256:B}function k(p,
|
||||
w){return p.charCodeAt(w)&255}function o(p){var w,B,C;w=h(a,p);B=h(a,p+M);C=h(a,p+F);p=j(a,p+J);THREE.BinaryLoader.prototype.f3(x,w,B,C,p)}function q(p){var w,B,C,G,N,R;w=h(a,p);B=h(a,p+M);C=h(a,p+F);G=j(a,p+J);N=h(a,p+I);R=h(a,p+K);p=h(a,p+L);THREE.BinaryLoader.prototype.f3n(x,H,w,B,C,G,N,R,p)}function m(p){var w,B,C,G;w=h(a,p);B=h(a,p+P);C=h(a,p+Q);G=h(a,p+E);p=j(a,p+O);THREE.BinaryLoader.prototype.f4(x,w,B,C,G,p)}function t(p){var w,B,C,G,N,R,aa,ba;w=h(a,p);B=h(a,p+P);C=h(a,p+Q);G=h(a,p+E);N=j(a,
|
||||
p+O);R=h(a,p+U);aa=h(a,p+$);ba=h(a,p+T);p=h(a,p+ca);THREE.BinaryLoader.prototype.f4n(x,H,w,B,C,G,N,R,aa,ba,p)}function A(p){var w,B;w=h(a,p);B=h(a,p+da);p=h(a,p+ea);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],D[w*2],D[w*2+1],D[B*2],D[B*2+1],D[p*2],D[p*2+1])}function z(p){var w,B,C;w=h(a,p);B=h(a,p+fa);C=h(a,p+ga);p=h(a,p+ha);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],D[w*2],D[w*2+1],D[B*2],D[B*2+1],D[C*2],D[C*2+1],D[p*2],D[p*2+1])}var x=this,y=0,n,H=[],D=[],M,F,J,I,K,L,P,Q,E,O,U,
|
||||
$,T,ca,da,ea,fa,ga,ha,V,W,X,Y,Z,S;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,c,f);n={signature:a.substr(y,8),header_bytes:k(a,y+8),vertex_coordinate_bytes:k(a,y+9),normal_coordinate_bytes:k(a,y+10),uv_coordinate_bytes:k(a,y+11),vertex_index_bytes:k(a,y+12),normal_index_bytes:k(a,y+13),uv_index_bytes:k(a,y+14),material_index_bytes:k(a,y+15),nvertices:h(a,y+16),nnormals:h(a,y+16+4),nuvs:h(a,y+16+8),ntri_flat:h(a,y+16+12),ntri_smooth:h(a,y+16+16),ntri_flat_uv:h(a,y+16+20),ntri_smooth_uv:h(a,
|
||||
y+16+24),nquad_flat:h(a,y+16+28),nquad_smooth:h(a,y+16+32),nquad_flat_uv:h(a,y+16+36),nquad_smooth_uv:h(a,y+16+40)};y+=n.header_bytes;M=n.vertex_index_bytes;F=n.vertex_index_bytes*2;J=n.vertex_index_bytes*3;I=n.vertex_index_bytes*3+n.material_index_bytes;K=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes;Q=n.vertex_index_bytes*2;E=n.vertex_index_bytes*3;O=n.vertex_index_bytes*4;U=n.vertex_index_bytes*
|
||||
4+n.material_index_bytes;$=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;T=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;ca=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;da=n.uv_index_bytes;ea=n.uv_index_bytes*2;fa=n.uv_index_bytes;ga=n.uv_index_bytes*2;ha=n.uv_index_bytes*3;f=n.vertex_index_bytes*3+n.material_index_bytes;S=n.vertex_index_bytes*4+n.material_index_bytes;V=n.ntri_flat*f;W=n.ntri_smooth*(f+n.normal_index_bytes*3);X=n.ntri_flat_uv*
|
||||
(f+n.uv_index_bytes*3);Y=n.ntri_smooth_uv*(f+n.normal_index_bytes*3+n.uv_index_bytes*3);Z=n.nquad_flat*S;f=n.nquad_smooth*(S+n.normal_index_bytes*4);S=n.nquad_flat_uv*(S+n.uv_index_bytes*4);y+=function(p){for(var w,A,C,G=n.vertex_coordinate_bytes*3,N=p+n.nvertices*G;p<N;p+=G){w=d(a,p);A=d(a,p+n.vertex_coordinate_bytes);C=d(a,p+n.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(x,w,A,C)}return n.nvertices*G}(y);y+=function(p){for(var w,A,C,G=n.normal_coordinate_bytes*3,N=p+n.nnormals*G;p<
|
||||
N;p+=G){w=l(a,p);A=l(a,p+n.normal_coordinate_bytes);C=l(a,p+n.normal_coordinate_bytes*2);H.push(w/127,A/127,C/127)}return n.nnormals*G}(y);y+=function(p){for(var w,A,C=n.uv_coordinate_bytes*2,G=p+n.nuvs*C;p<G;p+=C){w=d(a,p);A=d(a,p+n.uv_coordinate_bytes);D.push(w,A)}return n.nuvs*C}(y);V=y+V;W=V+W;X=W+X;Y=X+Y;Z=Y+Z;f=Z+f;S=f+S;(function(p){var w,A=n.vertex_index_bytes*3+n.material_index_bytes,C=A+n.uv_index_bytes*3,G=p+n.ntri_flat_uv*C;for(w=p;w<G;w+=C){o(w);B(w+A)}return G-p})(W);(function(p){var w,
|
||||
A=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,C=A+n.uv_index_bytes*3,G=p+n.ntri_smooth_uv*C;for(w=p;w<G;w+=C){q(w);B(w+A)}return G-p})(X);(function(p){var w,A=n.vertex_index_bytes*4+n.material_index_bytes,C=A+n.uv_index_bytes*4,G=p+n.nquad_flat_uv*C;for(w=p;w<G;w+=C){m(w);z(w+A)}return G-p})(f);(function(p){var w,A=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,C=A+n.uv_index_bytes*4,G=p+n.nquad_smooth_uv*C;for(w=p;w<G;w+=C){t(w);z(w+A)}return G-p})(S);
|
||||
(function(p){var w,A=n.vertex_index_bytes*3+n.material_index_bytes,C=p+n.ntri_flat*A;for(w=p;w<C;w+=A)o(w);return C-p})(y);(function(p){var w,A=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,C=p+n.ntri_smooth*A;for(w=p;w<C;w+=A)q(w);return C-p})(V);(function(p){var w,A=n.vertex_index_bytes*4+n.material_index_bytes,C=p+n.nquad_flat*A;for(w=p;w<C;w+=A)m(w);return C-p})(Y);(function(p){var w,A=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,C=p+n.nquad_smooth*
|
||||
A;for(w=p;w<C;w+=A)t(w);return C-p})(Z);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;e(new g(b))},v:function(a,e,b,c){a.vertices.push(new THREE.Vertex(new THREE.Vector3(e,b,c)))},f3:function(a,e,b,c,g){a.faces.push(new THREE.Face3(e,b,c,null,null,a.materials[g]))},f4:function(a,e,b,c,g,f){a.faces.push(new THREE.Face4(e,b,c,g,null,null,a.materials[f]))},f3n:function(a,e,b,c,g,f,d,h,j){f=a.materials[f];var l=e[h*3],k=e[h*3+1];h=e[h*3+2];
|
||||
var o=e[j*3],q=e[j*3+1];j=e[j*3+2];a.faces.push(new THREE.Face3(b,c,g,[new THREE.Vector3(e[d*3],e[d*3+1],e[d*3+2]),new THREE.Vector3(l,k,h),new THREE.Vector3(o,q,j)],null,f))},f4n:function(a,e,b,c,g,f,d,h,j,l,k){d=a.materials[d];var o=e[j*3],q=e[j*3+1];j=e[j*3+2];var m=e[l*3],t=e[l*3+1];l=e[l*3+2];var B=e[k*3],z=e[k*3+1];k=e[k*3+2];a.faces.push(new THREE.Face4(b,c,g,f,[new THREE.Vector3(e[h*3],e[h*3+1],e[h*3+2]),new THREE.Vector3(o,q,j),new THREE.Vector3(m,t,l),new THREE.Vector3(B,z,k)],null,d))},
|
||||
(f+n.uv_index_bytes*3);Y=n.ntri_smooth_uv*(f+n.normal_index_bytes*3+n.uv_index_bytes*3);Z=n.nquad_flat*S;f=n.nquad_smooth*(S+n.normal_index_bytes*4);S=n.nquad_flat_uv*(S+n.uv_index_bytes*4);y+=function(p){for(var w,B,C,G=n.vertex_coordinate_bytes*3,N=p+n.nvertices*G;p<N;p+=G){w=d(a,p);B=d(a,p+n.vertex_coordinate_bytes);C=d(a,p+n.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(x,w,B,C)}return n.nvertices*G}(y);y+=function(p){for(var w,B,C,G=n.normal_coordinate_bytes*3,N=p+n.nnormals*G;p<
|
||||
N;p+=G){w=l(a,p);B=l(a,p+n.normal_coordinate_bytes);C=l(a,p+n.normal_coordinate_bytes*2);H.push(w/127,B/127,C/127)}return n.nnormals*G}(y);y+=function(p){for(var w,B,C=n.uv_coordinate_bytes*2,G=p+n.nuvs*C;p<G;p+=C){w=d(a,p);B=d(a,p+n.uv_coordinate_bytes);D.push(w,B)}return n.nuvs*C}(y);V=y+V;W=V+W;X=W+X;Y=X+Y;Z=Y+Z;f=Z+f;S=f+S;(function(p){var w,B=n.vertex_index_bytes*3+n.material_index_bytes,C=B+n.uv_index_bytes*3,G=p+n.ntri_flat_uv*C;for(w=p;w<G;w+=C){o(w);A(w+B)}return G-p})(W);(function(p){var w,
|
||||
B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,C=B+n.uv_index_bytes*3,G=p+n.ntri_smooth_uv*C;for(w=p;w<G;w+=C){q(w);A(w+B)}return G-p})(X);(function(p){var w,B=n.vertex_index_bytes*4+n.material_index_bytes,C=B+n.uv_index_bytes*4,G=p+n.nquad_flat_uv*C;for(w=p;w<G;w+=C){m(w);z(w+B)}return G-p})(f);(function(p){var w,B=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,C=B+n.uv_index_bytes*4,G=p+n.nquad_smooth_uv*C;for(w=p;w<G;w+=C){t(w);z(w+B)}return G-p})(S);
|
||||
(function(p){var w,B=n.vertex_index_bytes*3+n.material_index_bytes,C=p+n.ntri_flat*B;for(w=p;w<C;w+=B)o(w);return C-p})(y);(function(p){var w,B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,C=p+n.ntri_smooth*B;for(w=p;w<C;w+=B)q(w);return C-p})(V);(function(p){var w,B=n.vertex_index_bytes*4+n.material_index_bytes,C=p+n.nquad_flat*B;for(w=p;w<C;w+=B)m(w);return C-p})(Y);(function(p){var w,B=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,C=p+n.nquad_smooth*
|
||||
B;for(w=p;w<C;w+=B)t(w);return C-p})(Z);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;e(new g(b))},v:function(a,e,b,c){a.vertices.push(new THREE.Vertex(new THREE.Vector3(e,b,c)))},f3:function(a,e,b,c,g){a.faces.push(new THREE.Face3(e,b,c,null,null,a.materials[g]))},f4:function(a,e,b,c,g,f){a.faces.push(new THREE.Face4(e,b,c,g,null,null,a.materials[f]))},f3n:function(a,e,b,c,g,f,d,h,j){f=a.materials[f];var l=e[h*3],k=e[h*3+1];h=e[h*3+2];
|
||||
var o=e[j*3],q=e[j*3+1];j=e[j*3+2];a.faces.push(new THREE.Face3(b,c,g,[new THREE.Vector3(e[d*3],e[d*3+1],e[d*3+2]),new THREE.Vector3(l,k,h),new THREE.Vector3(o,q,j)],null,f))},f4n:function(a,e,b,c,g,f,d,h,j,l,k){d=a.materials[d];var o=e[j*3],q=e[j*3+1];j=e[j*3+2];var m=e[l*3],t=e[l*3+1];l=e[l*3+2];var A=e[k*3],z=e[k*3+1];k=e[k*3+2];a.faces.push(new THREE.Face4(b,c,g,f,[new THREE.Vector3(e[h*3],e[h*3+1],e[h*3+2]),new THREE.Vector3(o,q,j),new THREE.Vector3(m,t,l),new THREE.Vector3(A,z,k)],null,d))},
|
||||
uv3:function(a,e,b,c,g,f,d){var h=[];h.push(new THREE.UV(e,b));h.push(new THREE.UV(c,g));h.push(new THREE.UV(f,d));a.push(h)},uv4:function(a,e,b,c,g,f,d,h,j){var l=[];l.push(new THREE.UV(e,b));l.push(new THREE.UV(c,g));l.push(new THREE.UV(f,d));l.push(new THREE.UV(h,j));a.push(l)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
|
||||
THREE.MarchingCubes=function(a,e){THREE.Object3D.call(this);this.materials=e instanceof Array?e:[e];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
|
||||
0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,g){return b+(c-b)*g};this.VIntX=function(b,c,g,f,d,h,j,l,k,o){d=(d-k)/(o-k);k=this.normal_cache;c[f]=h+d*this.delta;c[f+1]=j;c[f+2]=l;g[f]=this.lerp(k[b],k[b+3],d);g[f+1]=this.lerp(k[b+1],k[b+4],d);g[f+2]=this.lerp(k[b+2],k[b+5],d)};this.VIntY=function(b,c,g,f,d,h,j,l,k,o){d=(d-k)/(o-k);k=this.normal_cache;c[f]=h;c[f+1]=j+d*this.delta;c[f+
|
||||
2]=l;c=b+this.yd*3;g[f]=this.lerp(k[b],k[c],d);g[f+1]=this.lerp(k[b+1],k[c+1],d);g[f+2]=this.lerp(k[b+2],k[c+2],d)};this.VIntZ=function(b,c,g,f,d,h,j,l,k,o){d=(d-k)/(o-k);k=this.normal_cache;c[f]=h;c[f+1]=j;c[f+2]=l+d*this.delta;c=b+this.zd*3;g[f]=this.lerp(k[b],k[c],d);g[f+1]=this.lerp(k[b+1],k[c+1],d);g[f+2]=this.lerp(k[b+2],k[c+2],d)};this.compNorm=function(b){var c=b*3;if(this.normal_cache[c]==0){this.normal_cache[c]=this.field[b-1]-this.field[b+1];this.normal_cache[c+1]=this.field[b-this.yd]-
|
||||
this.field[b+this.yd];this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,c,g,f,d,h){var j=f+1,l=f+this.yd,k=f+this.zd,o=j+this.yd,q=j+this.zd,m=f+this.yd+this.zd,t=j+this.yd+this.zd,B=0,z=this.field[f],x=this.field[j],y=this.field[l],n=this.field[o],H=this.field[k],D=this.field[q],M=this.field[m],F=this.field[t];z<d&&(B|=1);x<d&&(B|=2);y<d&&(B|=8);n<d&&(B|=4);H<d&&(B|=16);D<d&&(B|=32);M<d&&(B|=128);F<d&&(B|=64);var J=THREE.edgeTable[B];if(J==0)return 0;
|
||||
this.field[b+this.yd];this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,c,g,f,d,h){var j=f+1,l=f+this.yd,k=f+this.zd,o=j+this.yd,q=j+this.zd,m=f+this.yd+this.zd,t=j+this.yd+this.zd,A=0,z=this.field[f],x=this.field[j],y=this.field[l],n=this.field[o],H=this.field[k],D=this.field[q],M=this.field[m],F=this.field[t];z<d&&(A|=1);x<d&&(A|=2);y<d&&(A|=8);n<d&&(A|=4);H<d&&(A|=16);D<d&&(A|=32);M<d&&(A|=128);F<d&&(A|=64);var J=THREE.edgeTable[A];if(J==0)return 0;
|
||||
var I=this.delta,K=b+I,L=c+I;I=g+I;if(J&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,d,b,c,g,z,x)}if(J&2){this.compNorm(j);this.compNorm(o);this.VIntY(j*3,this.vlist,this.nlist,3,d,K,c,g,x,n)}if(J&4){this.compNorm(l);this.compNorm(o);this.VIntX(l*3,this.vlist,this.nlist,6,d,b,L,g,y,n)}if(J&8){this.compNorm(f);this.compNorm(l);this.VIntY(f*3,this.vlist,this.nlist,9,d,b,c,g,z,y)}if(J&16){this.compNorm(k);this.compNorm(q);this.VIntX(k*3,this.vlist,this.nlist,12,d,b,c,I,
|
||||
H,D)}if(J&32){this.compNorm(q);this.compNorm(t);this.VIntY(q*3,this.vlist,this.nlist,15,d,K,c,I,D,F)}if(J&64){this.compNorm(m);this.compNorm(t);this.VIntX(m*3,this.vlist,this.nlist,18,d,b,L,I,M,F)}if(J&128){this.compNorm(k);this.compNorm(m);this.VIntY(k*3,this.vlist,this.nlist,21,d,b,c,I,H,M)}if(J&256){this.compNorm(f);this.compNorm(k);this.VIntZ(f*3,this.vlist,this.nlist,24,d,b,c,g,z,H)}if(J&512){this.compNorm(j);this.compNorm(q);this.VIntZ(j*3,this.vlist,this.nlist,27,d,K,c,g,x,D)}if(J&1024){this.compNorm(o);
|
||||
this.compNorm(t);this.VIntZ(o*3,this.vlist,this.nlist,30,d,K,L,g,n,F)}if(J&2048){this.compNorm(l);this.compNorm(m);this.VIntZ(l*3,this.vlist,this.nlist,33,d,b,L,g,y,M)}B<<=4;for(d=f=0;THREE.triTable[B+d]!=-1;){b=B+d;c=b+1;g=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[g],h);d+=3;f++}return f};this.posnormtriv=function(b,c,g,f,d,h){var j=this.count*3;this.positionArray[j]=b[g];this.positionArray[j+1]=b[g+1];this.positionArray[j+2]=b[g+2];this.positionArray[j+
|
||||
this.compNorm(t);this.VIntZ(o*3,this.vlist,this.nlist,30,d,K,L,g,n,F)}if(J&2048){this.compNorm(l);this.compNorm(m);this.VIntZ(l*3,this.vlist,this.nlist,33,d,b,L,g,y,M)}A<<=4;for(d=f=0;THREE.triTable[A+d]!=-1;){b=A+d;c=b+1;g=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[g],h);d+=3;f++}return f};this.posnormtriv=function(b,c,g,f,d,h){var j=this.count*3;this.positionArray[j]=b[g];this.positionArray[j+1]=b[g+1];this.positionArray[j+2]=b[g+2];this.positionArray[j+
|
||||
3]=b[f];this.positionArray[j+4]=b[f+1];this.positionArray[j+5]=b[f+2];this.positionArray[j+6]=b[d];this.positionArray[j+7]=b[d+1];this.positionArray[j+8]=b[d+2];this.normalArray[j]=c[g];this.normalArray[j+1]=c[g+1];this.normalArray[j+2]=c[g+2];this.normalArray[j+3]=c[f];this.normalArray[j+4]=c[f+1];this.normalArray[j+5]=c[f+2];this.normalArray[j+6]=c[d];this.normalArray[j+7]=c[d+1];this.normalArray[j+8]=c[d+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
|
||||
function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;b(this)}};this.addBall=function(b,c,g,f,d){var h=this.size*Math.sqrt(f/d),j=g*this.size,l=c*this.size,k=b*this.size,o=Math.floor(j-h);o<1&&(o=1);j=Math.floor(j+h);j>this.size-1&&(j=this.size-1);var q=Math.floor(l-h);q<1&&(q=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var m=Math.floor(k-h);m<1&&(m=1);h=Math.floor(k+h);
|
||||
h>this.size-1&&(h=this.size-1);for(var t,B,z,x,y,n;o<j;o++){k=this.size2*o;B=o/this.size-g;y=B*B;for(B=q;B<l;B++){z=k+this.size*B;t=B/this.size-c;n=t*t;for(t=m;t<h;t++){x=t/this.size-b;x=f/(1.0E-6+x*x+n+y)-d;x>0&&(this.field[z+t]+=x)}}}};this.addPlaneX=function(b,c){var g,f,d,h,j,l=this.size,k=this.yd,o=this.zd,q=this.field,m=l*Math.sqrt(b/c);m>l&&(m=l);for(g=0;g<m;g++){f=g/l;f*=f;h=b/(1.0E-4+f)-c;if(h>0)for(f=0;f<l;f++){j=g+f*k;for(d=0;d<l;d++)q[o*d+j]+=h}}};this.addPlaneY=function(b,c){var g,f,
|
||||
h>this.size-1&&(h=this.size-1);for(var t,A,z,x,y,n;o<j;o++){k=this.size2*o;A=o/this.size-g;y=A*A;for(A=q;A<l;A++){z=k+this.size*A;t=A/this.size-c;n=t*t;for(t=m;t<h;t++){x=t/this.size-b;x=f/(1.0E-6+x*x+n+y)-d;x>0&&(this.field[z+t]+=x)}}}};this.addPlaneX=function(b,c){var g,f,d,h,j,l=this.size,k=this.yd,o=this.zd,q=this.field,m=l*Math.sqrt(b/c);m>l&&(m=l);for(g=0;g<m;g++){f=g/l;f*=f;h=b/(1.0E-4+f)-c;if(h>0)for(f=0;f<l;f++){j=g+f*k;for(d=0;d<l;d++)q[o*d+j]+=h}}};this.addPlaneY=function(b,c){var g,f,
|
||||
d,h,j,l,k=this.size,o=this.yd,q=this.zd,m=this.field,t=k*Math.sqrt(b/c);t>k&&(t=k);for(f=0;f<t;f++){g=f/k;g*=g;h=b/(1.0E-4+g)-c;if(h>0){j=f*o;for(g=0;g<k;g++){l=j+g;for(d=0;d<k;d++)m[q*d+l]+=h}}}};this.addPlaneZ=function(b,c){var g,f,d,h,j,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(d=0;d<dist;d++){g=d/size;g*=g;h=b/(1.0E-4+g)-c;if(h>0){j=zd*d;for(f=0;f<size;f++){l=j+f*yd;for(g=0;g<size;g++)field[l+g]+=h}}}};this.reset=function(){var b;
|
||||
for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var c,g,f,d,h,j,l,k,o,q=this.size-2;for(d=1;d<q;d++){o=this.size2*d;l=(d-this.halfsize)/this.halfsize;for(f=1;f<q;f++){k=o+this.size*f;j=(f-this.halfsize)/this.halfsize;for(g=1;g<q;g++){h=(g-this.halfsize)/this.halfsize;c=k+g;this.polygonize(h,j,l,c,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry;this.render(function(g){var f,d,h,j,l,k,o,q;for(f=
|
||||
0;f<g.count;f++){l=f*3;o=l+1;q=l+2;d=g.positionArray[l];h=g.positionArray[o];j=g.positionArray[q];k=new THREE.Vector3(d,h,j);d=g.normalArray[l];h=g.normalArray[o];j=g.normalArray[q];l=new THREE.Vector3(d,h,j);l.normalize();l=new THREE.Vertex(k,l);c.vertices.push(l)}nfaces=g.count/3;for(f=0;f<nfaces;f++){l=(b+f)*3;o=l+1;q=l+2;k=c.vertices[l].normal;d=c.vertices[o].normal;h=c.vertices[q].normal;l=new THREE.Face3(l,o,q,[k,d,h]);c.faces.push(l)}b+=nfaces;g.count=0});return c};this.init(a)};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// ThreeSVG.js r37 - http://github.com/mrdoob/three.js
|
||||
var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
|
||||
THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,d,f,g,i,h;if(c==0)e=d=f=0;else{g=Math.floor(a*6);i=a*6-g;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(g){case 1:e=h;d=c;f=a;break;case 2:e=a;d=c;f=b;break;case 3:e=a;d=h;f=c;break;case 4:e=b;d=a;f=c;break;case 5:e=c;d=a;f=h;break;case 6:case 0:e=c;d=b;f=a}}this.r=e;this.g=d;this.b=f;if(this.autoUpdate){this.updateHex();
|
||||
this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
|
||||
THREE.Vector2=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,d,f,g,i,h;if(c==0)e=d=f=0;else{g=Math.floor(a*6);i=a*6-g;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(g){case 1:e=h;d=c;f=a;break;case 2:e=a;d=c;f=b;break;case 3:e=a;d=h;f=c;break;case 4:e=b;d=a;f=c;break;case 5:e=c;d=a;
|
||||
f=h;break;case 6:case 0:e=c;d=b;f=a}}this.r=e;this.g=d;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*
|
||||
255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
|
||||
this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
|
||||
THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
|
||||
@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
|
||||
THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=e*d;this.w=g*f-i*c;this.x=g*c+i*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
|
||||
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,d=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+d*f+c*i-e*g;this.y=c*a+d*g+e*f-b*i;this.z=e*a+d*i+b*g-c*f;this.w=d*a-b*f-c*g-e*i;return this},
|
||||
multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*d-i*e,m=h*e+i*c-f*d,l=h*d+f*e-g*c;c=-f*c-g*e-i*d;b.x=j*h+c*-f+m*-i-l*-g;b.y=m*h+c*-g+l*-f-j*-i;b.z=l*h+c*-i+j*-g-m*-f;return b}};
|
||||
THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);if(Math.abs(g)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);if(Math.abs(g)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Face3=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};
|
||||
THREE.Face4=function(a,b,c,e,d,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// ThreeWebGL.js r37 - http://github.com/mrdoob/three.js
|
||||
var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
|
||||
THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var f,e,h,j,p,n;if(c==0)f=e=h=0;else{j=Math.floor(a*6);p=a*6-j;a=c*(1-b);n=c*(1-b*p);b=c*(1-b*(1-p));switch(j){case 1:f=n;e=c;h=a;break;case 2:f=a;e=c;h=b;break;case 3:f=a;e=n;h=c;break;case 4:f=b;e=a;h=c;break;case 5:f=c;e=a;h=n;break;case 6:case 0:f=c;e=b;h=a}}this.r=f;this.g=e;this.b=h;if(this.autoUpdate){this.updateHex();
|
||||
this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
|
||||
THREE.Vector2=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var f,e,h,j,p,n;if(c==0)f=e=h=0;else{j=Math.floor(a*6);p=a*6-j;a=c*(1-b);n=c*(1-b*p);b=c*(1-b*(1-p));switch(j){case 1:f=n;e=c;h=a;break;case 2:f=a;e=c;h=b;break;case 3:f=a;e=n;h=c;break;case 4:f=b;e=a;h=c;break;case 5:f=c;e=a;
|
||||
h=n;break;case 6:case 0:f=c;e=b;h=a}}this.r=f;this.g=e;this.b=h;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*
|
||||
255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
|
||||
this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
|
||||
THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
|
||||
@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,f){this.set(a||0,b||0,c||0,f!==undefined?
|
||||
THREE.Quaternion.prototype={set:function(a,b,c,f){this.x=a;this.y=b;this.z=c;this.w=f;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,f=a.y*b,e=a.z*b;a=Math.cos(f);f=Math.sin(f);b=Math.cos(-e);e=Math.sin(-e);var h=Math.cos(c);c=Math.sin(c);var j=a*b,p=f*e;this.w=j*h-p*c;this.x=j*c+p*h;this.y=f*b*h+a*e*c;this.z=a*e*h-f*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
|
||||
-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,f=this.z,e=this.w,h=a.x,j=a.y,p=a.z;a=a.w;this.x=b*a+e*h+c*p-f*j;this.y=c*a+e*j+f*h-b*p;this.z=f*a+e*p+b*j-c*h;this.w=e*a-b*h-c*j-f*p;return this},
|
||||
multiplyVector3:function(a,b){b||(b=a);var c=a.x,f=a.y,e=a.z,h=this.x,j=this.y,p=this.z,n=this.w,s=n*c+j*e-p*f,x=n*f+p*c-h*e,z=n*e+h*f-j*c;c=-h*c-j*f-p*e;b.x=s*n+c*-h+x*-p-z*-j;b.y=x*n+c*-j+z*-h-s*-p;b.z=z*n+c*-p+s*-j-x*-h;return b}};
|
||||
THREE.Quaternion.slerp=function(a,b,c,f){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),j=Math.sqrt(1-e*e);if(Math.abs(j)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;c.w=a.w*e+b.w*f;c.x=a.x*e+b.x*f;c.y=a.y*e+b.y*f;c.z=a.z*e+b.z*f;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Quaternion.slerp=function(a,b,c,f){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),j=Math.sqrt(1-e*e);if(Math.abs(j)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;c.w=a.w*e+b.w*f;c.x=a.x*e+b.x*f;c.y=a.y*e+b.y*f;c.z=a.z*e+b.z*f;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
|
||||
THREE.Face3=function(a,b,c,f,e,h){this.a=a;this.b=b;this.c=c;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
|
||||
THREE.Face4=function(a,b,c,f,e,h,j){this.a=a;this.b=b;this.c=c;this.d=f;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
|
||||
THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
|
||||
|
||||
Reference in New Issue
Block a user