|
|
|
@@ -1,81 +1,82 @@
|
|
|
|
|
// Three.js r41/ROME - http://github.com/mrdoob/three.js
|
|
|
|
|
var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(b){this.setHex(b)};
|
|
|
|
|
THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,c,d){this.r=b;this.g=c;this.b=d;this.updateHex()},setHSV:function(b,c,d){var e,f,h,j,k,m;if(d==0)e=f=h=0;else switch(j=Math.floor(b*6),k=b*6-j,b=d*(1-c),m=d*(1-c*k),c=d*(1-c*(1-k)),j){case 1:e=m;f=d;h=b;break;case 2:e=b;f=d;h=c;break;case 3:e=b;f=m;h=d;break;case 4:e=c;f=b;h=d;break;case 5:e=d;f=b;h=m;break;case 6:case 0:e=d,f=c,h=b}this.setRGB(e,
|
|
|
|
|
f,h)},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},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,c){this.set(b||0,c||0)};
|
|
|
|
|
THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,c,e){this.r=b;this.g=c;this.b=e;this.updateHex()},setHSV:function(b,c,e){var f,g,j,k,m,n;if(e==0)f=g=j=0;else switch(k=Math.floor(b*6),m=b*6-k,b=e*(1-c),n=e*(1-c*m),c=e*(1-c*(1-m)),k){case 1:f=n;g=e;j=b;break;case 2:f=b;g=e;j=c;break;case 3:f=b;g=n;j=e;break;case 4:f=c;g=b;j=e;break;case 5:f=e;g=b;j=n;break;case 6:case 0:f=e,g=c,j=b}this.setRGB(f,
|
|
|
|
|
g,j)},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},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,c){this.set(b||0,c||0)};
|
|
|
|
|
THREE.Vector2.prototype={set:function(b,c){this.x=b;this.y=c;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this},divideScalar:function(b){b?
|
|
|
|
|
(this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},unit:function(){return this.normalize()}};THREE.Vector3=function(b,c,d){this.set(b||0,c||0,d||0)};
|
|
|
|
|
THREE.Vector3.prototype={set:function(b,c,d){this.x=b;this.y=c;this.z=d;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this},addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;return this},subSelf:function(b){this.x-=
|
|
|
|
|
(this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,b=this.y-b.y;return c*c+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)},
|
|
|
|
|
unit:function(){return this.normalize()},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,e){this.set(b||0,c||0,e||0)};
|
|
|
|
|
THREE.Vector3.prototype={set:function(b,c,e){this.x=b;this.y=c;this.z=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this},addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;return this},subSelf:function(b){this.x-=
|
|
|
|
|
b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,c){this.x=b.x*c.x;this.y=b.y*c.y;this.z=b.z*c.z;return this},multiplySelf:function(b){this.x*=b.x;this.y*=b.y;this.z*=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;return this},divideSelf:function(b){return this.divide(this,b)},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b):this.set(0,0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*
|
|
|
|
|
b.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},cross:function(b,c){this.x=b.y*c.z-b.z*c.y;this.y=b.z*c.x-b.x*c.z;this.z=b.x*c.y-b.y*c.x;return this},crossSelf:function(b){return this.set(this.y*b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*
|
|
|
|
|
b.y-this.y*b.x)},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){return(new THREE.Vector3).sub(this,b).lengthSq()},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var c=Math.cos(this.y);this.y=Math.asin(b.n13);Math.abs(c)>1.0E-5?(this.x=Math.atan2(-b.n23/c,b.n33/c),this.z=Math.atan2(-b.n12/c,b.n11/c)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};
|
|
|
|
|
THREE.Vector4=function(b,c,d,e){this.set(b||0,c||0,d||0,e||1)};
|
|
|
|
|
THREE.Vector4.prototype={set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){return this.set(b.x,b.y,b.z,b.w||1)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;this.w=b.w-c.w;return this},subSelf:function(b){this.x-=
|
|
|
|
|
THREE.Vector4=function(b,c,e,f){this.set(b||0,c||0,e||0,f||1)};
|
|
|
|
|
THREE.Vector4.prototype={set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){return this.set(b.x,b.y,b.z,b.w||1)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;this.w=b.w-c.w;return this},subSelf:function(b){this.x-=
|
|
|
|
|
b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):this.set(0,0,0,1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},
|
|
|
|
|
setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3};
|
|
|
|
|
THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,d,e=[];c=0;for(d=b.length;c<d;c++)e=e.concat(this.intersectObject(b[c]));e.sort(function(b,d){return b.distance-d.distance});return e},intersectObject:function(b){function c(b,d,c){var e;e=c.position.clone().subSelf(b).dot(d);if(e<0)return!1;b=b.clone().addSelf(d.clone().multiplyScalar(e));return c.position.distanceTo(b)}function d(b,d,c,e){var e=e.clone().subSelf(d),c=c.clone().subSelf(d),
|
|
|
|
|
f=b.clone().subSelf(d),b=e.dot(e),d=e.dot(c),e=e.dot(f),h=c.dot(c),c=c.dot(f),f=1/(b*h-d*d),h=(h*e-d*c)*f,b=(b*c-d*e)*f;return h>0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var e=c(this.origin,this.direction,b);if(!e||e>b.scale.x)return[];return[{distance:e,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){e=c(this.origin,this.direction,b);if(!e||e>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var f,h,j,k,m,o,n,p,t,u,v=b.geometry,
|
|
|
|
|
C=v.vertices,E=[],e=0;for(f=v.faces.length;e<f;e++)if(h=v.faces[e],t=this.origin.clone(),u=this.direction.clone(),o=b.matrixWorld,j=o.multiplyVector3(C[h.a].position.clone()),k=o.multiplyVector3(C[h.b].position.clone()),m=o.multiplyVector3(C[h.c].position.clone()),o=h instanceof THREE.Face4?o.multiplyVector3(C[h.d].position.clone()):null,n=b.matrixRotationWorld.multiplyVector3(h.normal.clone()),p=u.dot(n),b.doubleSided||(b.flipSided?p>0:p<0))if(n=n.dot((new THREE.Vector3).sub(j,t))/p,t=t.addSelf(u.multiplyScalar(n)),
|
|
|
|
|
h instanceof THREE.Face3)d(t,j,k,m)&&(h={distance:this.origin.distanceTo(t),point:t,face:h,object:b},E.push(h));else if(h instanceof THREE.Face4&&(d(t,j,k,o)||d(t,k,m,o)))h={distance:this.origin.distanceTo(t),point:t,face:h,object:b},E.push(h);return E}else return[]}};
|
|
|
|
|
THREE.Rectangle=function(){function b(){h=e-c;j=f-d}var c,d,e,f,h,j,k=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(h,j,n,p){k=!1;c=h;d=j;e=n;f=p;b()};this.addPoint=function(h,j){k?(k=!1,c=h,d=j,e=h,f=j):(c=c<h?c:h,d=d<j?d:j,e=e>h?e:h,f=f>j?f:j);b()};this.add3Points=
|
|
|
|
|
function(h,j,n,p,t,u){k?(k=!1,c=h<n?h<t?h:t:n<t?n:t,d=j<p?j<u?j:u:p<u?p:u,e=h>n?h>t?h:t:n>t?n:t,f=j>p?j>u?j:u:p>u?p:u):(c=h<n?h<t?h<c?h:c:t<c?t:c:n<t?n<c?n:c:t<c?t:c,d=j<p?j<u?j<d?j:d:u<d?u:d:p<u?p<d?p:d:u<d?u:d,e=h>n?h>t?h>e?h:e:t>e?t:e:n>t?n>e?n:e:t>e?t:e,f=j>p?j>u?j>f?j:f:u>f?u:f:p>u?p>f?p:f:u>f?u:f);b()};this.addRectangle=function(h){k?(k=!1,c=h.getLeft(),d=h.getTop(),e=h.getRight(),f=h.getBottom()):(c=c<h.getLeft()?c:h.getLeft(),d=d<h.getTop()?d:h.getTop(),e=e>h.getRight()?e:h.getRight(),f=f>
|
|
|
|
|
h.getBottom()?f:h.getBottom());b()};this.inflate=function(h){c-=h;d-=h;e+=h;f+=h;b()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();d=d>h.getTop()?d:h.getTop();e=e<h.getRight()?e:h.getRight();f=f<h.getBottom()?f:h.getBottom();b()};this.instersects=function(b){return Math.min(e,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(f,b.getBottom())-Math.max(d,b.getTop())>=0};this.empty=function(){k=!0;f=e=d=c=0;b()};this.isEmpty=function(){return k}};THREE.Matrix3=function(){this.m=[]};
|
|
|
|
|
THREE.Matrix3.prototype={transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,d,e,f,h,j,k,m,o,n,p,t,u,v,C){this.set(b||1,c||0,d||0,e||0,f||0,h||1,j||0,k||0,m||0,o||0,n||1,p||0,t||0,u||0,v||0,C||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
|
|
|
|
|
THREE.Matrix4.prototype={set:function(b,c,d,e,f,h,j,k,m,o,n,p,t,u,v,C){this.n11=b;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=o;this.n33=n;this.n34=p;this.n41=t;this.n42=u;this.n43=v;this.n44=C;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(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,d){var e=THREE.Matrix4.__v1,
|
|
|
|
|
f=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,c).normalize();if(h.length()===0)h.z=1;e.cross(d,h).normalize();e.length()===0&&(h.x+=1.0E-4,e.cross(d,h).normalize());f.cross(h,e).normalize();this.n11=e.x;this.n12=f.x;this.n13=h.x;this.n21=e.y;this.n22=f.y;this.n23=h.y;this.n31=e.z;this.n32=f.z;this.n33=h.z;return this},multiplyVector3:function(b){var c=b.x,d=b.y,e=b.z,f=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*f;b.y=(this.n21*c+this.n22*d+this.n23*
|
|
|
|
|
e+this.n24)*f;b.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*f;return b},multiplyVector4:function(b){var c=b.x,d=b.y,e=b.z,f=b.w;b.x=this.n11*c+this.n12*d+this.n13*e+this.n14*f;b.y=this.n21*c+this.n22*d+this.n23*e+this.n24*f;b.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;b.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;return b},rotateAxis:function(b){var c=b.x,d=b.y,e=b.z;b.x=c*this.n11+d*this.n12+e*this.n13;b.y=c*this.n21+d*this.n22+e*this.n23;b.z=c*this.n31+d*this.n32+e*this.n33;b.normalize();
|
|
|
|
|
return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,e=b.n12,f=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,n=b.n31,p=b.n32,t=b.n33,u=b.n34,v=b.n41,C=b.n42,E=b.n43,y=b.n44,D=c.n11,x=c.n12,I=c.n13,A=c.n14,z=c.n21,S=c.n22,
|
|
|
|
|
G=c.n23,M=c.n24,F=c.n31,N=c.n32,g=c.n33,Y=c.n34;this.n11=d*D+e*z+f*F;this.n12=d*x+e*S+f*N;this.n13=d*I+e*G+f*g;this.n14=d*A+e*M+f*Y+h;this.n21=j*D+k*z+m*F;this.n22=j*x+k*S+m*N;this.n23=j*I+k*G+m*g;this.n24=j*A+k*M+m*Y+o;this.n31=n*D+p*z+t*F;this.n32=n*x+p*S+t*N;this.n33=n*I+p*G+t*g;this.n34=n*A+p*M+t*Y+u;this.n41=v*D+C*z+E*F;this.n42=v*x+C*S+E*N;this.n43=v*I+C*G+E*g;this.n44=v*A+C*M+E*Y+y;return this},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=
|
|
|
|
|
this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=
|
|
|
|
|
this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,o=this.n32,n=this.n33,p=this.n34,t=this.n41,u=this.n42,v=this.n43,C=this.n44;return e*j*o*t-d*k*o*t-e*h*n*t+c*k*n*t+d*h*p*t-c*j*p*t-e*j*m*u+d*k*m*u+e*f*n*u-b*k*n*u-d*f*p*u+b*j*p*u+e*h*m*v-c*k*m*v-e*f*o*v+b*k*o*v+c*f*p*v-b*h*p*v-d*h*m*C+c*j*m*C+d*f*o*C-b*j*o*C-c*f*n*C+b*h*n*C},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=
|
|
|
|
|
THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c<e;c++)f=f.concat(this.intersectObject(b[c]));f.sort(function(b,e){return b.distance-e.distance});return f},intersectObject:function(b){function c(b,e,c){var f;f=c.position.clone().subSelf(b).dot(e);if(f<0)return!1;b=b.clone().addSelf(e.clone().multiplyScalar(f));return c.position.distanceTo(b)}function e(b,e,c,f){var f=f.clone().subSelf(e),c=c.clone().subSelf(e),
|
|
|
|
|
g=b.clone().subSelf(e),b=f.dot(f),e=f.dot(c),f=f.dot(g),j=c.dot(c),c=c.dot(g),g=1/(b*j-e*e),j=(j*f-e*c)*g,b=(b*c-e*f)*g;return j>0&&b>0&&j+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,j,k,m,n,p,o,t,u,v,w=b.geometry,
|
|
|
|
|
E=w.vertices,H=[],f=0;for(g=w.faces.length;f<g;f++)if(j=w.faces[f],u=this.origin.clone(),v=this.direction.clone(),p=b.matrixWorld,k=p.multiplyVector3(E[j.a].position.clone()),m=p.multiplyVector3(E[j.b].position.clone()),n=p.multiplyVector3(E[j.c].position.clone()),p=j instanceof THREE.Face4?p.multiplyVector3(E[j.d].position.clone()):null,o=b.matrixRotationWorld.multiplyVector3(j.normal.clone()),t=v.dot(o),b.doubleSided||(b.flipSided?t>0:t<0))if(o=o.dot((new THREE.Vector3).sub(k,u))/t,u=u.addSelf(v.multiplyScalar(o)),
|
|
|
|
|
j instanceof THREE.Face3)e(u,k,m,n)&&(j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},H.push(j));else if(j instanceof THREE.Face4&&(e(u,k,m,p)||e(u,m,n,p)))j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},H.push(j);return H}else return[]}};
|
|
|
|
|
THREE.Rectangle=function(){function b(){j=f-c;k=g-e}var c,e,f,g,j,k,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(j,k,o,t){m=!1;c=j;e=k;f=o;g=t;b()};this.addPoint=function(j,k){m?(m=!1,c=j,e=k,f=j,g=k):(c=c<j?c:j,e=e<k?e:k,f=f>j?f:j,g=g>k?g:k);b()};this.add3Points=
|
|
|
|
|
function(j,k,o,t,u,v){m?(m=!1,c=j<o?j<u?j:u:o<u?o:u,e=k<t?k<v?k:v:t<v?t:v,f=j>o?j>u?j:u:o>u?o:u,g=k>t?k>v?k:v:t>v?t:v):(c=j<o?j<u?j<c?j:c:u<c?u:c:o<u?o<c?o:c:u<c?u:c,e=k<t?k<v?k<e?k:e:v<e?v:e:t<v?t<e?t:e:v<e?v:e,f=j>o?j>u?j>f?j:f:u>f?u:f:o>u?o>f?o:f:u>f?u:f,g=k>t?k>v?k>g?k:g:v>g?v:g:t>v?t>g?t:g:v>g?v:g);b()};this.addRectangle=function(j){m?(m=!1,c=j.getLeft(),e=j.getTop(),f=j.getRight(),g=j.getBottom()):(c=c<j.getLeft()?c:j.getLeft(),e=e<j.getTop()?e:j.getTop(),f=f>j.getRight()?f:j.getRight(),g=g>
|
|
|
|
|
j.getBottom()?g:j.getBottom());b()};this.inflate=function(j){c-=j;e-=j;f+=j;g+=j;b()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();e=e>j.getTop()?e:j.getTop();f=f<j.getRight()?f:j.getRight();g=g<j.getBottom()?g:j.getBottom();b()};this.instersects=function(b){return Math.min(f,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(g,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){m=!0;g=f=e=c=0;b()};this.isEmpty=function(){return m}};THREE.Matrix3=function(){this.m=[]};
|
|
|
|
|
THREE.Matrix3.prototype={transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,e,f,g,j,k,m,n,p,o,t,u,v,w,E){this.set(b||1,c||0,e||0,f||0,g||0,j||1,k||0,m||0,n||0,p||0,o||1,t||0,u||0,v||0,w||0,E||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
|
|
|
|
|
THREE.Matrix4.prototype={set:function(b,c,e,f,g,j,k,m,n,p,o,t,u,v,w,E){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=k;this.n24=m;this.n31=n;this.n32=p;this.n33=o;this.n34=t;this.n41=u;this.n42=v;this.n43=w;this.n44=E;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(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,e){var f=THREE.Matrix4.__v1,
|
|
|
|
|
g=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,c).normalize();if(j.length()===0)j.z=1;f.cross(e,j).normalize();f.length()===0&&(j.x+=1.0E-4,f.cross(e,j).normalize());g.cross(j,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=j.x;this.n21=f.y;this.n22=g.y;this.n23=j.y;this.n31=f.z;this.n32=g.z;this.n33=j.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,g=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*g;b.y=(this.n21*c+this.n22*e+this.n23*
|
|
|
|
|
f+this.n24)*g;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,g=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*g;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*g;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*g;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+e*this.n32+f*this.n33;b.normalize();
|
|
|
|
|
return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,k=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,u=b.n33,v=b.n34,w=b.n41,E=b.n42,H=b.n43,B=b.n44,K=c.n11,A=c.n12,I=c.n13,G=c.n14,C=c.n21,R=c.n22,
|
|
|
|
|
D=c.n23,N=c.n24,J=c.n31,V=c.n32,h=c.n33,X=c.n34;this.n11=e*K+f*C+g*J;this.n12=e*A+f*R+g*V;this.n13=e*I+f*D+g*h;this.n14=e*G+f*N+g*X+j;this.n21=k*K+m*C+n*J;this.n22=k*A+m*R+n*V;this.n23=k*I+m*D+n*h;this.n24=k*G+m*N+n*X+p;this.n31=o*K+t*C+u*J;this.n32=o*A+t*R+u*V;this.n33=o*I+t*D+u*h;this.n34=o*G+t*N+u*X+v;this.n41=w*K+E*C+H*J;this.n42=w*A+E*R+H*V;this.n43=w*I+E*D+H*h;this.n44=w*G+E*N+H*X+B;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=
|
|
|
|
|
this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=
|
|
|
|
|
this.n11,c=this.n12,e=this.n13,f=this.n14,g=this.n21,j=this.n22,k=this.n23,m=this.n24,n=this.n31,p=this.n32,o=this.n33,t=this.n34,u=this.n41,v=this.n42,w=this.n43,E=this.n44;return f*k*p*u-e*m*p*u-f*j*o*u+c*m*o*u+e*j*t*u-c*k*t*u-f*k*n*v+e*m*n*v+f*g*o*v-b*m*o*v-e*g*t*v+b*k*t*v+f*j*n*w-c*m*n*w-f*g*p*w+b*m*p*w+c*g*t*w-b*j*t*w-e*j*n*E+c*k*n*E+e*g*p*E-b*k*p*E-c*g*o*E+b*j*o*E},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=
|
|
|
|
|
this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},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(b){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 b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b,
|
|
|
|
|
c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,h=b.x,j=b.y,k=b.z,m=f*h,o=f*j;this.set(m*
|
|
|
|
|
h+d,m*j-e*k,m*k+e*j,0,m*j+e*k,o*j+d,o*k-e*h,0,m*k-e*j,o*k+e*h,f*k*k+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;
|
|
|
|
|
this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b){var c=b.x,d=b.y,e=b.z,b=Math.cos(c),c=Math.sin(c),f=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e),j=b*d,k=c*d;this.n11=f*h;this.n12=-f*e;this.n13=d;this.n21=k*h+b*e;this.n22=-k*e+b*h;this.n23=-c*f;this.n31=-j*h+c*e;this.n32=j*e+c*h;this.n33=b*f;return this},
|
|
|
|
|
setRotationFromQuaternion:function(b){var c=b.x,d=b.y,e=b.z,f=b.w,h=c+c,j=d+d,k=e+e,b=c*h,m=c*j;c*=k;var o=d*j;d*=k;e*=k;h*=f;j*=f;f*=k;this.n11=1-(o+e);this.n12=m-f;this.n13=c+j;this.n21=m+f;this.n22=1-(b+e);this.n23=d-h;this.n31=c-j;this.n32=d+h;this.n33=1-(b+o);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*=b;return this},extractPosition:function(b){this.n14=
|
|
|
|
|
b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var d=1/c.x,e=1/c.y,f=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*e;this.n22=b.n22*e;this.n32=b.n32*e;this.n13=b.n13*f;this.n23=b.n23*f;this.n33=b.n33*f}};
|
|
|
|
|
THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,e=b.n12,f=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,n=b.n31,p=b.n32,t=b.n33,u=b.n34,v=b.n41,C=b.n42,E=b.n43,y=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=m*u*C-o*t*C+o*p*E-k*u*E-m*p*y+k*t*y;c.n12=h*t*C-f*u*C-h*p*E+e*u*E+f*p*y-e*t*y;c.n13=f*o*C-h*m*C+h*k*E-e*o*E-f*k*y+e*m*y;c.n14=h*m*p-f*o*p-h*k*t+e*o*t+f*k*u-e*m*u;c.n21=o*t*v-m*u*v-o*n*E+j*u*E+m*n*y-j*t*y;c.n22=f*u*v-h*t*v+h*n*E-d*u*E-f*n*y+d*t*y;c.n23=h*m*v-f*o*v-h*j*E+d*o*E+f*j*y-d*m*y;c.n24=
|
|
|
|
|
f*o*n-h*m*n+h*j*t-d*o*t-f*j*u+d*m*u;c.n31=k*u*v-o*p*v+o*n*C-j*u*C-k*n*y+j*p*y;c.n32=h*p*v-e*u*v-h*n*C+d*u*C+e*n*y-d*p*y;c.n33=f*o*v-h*k*v+h*j*C-d*o*C-e*j*y+d*k*y;c.n34=h*k*n-e*o*n-h*j*p+d*o*p+e*j*u-d*k*u;c.n41=m*p*v-k*t*v-m*n*C+j*t*C+k*n*E-j*p*E;c.n42=e*t*v-f*p*v+f*n*C-d*t*C-e*n*E+d*p*E;c.n43=f*k*v-e*m*v-f*j*C+d*m*C+e*j*E-d*k*E;c.n44=e*m*n-f*k*n+f*j*p-d*m*p-e*j*t+d*k*t;c.multiplyScalar(1/b.determinant());return c};
|
|
|
|
|
THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,e=b.n33*b.n22-b.n32*b.n23,f=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,o=b.n23*b.n12-b.n22*b.n13,n=-b.n23*b.n11+b.n21*b.n13,p=b.n22*b.n11-b.n21*b.n12,b=b.n11*e+b.n21*j+b.n31*o;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*e;d[1]=b*f;d[2]=b*h;d[3]=b*j;d[4]=b*k;d[5]=b*m;d[6]=b*o;d[7]=b*n;d[8]=b*p;return c};
|
|
|
|
|
THREE.Matrix4.makeFrustum=function(b,c,d,e,f,h){var j;j=new THREE.Matrix4;j.n11=2*f/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*f/(e-d);j.n23=(e+d)/(e-d);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+f)/(h-f);j.n34=-2*h*f/(h-f);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,c,d,e){var f,b=d*Math.tan(b*Math.PI/360);f=-b;return THREE.Matrix4.makeFrustum(f*c,b*c,f,b,d,e)};
|
|
|
|
|
THREE.Matrix4.makeOrtho=function(b,c,d,e,f,h){var j,k,m,o;j=new THREE.Matrix4;k=c-b;m=d-e;o=h-f;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((c+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((d+e)/m);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((h+f)/o);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
|
|
|
|
|
this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,e){this.set(1,0,0,b,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(b,
|
|
|
|
|
c,e){this.set(b,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var e=Math.cos(c),f=Math.sin(c),g=1-e,j=b.x,k=b.y,m=b.z,n=g*j,p=g*k;this.set(n*
|
|
|
|
|
j+e,n*k-f*m,n*m+f*k,0,n*k+f*m,p*k+e,p*m-f*j,0,n*m-f*k,p*m+f*j,g*m*m+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;
|
|
|
|
|
this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b){var c=b.x,e=b.y,f=b.z,b=Math.cos(c),c=Math.sin(c),g=Math.cos(e),e=Math.sin(e),j=Math.cos(f),f=Math.sin(f),k=b*e,m=c*e;this.n11=g*j;this.n12=-g*f;this.n13=e;this.n21=m*j+b*f;this.n22=-m*f+b*j;this.n23=-c*g;this.n31=-k*j+c*f;this.n32=k*f+c*j;this.n33=b*g;return this},
|
|
|
|
|
setRotationFromQuaternion:function(b){var c=b.x,e=b.y,f=b.z,g=b.w,j=c+c,k=e+e,m=f+f,b=c*j,n=c*k;c*=m;var p=e*k;e*=m;f*=m;j*=g;k*=g;g*=m;this.n11=1-(p+f);this.n12=n-g;this.n13=c+k;this.n21=n+g;this.n22=1-(b+f);this.n23=e-j;this.n31=c-k;this.n32=e+j;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=
|
|
|
|
|
b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var e=1/c.x,f=1/c.y,g=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}};
|
|
|
|
|
THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,k=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,u=b.n33,v=b.n34,w=b.n41,E=b.n42,H=b.n43,B=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*v*E-p*u*E+p*t*H-m*v*H-n*t*B+m*u*B;c.n12=j*u*E-g*v*E-j*t*H+f*v*H+g*t*B-f*u*B;c.n13=g*p*E-j*n*E+j*m*H-f*p*H-g*m*B+f*n*B;c.n14=j*n*t-g*p*t-j*m*u+f*p*u+g*m*v-f*n*v;c.n21=p*u*w-n*v*w-p*o*H+k*v*H+n*o*B-k*u*B;c.n22=g*v*w-j*u*w+j*o*H-e*v*H-g*o*B+e*u*B;c.n23=j*n*w-g*p*w-j*k*H+e*p*H+g*k*B-e*n*B;c.n24=
|
|
|
|
|
g*p*o-j*n*o+j*k*u-e*p*u-g*k*v+e*n*v;c.n31=m*v*w-p*t*w+p*o*E-k*v*E-m*o*B+k*t*B;c.n32=j*t*w-f*v*w-j*o*E+e*v*E+f*o*B-e*t*B;c.n33=g*p*w-j*m*w+j*k*E-e*p*E-f*k*B+e*m*B;c.n34=j*m*o-f*p*o-j*k*t+e*p*t+f*k*v-e*m*v;c.n41=n*t*w-m*u*w-n*o*E+k*u*E+m*o*H-k*t*H;c.n42=f*u*w-g*t*w+g*o*E-e*u*E-f*o*H+e*t*H;c.n43=g*m*w-f*n*w-g*k*E+e*n*E+f*k*H-e*m*H;c.n44=f*n*o-g*m*o+g*k*t-e*n*t-f*k*u+e*m*u;c.multiplyScalar(1/b.determinant());return c};
|
|
|
|
|
THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*k+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*j;e[3]=b*k;e[4]=b*m;e[5]=b*n;e[6]=b*p;e[7]=b*o;e[8]=b*t;return c};
|
|
|
|
|
THREE.Matrix4.makeFrustum=function(b,c,e,f,g,j){var k;k=new THREE.Matrix4;k.n11=2*g/(c-b);k.n12=0;k.n13=(c+b)/(c-b);k.n14=0;k.n21=0;k.n22=2*g/(f-e);k.n23=(f+e)/(f-e);k.n24=0;k.n31=0;k.n32=0;k.n33=-(j+g)/(j-g);k.n34=-2*j*g/(j-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,c,e,f){var g,b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*c,b*c,g,b,e,f)};
|
|
|
|
|
THREE.Matrix4.makeOrtho=function(b,c,e,f,g,j){var k,m,n,p;k=new THREE.Matrix4;m=c-b;n=e-f;p=j-g;k.n11=2/m;k.n12=0;k.n13=0;k.n14=-((c+b)/m);k.n21=0;k.n22=2/n;k.n23=0;k.n24=-((e+f)/n);k.n31=0;k.n32=0;k.n33=-2/p;k.n34=-((j+g)/p);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
|
|
|
|
|
THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=
|
|
|
|
|
0;this.boundRadiusScale=1;this.visible=!0;this._vector=new THREE.Vector3;this.name=""};
|
|
|
|
|
THREE.Object3D.prototype={translate:function(b,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===
|
|
|
|
|
-1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},removeChild:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var d,e,f;d=0;for(e=this.children.length;d<e;d++){f=this.children[d];if(f.name===b)return f;if(c&&(f=f.getChildByName(b,c),f!==void 0))return f}},updateMatrix:function(){this.matrix.setPosition(this.position);
|
|
|
|
|
this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(b,c,d){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,
|
|
|
|
|
this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,e=this.children.length;b<e;b++)this.children[b].update(this.matrixWorld,c,d)}};THREE.Quaternion=function(b,c,d,e){this.set(b||0,c||0,d||0,e!==void 0?e:1)};
|
|
|
|
|
THREE.Quaternion.prototype={set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,d=b.x*c,e=b.y*c,f=b.z*c,b=Math.cos(e),e=Math.sin(e),c=Math.cos(-f),f=Math.sin(-f),h=Math.cos(d),d=Math.sin(d),j=b*c,k=e*f;this.w=j*h-k*d;this.x=j*d+k*h;this.y=e*c*h+b*f*d;this.z=b*f*h-e*c*d;return this},setFromAxisAngle:function(b,c){var d=c/2,e=Math.sin(d);this.x=b.x*e;this.y=b.y*
|
|
|
|
|
e;this.z=b.z*e;this.w=Math.cos(d);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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},
|
|
|
|
|
multiplySelf:function(b){var c=this.x,d=this.y,e=this.z,f=this.w,h=b.x,j=b.y,k=b.z,b=b.w;this.x=c*b+f*h+d*k-e*j;this.y=d*b+f*j+e*h-c*k;this.z=e*b+f*k+c*j-d*h;this.w=f*b-c*h-d*j-e*k;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var d=b.x,e=b.y,f=b.z,h=this.x,j=this.y,k=this.z,m=this.w,o=m*d+j*f-k*e,n=
|
|
|
|
|
m*e+k*d-h*f,p=m*f+h*e-j*d,d=-h*d-j*e-k*f;c.x=o*m+d*-h+n*-k-p*-j;c.y=n*m+d*-j+p*-h-o*-k;c.z=p*m+d*-k+o*-j-n*-h;return c}};
|
|
|
|
|
THREE.Quaternion.slerp=function(b,c,d,e){var f=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(f)>=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var h=Math.acos(f),j=Math.sqrt(1-f*f);if(Math.abs(j)<0.0010)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;f=Math.sin((1-e)*h)/j;e=Math.sin(e*h)/j;d.w=b.w*f+c.w*e;d.x=b.x*f+c.x*e;d.y=b.y*f+c.y*e;d.z=b.z*f+c.z*e;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
|
|
|
|
|
THREE.Face3=function(b,c,d,e,f,h){this.a=b;this.b=c;this.c=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
|
|
|
|
|
THREE.Face4=function(b,c,d,e,f,h,j){this.a=b;this.b=c;this.c=d;this.d=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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(b,c){this.set(b||0,c||0)};
|
|
|
|
|
-1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},removeChild:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var e,f,g;e=0;for(f=this.children.length;e<f;e++){g=this.children[e];if(g.name===b)return g;if(c&&(g=g.getChildByName(b,c),g!==void 0))return g}},updateMatrix:function(){this.matrix.setPosition(this.position);
|
|
|
|
|
this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(b,c,e){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,
|
|
|
|
|
this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,c,e)}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)};
|
|
|
|
|
THREE.Quaternion.prototype={set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,e=b.x*c,f=b.y*c,g=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-g),g=Math.sin(-g),j=Math.cos(e),e=Math.sin(e),k=b*c,m=f*g;this.w=k*j-m*e;this.x=k*e+m*j;this.y=f*c*j+b*g*e;this.z=b*g*j-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e);this.x=b.x*f;this.y=b.y*
|
|
|
|
|
f;this.z=b.z*f;this.w=Math.cos(e);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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},
|
|
|
|
|
multiplySelf:function(b){var c=this.x,e=this.y,f=this.z,g=this.w,j=b.x,k=b.y,m=b.z,b=b.w;this.x=c*b+g*j+e*m-f*k;this.y=e*b+g*k+f*j-c*m;this.z=f*b+g*m+c*k-e*j;this.w=g*b-c*j-e*k-f*m;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var e=b.x,f=b.y,g=b.z,j=this.x,k=this.y,m=this.z,n=this.w,p=n*e+k*g-m*f,o=
|
|
|
|
|
n*f+m*e-j*g,t=n*g+j*f-k*e,e=-j*e-k*f-m*g;c.x=p*n+e*-j+o*-m-t*-k;c.y=o*n+e*-k+t*-j-p*-m;c.z=t*n+e*-m+p*-k-o*-j;return c}};
|
|
|
|
|
THREE.Quaternion.slerp=function(b,c,e,f){var g=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(g)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var j=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;g=Math.sin((1-f)*j)/k;f=Math.sin(f*j)/k;e.w=b.w*g+c.w*f;e.x=b.x*g+c.x*f;e.y=b.y*g+c.y*f;e.z=b.z*g+c.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
|
|
|
|
|
THREE.Face3=function(b,c,e,f,g,j){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};
|
|
|
|
|
THREE.Face4=function(b,c,e,f,g,j,k){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)};
|
|
|
|
|
THREE.UV.prototype={set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
|
|
|
|
|
THREE.Geometry.prototype={computeCentroids:function(){var b,c,d;b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d.centroid.set(0,0,0),d instanceof THREE.Face3?(d.centroid.addSelf(this.vertices[d.a].position),d.centroid.addSelf(this.vertices[d.b].position),d.centroid.addSelf(this.vertices[d.c].position),d.centroid.divideScalar(3)):d instanceof THREE.Face4&&(d.centroid.addSelf(this.vertices[d.a].position),d.centroid.addSelf(this.vertices[d.b].position),d.centroid.addSelf(this.vertices[d.c].position),
|
|
|
|
|
d.centroid.addSelf(this.vertices[d.d].position),d.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,d,e,f,h,j,k=new THREE.Vector3,m=new THREE.Vector3;e=0;for(f=this.faces.length;e<f;e++){h=this.faces[e];if(b&&h.vertexNormals.length){k.set(0,0,0);c=0;for(d=h.vertexNormals.length;c<d;c++)k.addSelf(h.vertexNormals[c]);k.divideScalar(3)}else c=this.vertices[h.a],d=this.vertices[h.b],j=this.vertices[h.c],k.sub(j.position,d.position),m.sub(c.position,d.position),k.crossSelf(m);k.isZero()||
|
|
|
|
|
k.normalize();h.normal.copy(k)}},computeVertexNormals:function(){var b,c,d,e;if(this.__tmpVertices==void 0){e=this.__tmpVertices=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)e[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(d=this.faces[b],d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{e=
|
|
|
|
|
this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)e[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof THREE.Face3?(e[d.a].addSelf(d.normal),e[d.b].addSelf(d.normal),e[d.c].addSelf(d.normal)):d instanceof THREE.Face4&&(e[d.a].addSelf(d.normal),e[d.b].addSelf(d.normal),e[d.c].addSelf(d.normal),e[d.d].addSelf(d.normal));b=0;for(c=this.vertices.length;b<c;b++)e[b].normalize();b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof THREE.Face3?(d.vertexNormals[0].copy(e[d.a]),
|
|
|
|
|
d.vertexNormals[1].copy(e[d.b]),d.vertexNormals[2].copy(e[d.c])):d instanceof THREE.Face4&&(d.vertexNormals[0].copy(e[d.a]),d.vertexNormals[1].copy(e[d.b]),d.vertexNormals[2].copy(e[d.c]),d.vertexNormals[3].copy(e[d.d]))},computeTangents:function(){function b(b,d,c,e,h,f,G){k=b.vertices[d].position;m=b.vertices[c].position;o=b.vertices[e].position;n=j[h];p=j[f];t=j[G];u=m.x-k.x;v=o.x-k.x;C=m.y-k.y;E=o.y-k.y;y=m.z-k.z;D=o.z-k.z;x=p.u-n.u;I=t.u-n.u;A=p.v-n.v;z=t.v-n.v;S=1/(x*z-I*A);N.set((z*u-A*v)*
|
|
|
|
|
S,(z*C-A*E)*S,(z*y-A*D)*S);g.set((x*v-I*u)*S,(x*E-I*C)*S,(x*D-I*y)*S);M[d].addSelf(N);M[c].addSelf(N);M[e].addSelf(N);F[d].addSelf(g);F[c].addSelf(g);F[e].addSelf(g)}var c,d,e,f,h,j,k,m,o,n,p,t,u,v,C,E,y,D,x,I,A,z,S,G,M=[],F=[],N=new THREE.Vector3,g=new THREE.Vector3,Y=new THREE.Vector3,O=new THREE.Vector3,V=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++)M[c]=new THREE.Vector3,F[c]=new THREE.Vector3;c=0;for(d=this.faces.length;c<d;c++)h=this.faces[c],j=this.faceVertexUvs[0][c],h instanceof
|
|
|
|
|
THREE.Face3?b(this,h.a,h.b,h.c,0,1,2):h instanceof THREE.Face4&&(b(this,h.a,h.b,h.c,0,1,2),b(this,h.a,h.b,h.d,0,1,3));var L=["a","b","c","d"];c=0;for(d=this.faces.length;c<d;c++){h=this.faces[c];for(e=0;e<h.vertexNormals.length;e++)V.copy(h.vertexNormals[e]),f=h[L[e]],G=M[f],Y.copy(G),Y.subSelf(V.multiplyScalar(V.dot(G))).normalize(),O.cross(h.vertexNormals[e],G),f=O.dot(F[f]),f=f<0?-1:1,h.vertexTangents[e]=new THREE.Vector4(Y.x,Y.y,Y.z,f)}this.hasTangents=!0},computeBoundingBox:function(){var b;
|
|
|
|
|
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,d=this.vertices.length;c<d;c++){b=this.vertices[c];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;
|
|
|
|
|
else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,d=this.vertices.length;c<d;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,d){return Math.min(b,d)+"_"+Math.max(b,d)}function c(b,d,c){b[d]===
|
|
|
|
|
void 0?(b[d]={set:{},array:[]},b[d].set[c]=1,b[d].array.push(c)):b[d].set[c]===void 0&&(b[d].set[c]=1,b[d].array.push(c))}var d,e,f,h,j,k={};d=0;for(e=this.faces.length;d<e;d++)j=this.faces[d],j instanceof THREE.Face3?(f=b(j.a,j.b),c(k,f,d),f=b(j.b,j.c),c(k,f,d),f=b(j.a,j.c),c(k,f,d)):j instanceof THREE.Face4&&(f=b(j.b,j.d),c(k,f,d),f=b(j.a,j.b),c(k,f,d),f=b(j.a,j.d),c(k,f,d),f=b(j.b,j.c),c(k,f,d),f=b(j.c,j.d),c(k,f,d));d=0;for(e=this.edges.length;d<e;d++){j=this.edges[d];f=j.vertexIndices[0];h=j.vertexIndices[1];
|
|
|
|
|
j.faceIndices=k[b(f,h)].array;for(f=0;f<j.faceIndices.length;f++)h=j.faceIndices[f],j.faces.push(this.faces[h])}}};THREE.GeometryIdCounter=0;
|
|
|
|
|
THREE.Spline=function(b){function c(b,d,c,e,h,f,j){b=(c-b)*0.5;e=(e-d)*0.5;return(2*(d-c)+b+e)*j+(-3*(d-c)-2*b-e)*f+b*h+d}this.points=b;var d=[],e={x:0,y:0,z:0},f,h,j,k,m,o,n,p,t;this.initFromArray=function(b){this.points=[];for(var d=0;d<b.length;d++)this.points[d]={x:b[d][0],y:b[d][1],z:b[d][2]}};this.getPoint=function(b){f=(this.points.length-1)*b;h=Math.floor(f);j=f-h;d[0]=h==0?h:h-1;d[1]=h;d[2]=h>this.points.length-2?h:h+1;d[3]=h>this.points.length-3?h:h+2;o=this.points[d[0]];n=this.points[d[1]];
|
|
|
|
|
p=this.points[d[2]];t=this.points[d[3]];k=j*j;m=j*k;e.x=c(o.x,n.x,p.x,t.x,j,k,m);e.y=c(o.y,n.y,p.y,t.y,j,k,m);e.z=c(o.z,n.z,p.z,t.z,j,k,m);return e};this.getControlPointsArray=function(){var b,d,c=this.points.length,e=[];for(b=0;b<c;b++)d=this.points[b],e[b]=[d.x,d.y,d.z];return e};this.getLength=function(b){var d,c,e=d=d=0,h=new THREE.Vector3,f=new THREE.Vector3,j=[],k=0;j[0]=0;b||(b=100);c=this.points.length*b;h.copy(this.points[0]);for(b=1;b<c;b++)d=b/c,position=this.getPoint(d),f.copy(position),
|
|
|
|
|
k+=f.distanceTo(h),h.copy(position),d*=this.points.length-1,d=Math.floor(d),d!=e&&(j[d]=k,e=d);j[j.length]=k;return{chunks:j,total:k}};this.reparametrizeByArcLength=function(b){var d,c,e,h,f,j,k=[],m=new THREE.Vector3,o=this.getLength();k.push(m.copy(this.points[0]).clone());for(d=1;d<this.points.length;d++){c=o.chunks[d]-o.chunks[d-1];j=Math.ceil(b*c/o.total);h=(d-1)/(this.points.length-1);f=d/(this.points.length-1);for(c=1;c<j-1;c++)e=h+c*(1/j)*(f-h),position=this.getPoint(e),k.push(m.copy(position).clone());
|
|
|
|
|
k.push(m.copy(this.points[d]).clone())}this.points=k}};THREE.Edge=function(b,c,d,e){this.vertices=[b,c];this.vertexIndices=[d,e];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,c,d,e,f){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=d||0.1;this.far=e||2E3;this.target=f||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
|
|
|
|
|
THREE.Geometry.prototype={computeCentroids:function(){var b,c,e;b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),e.centroid.divideScalar(3)):e instanceof THREE.Face4&&(e.centroid.addSelf(this.vertices[e.a].position),e.centroid.addSelf(this.vertices[e.b].position),e.centroid.addSelf(this.vertices[e.c].position),
|
|
|
|
|
e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,e,f,g,j,k,m=new THREE.Vector3,n=new THREE.Vector3;f=0;for(g=this.faces.length;f<g;f++){j=this.faces[f];if(b&&j.vertexNormals.length){m.set(0,0,0);c=0;for(e=j.vertexNormals.length;c<e;c++)m.addSelf(j.vertexNormals[c]);m.divideScalar(3)}else c=this.vertices[j.a],e=this.vertices[j.b],k=this.vertices[j.c],m.sub(k.position,e.position),n.sub(c.position,e.position),m.crossSelf(n);m.isZero()||
|
|
|
|
|
m.normalize();j.normal.copy(m)}},computeVertexNormals:function(){var b,c,e,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)f[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(e=this.faces[b],e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{f=
|
|
|
|
|
this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)f[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof THREE.Face3?(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal)):e instanceof THREE.Face4&&(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal),f[e.d].addSelf(e.normal));b=0;for(c=this.vertices.length;b<c;b++)f[b].normalize();b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof THREE.Face3?(e.vertexNormals[0].copy(f[e.a]),
|
|
|
|
|
e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c])):e instanceof THREE.Face4&&(e.vertexNormals[0].copy(f[e.a]),e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,e,c,f,j,g,D){m=b.vertices[e].position;n=b.vertices[c].position;p=b.vertices[f].position;o=k[j];t=k[g];u=k[D];v=n.x-m.x;w=p.x-m.x;E=n.y-m.y;H=p.y-m.y;B=n.z-m.z;K=p.z-m.z;A=t.u-o.u;I=u.u-o.u;G=t.v-o.v;C=u.v-o.v;R=1/(A*C-I*G);V.set((C*v-G*w)*
|
|
|
|
|
R,(C*E-G*H)*R,(C*B-G*K)*R);h.set((A*w-I*v)*R,(A*H-I*E)*R,(A*K-I*B)*R);N[e].addSelf(V);N[c].addSelf(V);N[f].addSelf(V);J[e].addSelf(h);J[c].addSelf(h);J[f].addSelf(h)}var c,e,f,g,j,k,m,n,p,o,t,u,v,w,E,H,B,K,A,I,G,C,R,D,N=[],J=[],V=new THREE.Vector3,h=new THREE.Vector3,X=new THREE.Vector3,O=new THREE.Vector3,aa=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)N[c]=new THREE.Vector3,J[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)j=this.faces[c],k=this.faceVertexUvs[0][c],j instanceof
|
|
|
|
|
THREE.Face3?b(this,j.a,j.b,j.c,0,1,2):j instanceof THREE.Face4&&(b(this,j.a,j.b,j.c,0,1,2),b(this,j.a,j.b,j.d,0,1,3));var M=["a","b","c","d"];c=0;for(e=this.faces.length;c<e;c++){j=this.faces[c];for(f=0;f<j.vertexNormals.length;f++)aa.copy(j.vertexNormals[f]),g=j[M[f]],D=N[g],X.copy(D),X.subSelf(aa.multiplyScalar(aa.dot(D))).normalize(),O.cross(j.vertexNormals[f],D),g=O.dot(J[g]),g=g<0?-1:1,j.vertexTangents[f]=new THREE.Vector4(X.x,X.y,X.z,g)}this.hasTangents=!0},computeBoundingBox:function(){var b;
|
|
|
|
|
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,e=this.vertices.length;c<e;c++){b=this.vertices[c];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;
|
|
|
|
|
else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;c<e;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,e){return Math.min(b,e)+"_"+Math.max(b,e)}function c(b,e,c){b[e]===
|
|
|
|
|
void 0?(b[e]={set:{},array:[]},b[e].set[c]=1,b[e].array.push(c)):b[e].set[c]===void 0&&(b[e].set[c]=1,b[e].array.push(c))}var e,f,g,j,k,m={};e=0;for(f=this.faces.length;e<f;e++)k=this.faces[e],k instanceof THREE.Face3?(g=b(k.a,k.b),c(m,g,e),g=b(k.b,k.c),c(m,g,e),g=b(k.a,k.c),c(m,g,e)):k instanceof THREE.Face4&&(g=b(k.b,k.d),c(m,g,e),g=b(k.a,k.b),c(m,g,e),g=b(k.a,k.d),c(m,g,e),g=b(k.b,k.c),c(m,g,e),g=b(k.c,k.d),c(m,g,e));e=0;for(f=this.edges.length;e<f;e++){k=this.edges[e];g=k.vertexIndices[0];j=k.vertexIndices[1];
|
|
|
|
|
k.faceIndices=m[b(g,j)].array;for(g=0;g<k.faceIndices.length;g++)j=k.faceIndices[g],k.faces.push(this.faces[j])}}};THREE.GeometryIdCounter=0;
|
|
|
|
|
THREE.Spline=function(b){function c(b,e,c,f,j,g,k){b=(c-b)*0.5;f=(f-e)*0.5;return(2*(e-c)+b+f)*k+(-3*(e-c)-2*b-f)*g+b*j+e}this.points=b;var e=[],f={x:0,y:0,z:0},g,j,k,m,n,p,o,t,u;this.initFromArray=function(b){this.points=[];for(var e=0;e<b.length;e++)this.points[e]={x:b[e][0],y:b[e][1],z:b[e][2]}};this.getPoint=function(b){g=(this.points.length-1)*b;j=Math.floor(g);k=g-j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>this.points.length-2?j:j+1;e[3]=j>this.points.length-3?j:j+2;p=this.points[e[0]];o=this.points[e[1]];
|
|
|
|
|
t=this.points[e[2]];u=this.points[e[3]];m=k*k;n=k*m;f.x=c(p.x,o.x,t.x,u.x,k,m,n);f.y=c(p.y,o.y,t.y,u.y,k,m,n);f.z=c(p.z,o.z,t.z,u.z,k,m,n);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;b<c;b++)e=this.points[b],f[b]=[e.x,e.y,e.z];return f};this.getLength=function(b){var e,c,f=e=e=0,j=new THREE.Vector3,g=new THREE.Vector3,k=[],m=0;k[0]=0;b||(b=100);c=this.points.length*b;j.copy(this.points[0]);for(b=1;b<c;b++)e=b/c,position=this.getPoint(e),g.copy(position),
|
|
|
|
|
m+=g.distanceTo(j),j.copy(position),e*=this.points.length-1,e=Math.floor(e),e!=f&&(k[e]=m,f=e);k[k.length]=m;return{chunks:k,total:m}};this.reparametrizeByArcLength=function(b){var e,c,f,j,g,k,m=[],n=new THREE.Vector3,p=this.getLength();m.push(n.copy(this.points[0]).clone());for(e=1;e<this.points.length;e++){c=p.chunks[e]-p.chunks[e-1];k=Math.ceil(b*c/p.total);j=(e-1)/(this.points.length-1);g=e/(this.points.length-1);for(c=1;c<k-1;c++)f=j+c*(1/k)*(g-j),position=this.getPoint(f),m.push(n.copy(position).clone());
|
|
|
|
|
m.push(n.copy(this.points[e]).clone())}this.points=m}};THREE.Edge=function(b,c,e,f){this.vertices=[b,c];this.vertexIndices=[e,f];this.faces=[];this.faceIndices=[]};THREE.Camera=function(b,c,e,f,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=e||0.1;this.far=f||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
|
|
|
|
|
THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);c.multiplyScalar(b);this.position.addSelf(c);this.target.position.addSelf(c)};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
|
|
|
|
|
THREE.Camera.prototype.update=function(b,c,d){if(this.useTarget)this.matrix.lookAt(this.position,this.target.position,this.up),this.matrix.setPosition(this.position),b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse),c=!0;else if(this.matrixAutoUpdate&&this.updateMatrix(),c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
|
|
|
|
|
!1,c=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,d)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;
|
|
|
|
|
THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,c,d,e){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1;this.distance=d||0;this.castShadow=e!==void 0?e:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,c,d){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=c||1;this.distance=d||0};
|
|
|
|
|
THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.LensFlare=function(b,c,d,e){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=void 0;b!==void 0&&this.add(b,c,d,e)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
|
|
|
|
|
THREE.LensFlare.prototype.add=function(b,c,d,e){c===void 0&&(c=-1);d===void 0&&(d=0);if(e===void 0)e=THREE.BillboardBlending;d=Math.min(d,Math.max(0,d));this.lensFlares.push({texture:b,size:c,distance:d,x:0,y:0,z:0,scale:1,rotation:1,opacity:1,blending:e})};
|
|
|
|
|
THREE.LensFlare.prototype.updateLensFlares=function(){var b,c=this.lensFlares.length,d,e=-this.positionScreen.x*2,f=-this.positionScreen.y*2;for(b=0;b<c;b++)d=this.lensFlares[b],d.x=this.positionScreen.x+e*d.distance,d.y=this.positionScreen.y+f*d.distance,d.wantedRotation=d.x*Math.PI*0.25,d.rotation+=(d.wantedRotation-d.rotation)*0.25};
|
|
|
|
|
THREE.Camera.prototype.update=function(b,c,e){if(this.useTarget)this.matrix.lookAt(this.position,this.target.position,this.up),this.matrix.setPosition(this.position),b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse),c=!0;else if(this.matrixAutoUpdate&&this.updateMatrix(),c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
|
|
|
|
|
!1,c=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,e)};THREE.Light=function(b){THREE.Object3D.call(this);this.color=new THREE.Color(b)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(b){THREE.Light.call(this,b)};THREE.AmbientLight.prototype=new THREE.Light;
|
|
|
|
|
THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(b,c,e,f){THREE.Light.call(this,b);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1;this.distance=e||0;this.castShadow=f!==void 0?f:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(b,c,e){THREE.Light.call(this,b);this.position=new THREE.Vector3;this.intensity=c||1;this.distance=e||0};
|
|
|
|
|
THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.LensFlare=function(b,c,e,f){THREE.Object3D.call(this);this.positionScreen=new THREE.Vector3;this.lensFlares=[];this.customUpdateCallback=void 0;b!==void 0&&this.add(b,c,e,f)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
|
|
|
|
|
THREE.LensFlare.prototype.add=function(b,c,e,f){c===void 0&&(c=-1);e===void 0&&(e=0);if(f===void 0)f=THREE.BillboardBlending;e=Math.min(e,Math.max(0,e));this.lensFlares.push({texture:b,size:c,distance:e,x:0,y:0,z:0,scale:1,rotation:1,opacity:1,blending:f})};
|
|
|
|
|
THREE.LensFlare.prototype.updateLensFlares=function(){var b,c=this.lensFlares.length,e,f=-this.positionScreen.x*2,g=-this.positionScreen.y*2;for(b=0;b<c;b++)e=this.lensFlares[b],e.x=this.positionScreen.x+f*e.distance,e.y=this.positionScreen.y+g*e.distance,e.wantedRotation=e.x*Math.PI*0.25,e.rotation+=(e.wantedRotation-e.rotation)*0.25};
|
|
|
|
|
THREE.Material=function(b){this.id=THREE.MaterialCounter.value++;b=b||{};this.opacity=b.opacity!==void 0?b.opacity:1;this.transparent=b.transparent!==void 0?b.transparent:!1;this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.depthTest=b.depthTest!==void 0?b.depthTest:!0};THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
|
|
|
|
|
THREE.MultiplyBlending=3;THREE.AdditiveAlphaBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
|
|
|
|
|
THREE.LineBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.linewidth=b.linewidth!==void 0?b.linewidth:1;this.linecap=b.linecap!==void 0?b.linecap:"round";this.linejoin=b.linejoin!==void 0?b.linejoin:"round";this.vertexColors=b.vertexColors?b.vertexColors:!1};THREE.LineBasicMaterial.prototype=new THREE.Material;THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
|
|
|
|
@@ -97,39 +98,39 @@ void 0?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==void 0?b.wiref
|
|
|
|
|
THREE.ShadowVolumeDynamicMaterial.prototype=new THREE.Material;THREE.ShadowVolumeDynamicMaterial.prototype.constructor=THREE.ShadowVolumeDynamicMaterial;
|
|
|
|
|
THREE.ParticleBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==void 0?b.map:null;this.size=b.size!==void 0?b.size:1;this.sizeAttenuation=b.sizeAttenuation!==void 0?b.sizeAttenuation:!0;this.vertexColors=b.vertexColors!==void 0?b.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
|
|
|
|
|
THREE.ParticleCanvasMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==void 0?new THREE.Color(b.color):new THREE.Color(16777215);this.program=b.program!==void 0?b.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;THREE.ParticleDOMMaterial=function(b){THREE.Material.call(this);this.domElement=b};
|
|
|
|
|
THREE.Texture=function(b,c,d,e,f,h){this.image=b;this.mapping=c!==void 0?c:new THREE.UVMapping;this.wrapS=d!==void 0?d:THREE.ClampToEdgeWrapping;this.wrapT=e!==void 0?e:THREE.ClampToEdgeWrapping;this.magFilter=f!==void 0?f:THREE.LinearFilter;this.minFilter=h!==void 0?h:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
|
|
|
|
|
THREE.Texture=function(b,c,e,f,g,j){this.image=b;this.mapping=c!==void 0?c:new THREE.UVMapping;this.wrapS=e!==void 0?e:THREE.ClampToEdgeWrapping;this.wrapT=f!==void 0?f:THREE.ClampToEdgeWrapping;this.magFilter=g!==void 0?g:THREE.LinearFilter;this.minFilter=j!==void 0?j:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
|
|
|
|
|
THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;
|
|
|
|
|
THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.Particle=function(b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b]};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
|
|
|
|
|
THREE.ParticleSystem=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(b,c,d){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.type=d!=void 0?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;
|
|
|
|
|
THREE.ParticleSystem=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(b,c,e){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c];this.type=e!=void 0?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;
|
|
|
|
|
THREE.Line.prototype.constructor=THREE.Line;
|
|
|
|
|
THREE.Mesh=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c&&c.length?c:[c];this.overdraw=!1;if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=b.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var d=0;d<this.geometry.morphTargets.length;d++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[d].name]=
|
|
|
|
|
d}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(b){if(this.morphTargetDictionary[b]!==void 0)return this.morphTargetDictionary[b];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+b+" does not exist. Returning 0.");return 0};
|
|
|
|
|
THREE.Mesh=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c&&c.length?c:[c];this.overdraw=!1;if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=b.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var e=0;e<this.geometry.morphTargets.length;e++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[e].name]=
|
|
|
|
|
e}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(b){if(this.morphTargetDictionary[b]!==void 0)return this.morphTargetDictionary[b];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+b+" does not exist. Returning 0.");return 0};
|
|
|
|
|
THREE.Bone=function(b){THREE.Object3D.call(this);this.skin=b;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
|
|
|
|
|
THREE.Bone.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,f=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<f;e++)b=this.children[e],b instanceof THREE.Bone?b.update(this.skinMatrix,c,d):b.update(this.matrixWorld,!0,d)}else for(e=0;e<f;e++)this.children[e].update(this.skinMatrix,
|
|
|
|
|
c,d)};THREE.Bone.prototype.addChild=function(b){if(this.children.indexOf(b)===-1&&(b.parent!==void 0&&b.parent.removeChild(b),b.parent=this,this.children.push(b),!(b instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};
|
|
|
|
|
THREE.SkinnedMesh=function(b,c){THREE.Mesh.call(this,b,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,e,f,h,j,k;if(this.geometry.bones!==void 0){for(d=0;d<this.geometry.bones.length;d++)f=this.geometry.bones[d],h=f.pos,j=f.rotq,k=f.scl,e=this.addBone(),e.name=f.name,e.position.set(h[0],h[1],h[2]),e.quaternion.set(j[0],j[1],j[2],j[3]),e.useQuaternion=!0,k!==void 0?e.scale.set(k[0],k[1],k[2]):e.scale.set(1,1,1);for(d=0;d<this.bones.length;d++)f=this.geometry.bones[d],
|
|
|
|
|
e=this.bones[d],f.parent===-1?this.addChild(e):this.bones[f.parent].addChild(e);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
|
|
|
|
|
THREE.SkinnedMesh.prototype.update=function(b,c,d){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var e,f=this.children.length;for(e=0;e<f;e++)b=this.children[e],b instanceof THREE.Bone?b.update(this.identityMatrix,!1,d):b.update(this.matrixWorld,c,d);d=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<d;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
|
|
|
|
|
THREE.Bone.prototype.update=function(b,c,e){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var f,g=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(f=0;f<g;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.skinMatrix,c,e):b.update(this.matrixWorld,!0,e)}else for(f=0;f<g;f++)this.children[f].update(this.skinMatrix,
|
|
|
|
|
c,e)};THREE.Bone.prototype.addChild=function(b){if(this.children.indexOf(b)===-1&&(b.parent!==void 0&&b.parent.removeChild(b),b.parent=this,this.children.push(b),!(b instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};
|
|
|
|
|
THREE.SkinnedMesh=function(b,c){THREE.Mesh.call(this,b,c);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,f,g,j,k,m;if(this.geometry.bones!==void 0){for(e=0;e<this.geometry.bones.length;e++)g=this.geometry.bones[e],j=g.pos,k=g.rotq,m=g.scl,f=this.addBone(),f.name=g.name,f.position.set(j[0],j[1],j[2]),f.quaternion.set(k[0],k[1],k[2],k[3]),f.useQuaternion=!0,m!==void 0?f.scale.set(m[0],m[1],m[2]):f.scale.set(1,1,1);for(e=0;e<this.bones.length;e++)g=this.geometry.bones[e],
|
|
|
|
|
f=this.bones[e],g.parent===-1?this.addChild(f):this.bones[g.parent].addChild(f);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
|
|
|
|
|
THREE.SkinnedMesh.prototype.update=function(b,c,e){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;var f,g=this.children.length;for(f=0;f<g;f++)b=this.children[f],b instanceof THREE.Bone?b.update(this.identityMatrix,!1,e):b.update(this.matrixWorld,c,e);e=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(c=0;c<e;c++)ba[c].skinMatrix.flattenToArrayOffset(bm,
|
|
|
|
|
c*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===void 0&&(b=new THREE.Bone(this));this.bones.push(b);return b};
|
|
|
|
|
THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,c=[],d=0;d<this.bones.length;d++)b=this.bones[d],c.push(THREE.Matrix4.makeInvert(b.skinMatrix)),b.skinMatrix.flattenToArrayOffset(this.boneMatrices,d*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(b=0;b<this.geometry.skinIndices.length;b++){var d=this.geometry.vertices[b].position,f=this.geometry.skinIndices[b].x,h=this.geometry.skinIndices[b].y;e=new THREE.Vector3(d.x,
|
|
|
|
|
d.y,d.z);this.geometry.skinVerticesA.push(c[f].multiplyVector3(e));e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesB.push(c[h].multiplyVector3(e));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(d=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=d,this.geometry.skinWeights[b].y+=d)}}};THREE.Ribbon=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c]};
|
|
|
|
|
THREE.SkinnedMesh.prototype.pose=function(){this.update(void 0,!0);for(var b,c=[],e=0;e<this.bones.length;e++)b=this.bones[e],c.push(THREE.Matrix4.makeInvert(b.skinMatrix)),b.skinMatrix.flattenToArrayOffset(this.boneMatrices,e*16);if(this.geometry.skinVerticesA===void 0){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var f;for(b=0;b<this.geometry.skinIndices.length;b++){var e=this.geometry.vertices[b].position,g=this.geometry.skinIndices[b].x,j=this.geometry.skinIndices[b].y;f=new THREE.Vector3(e.x,
|
|
|
|
|
e.y,e.z);this.geometry.skinVerticesA.push(c[g].multiplyVector3(f));f=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesB.push(c[j].multiplyVector3(f));this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1&&(e=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5,this.geometry.skinWeights[b].x+=e,this.geometry.skinWeights[b].y+=e)}}};THREE.Ribbon=function(b,c){THREE.Object3D.call(this);this.geometry=b;this.materials=c instanceof Array?c:[c]};
|
|
|
|
|
THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
|
|
|
|
|
THREE.Sound=function(b,c,d,e){THREE.Object3D.call(this);this.isPlaying=this.isAddedToDOM=this.isLoaded=!1;this.duration=-1;this.radius=c!==void 0?Math.abs(c):100;this.volume=Math.min(1,Math.max(0,d!==void 0?d:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=e!==void 0?e:!0;this.sources=b instanceof Array?b:[b];for(var f,d=this.sources.length,b=0;b<d;b++)if(c=this.sources[b],c.toLowerCase(),c.indexOf(".mp3")!==-1?f="audio/mpeg":
|
|
|
|
|
c.indexOf(".ogg")!==-1?f="audio/ogg":c.indexOf(".wav")!==-1&&(f="audio/wav"),this.domElement.canPlayType(f)){f=document.createElement("source");f.src=this.sources[b];this.domElement.THREESound=this;this.domElement.appendChild(f);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
|
|
|
|
|
THREE.Sound=function(b,c,e,f){THREE.Object3D.call(this);this.isPlaying=this.isAddedToDOM=this.isLoaded=!1;this.duration=-1;this.radius=c!==void 0?Math.abs(c):100;this.volume=Math.min(1,Math.max(0,e!==void 0?e:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=f!==void 0?f:!0;this.sources=b instanceof Array?b:[b];for(var g,e=this.sources.length,b=0;b<e;b++)if(c=this.sources[b],c.toLowerCase(),c.indexOf(".mp3")!==-1?g="audio/mpeg":
|
|
|
|
|
c.indexOf(".ogg")!==-1?g="audio/ogg":c.indexOf(".wav")!==-1&&(g="audio/wav"),this.domElement.canPlayType(g)){g=document.createElement("source");g.src=this.sources[b];this.domElement.THREESound=this;this.domElement.appendChild(g);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
|
|
|
|
|
THREE.Sound.prototype.onLoad=function(){var b=this.THREESound;if(!b.isLoaded)this.removeEventListener("canplay",this.onLoad,!0),b.isLoaded=!0,b.duration=this.duration,b.isPlaying&&b.play()};THREE.Sound.prototype.addToDOM=function(b){this.isAddedToDOM=!0;b.appendChild(this.domElement)};THREE.Sound.prototype.play=function(b){this.isPlaying=!0;if(this.isLoaded&&(this.domElement.play(),b))this.domElement.currentTime=b%this.duration};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
|
|
|
|
|
THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(b){b=b.length();this.domElement.volume=b<=this.radius?this.volume*(1-b/this.radius):0};
|
|
|
|
|
THREE.Sound.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(this.matrix.setPosition(this.position),c=!0);if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;for(var e=this.children.length,b=0;b<e;b++)this.children[b].update(this.matrixWorld,c,d)};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;
|
|
|
|
|
THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(b,c){c===void 0&&(c=0);for(var c=Math.abs(c),d=0;d<this.LODs.length;d++)if(c<this.LODs[d].visibleAtDistance)break;this.LODs.splice(d,0,{visibleAtDistance:c,object3D:b});this.addChild(b)};
|
|
|
|
|
THREE.LOD.prototype.update=function(b,c,d){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;if(this.LODs.length>1){b=d.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e<this.LODs.length;e++)if(b>=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1,
|
|
|
|
|
this.LODs[e].object3D.visible=!0;else break;for(;e<this.LODs.length;e++)this.LODs[e].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,d)};THREE.ShadowVolume=function(b,c){b instanceof THREE.Mesh?(THREE.Mesh.call(this,b.geometry,c?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]),b.addChild(this)):THREE.Mesh.call(this,b,c?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);this.calculateShadowVolumeGeometry()};
|
|
|
|
|
THREE.Sound.prototype.update=function(b,c,e){this.matrixAutoUpdate&&(this.matrix.setPosition(this.position),c=!0);if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;for(var f=this.children.length,b=0;b<f;b++)this.children[b].update(this.matrixWorld,c,e)};THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;
|
|
|
|
|
THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=function(b,c){c===void 0&&(c=0);for(var c=Math.abs(c),e=0;e<this.LODs.length;e++)if(c<this.LODs[e].visibleAtDistance)break;this.LODs.splice(e,0,{visibleAtDistance:c,object3D:b});this.addChild(b)};
|
|
|
|
|
THREE.LOD.prototype.update=function(b,c,e){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0;if(this.LODs.length>1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f<this.LODs.length;f++)if(b>=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1,
|
|
|
|
|
this.LODs[f].object3D.visible=!0;else break;for(;f<this.LODs.length;f++)this.LODs[f].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,e)};THREE.ShadowVolume=function(b,c){b instanceof THREE.Mesh?(THREE.Mesh.call(this,b.geometry,c?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]),b.addChild(this)):THREE.Mesh.call(this,b,c?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);this.calculateShadowVolumeGeometry()};
|
|
|
|
|
THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
|
|
|
|
|
THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,c,d,e,f,h,j,k,m,o,n,p,t,u,v=new THREE.Geometry;v.vertices=this.geometry.vertices;e=v.faces=this.geometry.faces;var C=v.egdes=this.geometry.edges,E=v.edgeFaces=[];f=0;var y=[];b=0;for(c=e.length;b<c;b++)if(d=e[b],y.push(f),f+=d instanceof THREE.Face3?3:4,d.vertexNormals[0]=d.normal,d.vertexNormals[1]=d.normal,d.vertexNormals[2]=d.normal,d instanceof THREE.Face4)d.vertexNormals[3]=
|
|
|
|
|
d.normal;b=0;for(c=C.length;b<c;b++)k=C[b],d=k.faces[0],e=k.faces[1],f=k.faceIndices[0],h=k.faceIndices[1],j=k.vertexIndices[0],k=k.vertexIndices[1],d.a===j?(m="a",n=y[f]+0):d.b===j?(m="b",n=y[f]+1):d.c===j?(m="c",n=y[f]+2):d.d===j&&(m="d",n=y[f]+3),d.a===k?(m+="a",p=y[f]+0):d.b===k?(m+="b",p=y[f]+1):d.c===k?(m+="c",p=y[f]+2):d.d===k&&(m+="d",p=y[f]+3),e.a===j?(o="a",t=y[h]+0):e.b===j?(o="b",t=y[h]+1):e.c===j?(o="c",t=y[h]+2):e.d===j&&(o="d",t=y[h]+3),e.a===k?(o+="a",u=y[h]+0):e.b===k?(o+="b",u=y[h]+
|
|
|
|
|
1):e.c===k?(o+="c",u=y[h]+2):e.d===k&&(o+="d",u=y[h]+3),m==="ac"||m==="ad"||m==="ca"||m==="da"?n>p&&(d=n,n=p,p=d):n<p&&(d=n,n=p,p=d),o==="ac"||o==="ad"||o==="ca"||o==="da"?t>u&&(d=t,t=u,u=d):t<u&&(d=t,t=u,u=d),d=new THREE.Face4(n,p,t,u),d.normal.set(1,0,0),E.push(d);this.geometry=v}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
|
|
|
|
|
THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var c=this.geometry.vertices,d=this.geometry.faces,e=this.geometry.edgeFaces,f=b.faces,b=b.vertices,h=f.length,j,k,m,o,n,p=["a","b","c","d"];for(m=0;m<h;m++){k=c.length;j=f[m];j instanceof THREE.Face4?(o=4,k=new THREE.Face4(k,k+1,k+2,k+3)):(o=3,k=new THREE.Face3(k,k+1,k+2));k.normal.copy(j.normal);d.push(k);
|
|
|
|
|
for(k=0;k<o;k++)n=b[j[p[k]]],c.push(new THREE.Vertex(n.position.clone()))}for(h=0;h<f.length-1;h++){b=d[h];for(j=h+1;j<f.length;j++)k=d[j],k=this.facesShareEdge(c,b,k),k!==void 0&&(k=new THREE.Face4(k.indices[0],k.indices[3],k.indices[2],k.indices[1]),k.normal.set(1,0,0),e.push(k))}};
|
|
|
|
|
THREE.ShadowVolume.prototype.facesShareEdge=function(b,c,d){var e,f,h,j,k,m,o,n,p,t,u,v,C,E=0,y=["a","b","c","d"];e=c instanceof THREE.Face4?4:3;f=d instanceof THREE.Face4?4:3;for(v=0;v<e;v++){h=c[y[v]];k=b[h];for(C=0;C<f;C++)if(j=d[y[C]],m=b[j],Math.abs(k.position.x-m.position.x)<1.0E-4&&Math.abs(k.position.y-m.position.y)<1.0E-4&&Math.abs(k.position.z-m.position.z)<1.0E-4&&(E++,E===1&&(o=k,n=m,p=h,t=j,u=y[v]),E===2))return u+=y[v],u==="ad"||u==="ac"?{faces:[c,d],vertices:[o,n,m,k],indices:[p,t,
|
|
|
|
|
j,h],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[c,d],vertices:[o,k,m,n],indices:[p,h,j,t],vertexTypes:[1,1,2,2],extrudable:!0}}};
|
|
|
|
|
THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(){if(this.geometry.edges&&this.geometry.edges.length){var b,c,e,f,g,j,k,m,n,p,o,t,u,v,w=new THREE.Geometry;w.vertices=this.geometry.vertices;f=w.faces=this.geometry.faces;var E=w.egdes=this.geometry.edges,H=w.edgeFaces=[];g=0;var B=[];b=0;for(c=f.length;b<c;b++)if(e=f[b],B.push(g),g+=e instanceof THREE.Face3?3:4,e.vertexNormals[0]=e.normal,e.vertexNormals[1]=e.normal,e.vertexNormals[2]=e.normal,e instanceof THREE.Face4)e.vertexNormals[3]=
|
|
|
|
|
e.normal;b=0;for(c=E.length;b<c;b++)m=E[b],e=m.faces[0],f=m.faces[1],g=m.faceIndices[0],j=m.faceIndices[1],k=m.vertexIndices[0],m=m.vertexIndices[1],e.a===k?(n="a",o=B[g]+0):e.b===k?(n="b",o=B[g]+1):e.c===k?(n="c",o=B[g]+2):e.d===k&&(n="d",o=B[g]+3),e.a===m?(n+="a",t=B[g]+0):e.b===m?(n+="b",t=B[g]+1):e.c===m?(n+="c",t=B[g]+2):e.d===m&&(n+="d",t=B[g]+3),f.a===k?(p="a",u=B[j]+0):f.b===k?(p="b",u=B[j]+1):f.c===k?(p="c",u=B[j]+2):f.d===k&&(p="d",u=B[j]+3),f.a===m?(p+="a",v=B[j]+0):f.b===m?(p+="b",v=B[j]+
|
|
|
|
|
1):f.c===m?(p+="c",v=B[j]+2):f.d===m&&(p+="d",v=B[j]+3),n==="ac"||n==="ad"||n==="ca"||n==="da"?o>t&&(e=o,o=t,t=e):o<t&&(e=o,o=t,t=e),p==="ac"||p==="ad"||p==="ca"||p==="da"?u>v&&(e=u,u=v,v=e):u<v&&(e=u,u=v,v=e),e=new THREE.Face4(o,t,u,v),e.normal.set(1,0,0),H.push(e);this.geometry=w}else this.calculateShadowVolumeGeometryWithoutEdgeInfo(this.geometry)};
|
|
|
|
|
THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var c=this.geometry.vertices,e=this.geometry.faces,f=this.geometry.edgeFaces,g=b.faces,b=b.vertices,j=g.length,k,m,n,p,o,t=["a","b","c","d"];for(n=0;n<j;n++){m=c.length;k=g[n];k instanceof THREE.Face4?(p=4,m=new THREE.Face4(m,m+1,m+2,m+3)):(p=3,m=new THREE.Face3(m,m+1,m+2));m.normal.copy(k.normal);e.push(m);
|
|
|
|
|
for(m=0;m<p;m++)o=b[k[t[m]]],c.push(new THREE.Vertex(o.position.clone()))}for(j=0;j<g.length-1;j++){b=e[j];for(k=j+1;k<g.length;k++)m=e[k],m=this.facesShareEdge(c,b,m),m!==void 0&&(m=new THREE.Face4(m.indices[0],m.indices[3],m.indices[2],m.indices[1]),m.normal.set(1,0,0),f.push(m))}};
|
|
|
|
|
THREE.ShadowVolume.prototype.facesShareEdge=function(b,c,e){var f,g,j,k,m,n,p,o,t,u,v,w,E,H=0,B=["a","b","c","d"];f=c instanceof THREE.Face4?4:3;g=e instanceof THREE.Face4?4:3;for(w=0;w<f;w++){j=c[B[w]];m=b[j];for(E=0;E<g;E++)if(k=e[B[E]],n=b[k],Math.abs(m.position.x-n.position.x)<1.0E-4&&Math.abs(m.position.y-n.position.y)<1.0E-4&&Math.abs(m.position.z-n.position.z)<1.0E-4&&(H++,H===1&&(p=m,o=n,t=j,u=k,v=B[w]),H===2))return v+=B[w],v==="ad"||v==="ac"?{faces:[c,e],vertices:[p,o,n,m],indices:[t,u,
|
|
|
|
|
k,j],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[c,e],vertices:[p,m,n,o],indices:[t,j,k,u],vertexTypes:[1,1,2,2],extrudable:!0}}};
|
|
|
|
|
THREE.Sprite=function(b){THREE.Object3D.call(this);if(b.material!==void 0)this.material=b.material,this.map=void 0,this.blending=material.blending;else if(b.map!==void 0)this.map=b.map instanceof THREE.Texture?b.map:ImageUtils.loadTexture(b.map),this.material=void 0,this.blending=b.blending!==void 0?b.blending:THREE.NormalBlending;this.useScreenCoordinates=b.useScreenCoordinates!==void 0?b.useScreenCoordinates:!0;this.mergeWith3D=b.mergeWith3D!==void 0?b.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=
|
|
|
|
|
b.affectedByDistance!==void 0?b.affectedByDistance:!this.useScreenCoordinates;this.alignment=b.alignment instanceof THREE.Vector2?b.alignment:THREE.SpriteAlignment.center;this.rotation3d=this.rotation;this.rotation=0;this.opacity=1;this.uvOffset=new THREE.Vector2(0,0);this.uvScale=new THREE.Vector2(1,1)};THREE.Sprite.prototype=new THREE.Object3D;THREE.Sprite.prototype.constructor=THREE.Sprite;THREE.Sprite.prototype.supr=THREE.Object3D.prototype;
|
|
|
|
|
THREE.Sprite.prototype.updateMatrix=function(){this.matrix.setPosition(this.position);this.rotation3d.set(0,0,this.rotation);this.matrix.setRotationFromEuler(this.rotation3d);if(this.scale.x!==1||this.scale.y!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,this.scale.y);this.matrixWorldNeedsUpdate=!0};THREE.SpriteAlignment={};THREE.SpriteAlignment.topLeft=new THREE.Vector2(1,-1);THREE.SpriteAlignment.topCenter=new THREE.Vector2(0,-1);
|
|
|
|
@@ -137,57 +138,57 @@ THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.ce
|
|
|
|
|
THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.collisions=this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(b){this.supr.addChild.call(this,b);this.addChildRecurse(b)};
|
|
|
|
|
THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(b instanceof THREE.Sound)this.sounds.indexOf(b)===-1&&this.sounds.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1)this.objects.push(b),this.__objectsAdded.push(b);for(var c=0;c<b.children.length;c++)this.addChildRecurse(b.children[c])};
|
|
|
|
|
THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var c=this.lights.indexOf(b);c!==-1&&this.lights.splice(c,1)}else b instanceof THREE.Sound?(c=this.sounds.indexOf(b),c!==-1&&this.sounds.splice(c,1)):b instanceof THREE.Camera||(c=this.objects.indexOf(b),c!==-1&&(this.objects.splice(c,1),this.__objectsRemoved.push(b)));for(c=0;c<b.children.length;c++)this.removeChildRecurse(b.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(b,c,d){this.color=new THREE.Color(b);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(b,c){this.color=new THREE.Color(b);this.density=c!==void 0?c:2.5E-4};
|
|
|
|
|
THREE.Projector=function(){function b(){var b=m[k]=m[k]||new THREE.RenderableVertex;k++;return b}function c(b,d){return d.z-b.z}function d(b,d){var c=0,e=1,h=b.z+b.w,f=d.z+d.w,j=-b.z+b.w,k=-d.z+d.w;return h>=0&&f>=0&&j>=0&&k>=0?!0:h<0&&f<0||j<0&&k<0?!1:(h<0?c=Math.max(c,h/(h-f)):f<0&&(e=Math.min(e,h/(h-f))),j<0?c=Math.max(c,j/(j-k)):k<0&&(e=Math.min(e,j/(j-k))),e<c?!1:(b.lerpSelf(d,c),d.lerpSelf(b,1-e),!0))}var e,f,h=[],j,k,m=[],o,n,p=[],t,u=[],v,C,E=[],y,D,x=[],I=new THREE.Vector4,A=new THREE.Vector4,
|
|
|
|
|
z=new THREE.Matrix4,S=new THREE.Matrix4,G=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Vector4,F=new THREE.Vector4;this.projectVector=function(b,d){z.multiply(d.projectionMatrix,d.matrixWorldInverse);z.multiplyVector3(b);return b};this.unprojectVector=function(b,d){z.multiply(d.matrixWorld,THREE.Matrix4.makeInvert(d.projectionMatrix));z.multiplyVector3(b);return b};this.projectObjects=function(b,d,j){var d=[],k,m,o;f=0;m=
|
|
|
|
|
b.objects;b=0;for(k=m.length;b<k;b++){o=m[b];var p;if(!(p=!o.visible))if(p=o instanceof THREE.Mesh){a:{p=void 0;for(var n=o.matrixWorld,t=-o.geometry.boundingSphere.radius*Math.max(o.scale.x,Math.max(o.scale.y,o.scale.z)),u=0;u<6;u++)if(p=G[u].x*n.n14+G[u].y*n.n24+G[u].z*n.n34+G[u].w,p<=t){p=!1;break a}p=!0}p=!p}if(!p)p=h[f]=h[f]||new THREE.RenderableObject,f++,e=p,I.copy(o.position),z.multiplyVector3(I),e.object=o,e.z=I.z,d.push(e)}j&&d.sort(c);return d};this.projectScene=function(e,g,h){var f=[],
|
|
|
|
|
I=g.near,L=g.far,$,T,Q,fa,U,ka,ga,ca,aa,R,P,W,X,ea,ia,J,da;D=C=t=n=0;g.matrixAutoUpdate&&g.update(void 0,!0);e.update(void 0,!1,g);z.multiply(g.projectionMatrix,g.matrixWorldInverse);G[0].set(z.n41-z.n11,z.n42-z.n12,z.n43-z.n13,z.n44-z.n14);G[1].set(z.n41+z.n11,z.n42+z.n12,z.n43+z.n13,z.n44+z.n14);G[2].set(z.n41+z.n21,z.n42+z.n22,z.n43+z.n23,z.n44+z.n24);G[3].set(z.n41-z.n21,z.n42-z.n22,z.n43-z.n23,z.n44-z.n24);G[4].set(z.n41-z.n31,z.n42-z.n32,z.n43-z.n33,z.n44-z.n34);G[5].set(z.n41+z.n31,z.n42+z.n32,
|
|
|
|
|
z.n43+z.n33,z.n44+z.n34);for($=0;$<6;$++)aa=G[$],aa.divideScalar(Math.sqrt(aa.x*aa.x+aa.y*aa.y+aa.z*aa.z));aa=this.projectObjects(e,g,!0);e=0;for($=aa.length;e<$;e++)if(R=aa[e].object,R.visible)if(P=R.matrixWorld,W=R.matrixRotationWorld,X=R.materials,ea=R.overdraw,k=0,R instanceof THREE.Mesh){ia=R.geometry;fa=ia.vertices;J=ia.faces;ia=ia.faceVertexUvs;T=0;for(Q=fa.length;T<Q;T++)j=b(),j.positionWorld.copy(fa[T].position),P.multiplyVector3(j.positionWorld),j.positionScreen.copy(j.positionWorld),z.multiplyVector4(j.positionScreen),
|
|
|
|
|
j.positionScreen.x/=j.positionScreen.w,j.positionScreen.y/=j.positionScreen.w,j.visible=j.positionScreen.z>I&&j.positionScreen.z<L;fa=0;for(T=J.length;fa<T;fa++){Q=J[fa];if(Q instanceof THREE.Face3)if(U=m[Q.a],ka=m[Q.b],ga=m[Q.c],U.visible&&ka.visible&&ga.visible&&(R.doubleSided||R.flipSided!=(ga.positionScreen.x-U.positionScreen.x)*(ka.positionScreen.y-U.positionScreen.y)-(ga.positionScreen.y-U.positionScreen.y)*(ka.positionScreen.x-U.positionScreen.x)<0))ca=p[n]=p[n]||new THREE.RenderableFace3,
|
|
|
|
|
n++,o=ca,o.v1.copy(U),o.v2.copy(ka),o.v3.copy(ga);else continue;else if(Q instanceof THREE.Face4)if(U=m[Q.a],ka=m[Q.b],ga=m[Q.c],ca=m[Q.d],U.visible&&ka.visible&&ga.visible&&ca.visible&&(R.doubleSided||R.flipSided!=((ca.positionScreen.x-U.positionScreen.x)*(ka.positionScreen.y-U.positionScreen.y)-(ca.positionScreen.y-U.positionScreen.y)*(ka.positionScreen.x-U.positionScreen.x)<0||(ka.positionScreen.x-ga.positionScreen.x)*(ca.positionScreen.y-ga.positionScreen.y)-(ka.positionScreen.y-ga.positionScreen.y)*
|
|
|
|
|
(ca.positionScreen.x-ga.positionScreen.x)<0)))da=u[t]=u[t]||new THREE.RenderableFace4,t++,o=da,o.v1.copy(U),o.v2.copy(ka),o.v3.copy(ga),o.v4.copy(ca);else continue;o.normalWorld.copy(Q.normal);W.multiplyVector3(o.normalWorld);o.centroidWorld.copy(Q.centroid);P.multiplyVector3(o.centroidWorld);o.centroidScreen.copy(o.centroidWorld);z.multiplyVector3(o.centroidScreen);ga=Q.vertexNormals;U=0;for(ka=ga.length;U<ka;U++)ca=o.vertexNormalsWorld[U],ca.copy(ga[U]),W.multiplyVector3(ca);U=0;for(ka=ia.length;U<
|
|
|
|
|
ka;U++)if(da=ia[U][fa]){ga=0;for(ca=da.length;ga<ca;ga++)o.uvs[U][ga]=da[ga]}o.meshMaterials=X;o.faceMaterials=Q.materials;o.overdraw=ea;o.z=o.centroidScreen.z;f.push(o)}}else if(R instanceof THREE.Line){S.multiply(z,P);fa=R.geometry.vertices;U=b();U.positionScreen.copy(fa[0].position);S.multiplyVector4(U.positionScreen);T=1;for(Q=fa.length;T<Q;T++)if(U=b(),U.positionScreen.copy(fa[T].position),S.multiplyVector4(U.positionScreen),ka=m[k-2],M.copy(U.positionScreen),F.copy(ka.positionScreen),d(M,F))M.multiplyScalar(1/
|
|
|
|
|
M.w),F.multiplyScalar(1/F.w),P=E[C]=E[C]||new THREE.RenderableLine,C++,v=P,v.v1.positionScreen.copy(M),v.v2.positionScreen.copy(F),v.z=Math.max(M.z,F.z),v.materials=R.materials,f.push(v)}else if(R instanceof THREE.Particle&&(A.set(R.matrixWorld.n14,R.matrixWorld.n24,R.matrixWorld.n34,1),z.multiplyVector4(A),A.z/=A.w,A.z>0&&A.z<1))P=x[D]=x[D]||new THREE.RenderableParticle,D++,y=P,y.x=A.x/A.w,y.y=A.y/A.w,y.z=A.z,y.rotation=R.rotation.z,y.scale.x=R.scale.x*Math.abs(y.x-(A.x+g.projectionMatrix.n11)/(A.w+
|
|
|
|
|
g.projectionMatrix.n14)),y.scale.y=R.scale.y*Math.abs(y.y-(A.y+g.projectionMatrix.n22)/(A.w+g.projectionMatrix.n24)),y.materials=R.materials,f.push(y);h&&f.sort(c);return f}};
|
|
|
|
|
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,d,e,f,h;this.domElement=document.createElement("div");this.setSize=function(b,c){d=b;e=c;f=d/2;h=e/2};this.render=function(d,e){var m,o,n,p,t,u,v,C;b=c.projectScene(d,e);m=0;for(o=b.length;m<o;m++)if(t=b[m],t instanceof THREE.RenderableParticle){v=t.x*f+f;C=t.y*h+h;n=0;for(p=t.material.length;n<p;n++)if(u=t.material[n],u instanceof THREE.ParticleDOMMaterial)u=u.domElement,u.style.left=v+"px",u.style.top=C+"px"}}};
|
|
|
|
|
THREE.CanvasRenderer=function(b){function c(b){if(y!=b)v.globalAlpha=y=b}function d(b){if(D!=b){switch(b){case THREE.NormalBlending:v.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:v.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:v.globalCompositeOperation="darker"}D=b}}function e(b){if(x!=b.hex)x=b.hex,v.strokeStyle="#"+h(x.toString(16))}function f(b){if(I!=b.hex)I=b.hex,v.fillStyle="#"+h(I.toString(16))}function h(b){for(;b.length<6;)b="0"+b;return b}
|
|
|
|
|
var j=this,k=null,m=new THREE.Projector,b=b||{},o=b.canvas!==void 0?b.canvas:document.createElement("canvas"),n,p,t,u,v=o.getContext("2d"),C=new THREE.Color(0),E=0,y=1,D=0,x=null,I=null,A=null,z=null,S=null,G,M,F,N,g=new THREE.RenderableVertex,Y=new THREE.RenderableVertex,O,V,L,$,T,Q,fa,U,ka,ga,ca,aa,R=new THREE.Color(0),P=new THREE.Color(0),W=new THREE.Color(0),X=new THREE.Color(0),ea=new THREE.Color(0),ia,J,da,la,ma,ya,va,Z,K,wa,qa=new THREE.Rectangle,ha=new THREE.Rectangle,pa=new THREE.Rectangle,
|
|
|
|
|
Sa=!1,sa=new THREE.Color,ra=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,na=new THREE.Vector3,Ja,Ka,Ta,ta,La,Oa,b=16;Ja=document.createElement("canvas");Ja.width=Ja.height=2;Ka=Ja.getContext("2d");Ka.fillStyle="rgba(0,0,0,1)";Ka.fillRect(0,0,2,2);Ta=Ka.getImageData(0,0,2,2);ta=Ta.data;La=document.createElement("canvas");La.width=La.height=b;Oa=La.getContext("2d");Oa.translate(-b/2,-b/2);Oa.scale(b,b);b--;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,
|
|
|
|
|
faces:0};this.setSize=function(b,d){n=b;p=d;t=n/2;u=p/2;o.width=n;o.height=p;qa.set(-t,-u,t,u);y=1;D=0;S=z=A=I=x=null};this.setClearColor=function(b,d){C=b;E=d};this.setClearColorHex=function(b,d){C.setHex(b);E=d};this.clear=function(){v.setTransform(1,0,0,-1,t,u);if(!ha.isEmpty())ha.inflate(1),ha.minSelf(qa),C.hex==0&&E==0?v.clearRect(ha.getX(),ha.getY(),ha.getWidth(),ha.getHeight()):(d(THREE.NormalBlending),c(1),v.fillStyle="rgba("+Math.floor(C.r*255)+","+Math.floor(C.g*255)+","+Math.floor(C.b*
|
|
|
|
|
255)+","+E+")",v.fillRect(ha.getX(),ha.getY(),ha.getWidth(),ha.getHeight())),ha.empty()};this.render=function(b,h){function o(b){var d,c,g,e=b.lights;ra.setRGB(0,0,0);Ma.setRGB(0,0,0);Na.setRGB(0,0,0);b=0;for(d=e.length;b<d;b++)c=e[b],g=c.color,c instanceof THREE.AmbientLight?(ra.r+=g.r,ra.g+=g.g,ra.b+=g.b):c instanceof THREE.DirectionalLight?(Ma.r+=g.r,Ma.g+=g.g,Ma.b+=g.b):c instanceof THREE.PointLight&&(Na.r+=g.r,Na.g+=g.g,Na.b+=g.b)}function p(b,d,c,g){var e,h,f,j,k=b.lights,b=0;for(e=k.length;b<
|
|
|
|
|
e;b++)h=k[b],f=h.color,h instanceof THREE.DirectionalLight?(j=c.dot(h.position),j<=0||(j*=h.intensity,g.r+=f.r*j,g.g+=f.g*j,g.b+=f.b*j)):h instanceof THREE.PointLight&&(j=c.dot(na.sub(h.position,d).normalize()),j<=0||(j*=h.distance==0?1:1-Math.min(d.distanceTo(h.position)/h.distance,1),j!=0&&(j*=h.intensity,g.r+=f.r*j,g.g+=f.g*j,g.b+=f.b*j)))}function n(b,g,h){c(h.opacity);d(h.blending);var j,k,ha,m,o,p;if(h instanceof THREE.ParticleBasicMaterial){if(h.map)m=h.map.image,o=m.width>>1,p=m.height>>1,
|
|
|
|
|
h=g.scale.x*t,ha=g.scale.y*u,j=h*o,k=ha*p,pa.set(b.x-j,b.y-k,b.x+j,b.y+k),qa.instersects(pa)&&(v.save(),v.translate(b.x,b.y),v.rotate(-g.rotation),v.scale(h,-ha),v.translate(-o,-p),v.drawImage(m,0,0),v.restore())}else h instanceof THREE.ParticleCanvasMaterial&&(j=g.scale.x*t,k=g.scale.y*u,pa.set(b.x-j,b.y-k,b.x+j,b.y+k),qa.instersects(pa)&&(e(h.color),f(h.color),v.save(),v.translate(b.x,b.y),v.rotate(-g.rotation),v.scale(j,k),h.program(v),v.restore()))}function y(b,g,h,f){c(f.opacity);d(f.blending);
|
|
|
|
|
v.beginPath();v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(g.positionScreen.x,g.positionScreen.y);v.closePath();if(f instanceof THREE.LineBasicMaterial){b=f.linewidth;if(A!=b)v.lineWidth=A=b;b=f.linecap;if(z!=b)v.lineCap=z=b;b=f.linejoin;if(S!=b)v.lineJoin=S=b;e(f.color);v.stroke();pa.inflate(f.linewidth*2)}}function x(b,g,e,f,k,ha,m,o,n){j.data.vertices+=3;j.data.faces++;c(o.opacity);d(o.blending);O=b.positionScreen.x;V=b.positionScreen.y;L=g.positionScreen.x;$=g.positionScreen.y;T=e.positionScreen.x;
|
|
|
|
|
Q=e.positionScreen.y;E(O,V,L,$,T,Q);if(o instanceof THREE.MeshBasicMaterial)if(o.map)o.map.mapping instanceof THREE.UVMapping&&(la=m.uvs[0],w(O,V,L,$,T,Q,o.map.image,la[f].u,la[f].v,la[k].u,la[k].v,la[ha].u,la[ha].v));else if(o.envMap){if(o.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=h.matrixWorldInverse,na.copy(m.vertexNormalsWorld[0]),ma=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,ya=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(m.vertexNormalsWorld[1]),va=(na.x*b.n11+na.y*
|
|
|
|
|
b.n12+na.z*b.n13)*0.5+0.5,Z=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(m.vertexNormalsWorld[2]),K=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,wa=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,w(O,V,L,$,T,Q,o.envMap.image,ma,ya,va,Z,K,wa)}else o.wireframe?B(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):D(o.color);else if(o instanceof THREE.MeshLambertMaterial)o.map&&!o.wireframe&&(o.map.mapping instanceof THREE.UVMapping&&(la=m.uvs[0],w(O,V,L,$,T,Q,o.map.image,la[f].u,la[f].v,
|
|
|
|
|
la[k].u,la[k].v,la[ha].u,la[ha].v)),d(THREE.SubtractiveBlending)),Sa?!o.wireframe&&o.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3?(P.r=W.r=X.r=ra.r,P.g=W.g=X.g=ra.g,P.b=W.b=X.b=ra.b,p(n,m.v1.positionWorld,m.vertexNormalsWorld[0],P),p(n,m.v2.positionWorld,m.vertexNormalsWorld[1],W),p(n,m.v3.positionWorld,m.vertexNormalsWorld[2],X),ea.r=(W.r+X.r)*0.5,ea.g=(W.g+X.g)*0.5,ea.b=(W.b+X.b)*0.5,da=Pa(P,W,X,ea),w(O,V,L,$,T,Q,da,0,0,1,0,0,1)):(sa.r=ra.r,sa.g=ra.g,sa.b=ra.b,p(n,m.centroidWorld,
|
|
|
|
|
m.normalWorld,sa),R.r=Math.max(0,Math.min(o.color.r*sa.r,1)),R.g=Math.max(0,Math.min(o.color.g*sa.g,1)),R.b=Math.max(0,Math.min(o.color.b*sa.b,1)),R.updateHex(),o.wireframe?B(R,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):D(R)):o.wireframe?B(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):D(o.color);else if(o instanceof THREE.MeshDepthMaterial)ia=h.near,J=h.far,P.r=P.g=P.b=1-Ca(b.positionScreen.z,ia,J),W.r=W.g=W.b=1-Ca(g.positionScreen.z,ia,J),X.r=X.g=X.b=1-Ca(e.positionScreen.z,
|
|
|
|
|
ia,J),ea.r=(W.r+X.r)*0.5,ea.g=(W.g+X.g)*0.5,ea.b=(W.b+X.b)*0.5,da=Pa(P,W,X,ea),w(O,V,L,$,T,Q,da,0,0,1,0,0,1);else if(o instanceof THREE.MeshNormalMaterial)R.r=Ha(m.normalWorld.x),R.g=Ha(m.normalWorld.y),R.b=Ha(m.normalWorld.z),R.updateHex(),o.wireframe?B(R,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):D(R)}function C(b,g,e,f,k,ha,o,m,n){j.data.vertices+=4;j.data.faces++;c(m.opacity);d(m.blending);if(m.map||m.envMap)x(b,g,f,0,1,3,o,m,n),x(k,e,ha,1,2,3,o,m,n);else if(O=b.positionScreen.x,
|
|
|
|
|
V=b.positionScreen.y,L=g.positionScreen.x,$=g.positionScreen.y,T=e.positionScreen.x,Q=e.positionScreen.y,fa=f.positionScreen.x,U=f.positionScreen.y,ka=k.positionScreen.x,ga=k.positionScreen.y,ca=ha.positionScreen.x,aa=ha.positionScreen.y,m instanceof THREE.MeshBasicMaterial)I(O,V,L,$,T,Q,fa,U),m.wireframe?B(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):D(m.color);else if(m instanceof THREE.MeshLambertMaterial)Sa?!m.wireframe&&m.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==
|
|
|
|
|
4?(P.r=W.r=X.r=ea.r=ra.r,P.g=W.g=X.g=ea.g=ra.g,P.b=W.b=X.b=ea.b=ra.b,p(n,o.v1.positionWorld,o.vertexNormalsWorld[0],P),p(n,o.v2.positionWorld,o.vertexNormalsWorld[1],W),p(n,o.v4.positionWorld,o.vertexNormalsWorld[3],X),p(n,o.v3.positionWorld,o.vertexNormalsWorld[2],ea),da=Pa(P,W,X,ea),E(O,V,L,$,fa,U),w(O,V,L,$,fa,U,da,0,0,1,0,0,1),E(ka,ga,T,Q,ca,aa),w(ka,ga,T,Q,ca,aa,da,1,0,1,1,0,1)):(sa.r=ra.r,sa.g=ra.g,sa.b=ra.b,p(n,o.centroidWorld,o.normalWorld,sa),R.r=Math.max(0,Math.min(m.color.r*sa.r,1)),R.g=
|
|
|
|
|
Math.max(0,Math.min(m.color.g*sa.g,1)),R.b=Math.max(0,Math.min(m.color.b*sa.b,1)),R.updateHex(),I(O,V,L,$,T,Q,fa,U),m.wireframe?B(R,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):D(R)):(I(O,V,L,$,T,Q,fa,U),m.wireframe?B(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):D(m.color));else if(m instanceof THREE.MeshNormalMaterial)R.r=Ha(o.normalWorld.x),R.g=Ha(o.normalWorld.y),R.b=Ha(o.normalWorld.z),R.updateHex(),I(O,V,L,$,T,Q,fa,U),m.wireframe?B(R,m.wireframeLinewidth,
|
|
|
|
|
m.wireframeLinecap,m.wireframeLinejoin):D(R);else if(m instanceof THREE.MeshDepthMaterial)ia=h.near,J=h.far,P.r=P.g=P.b=1-Ca(b.positionScreen.z,ia,J),W.r=W.g=W.b=1-Ca(g.positionScreen.z,ia,J),X.r=X.g=X.b=1-Ca(f.positionScreen.z,ia,J),ea.r=ea.g=ea.b=1-Ca(e.positionScreen.z,ia,J),da=Pa(P,W,X,ea),E(O,V,L,$,fa,U),w(O,V,L,$,fa,U,da,0,0,1,0,0,1),E(ka,ga,T,Q,ca,aa),w(ka,ga,T,Q,ca,aa,da,1,0,1,1,0,1)}function E(b,d,c,g,e,h){v.beginPath();v.moveTo(b,d);v.lineTo(c,g);v.lineTo(e,h);v.lineTo(b,d);v.closePath()}
|
|
|
|
|
function I(b,d,c,g,e,h,f,j){v.beginPath();v.moveTo(b,d);v.lineTo(c,g);v.lineTo(e,h);v.lineTo(f,j);v.lineTo(b,d);v.closePath()}function B(b,d,c,g){if(A!=d)v.lineWidth=A=d;if(z!=c)v.lineCap=z=c;if(S!=g)v.lineJoin=S=g;e(b);v.stroke();pa.inflate(d*2)}function D(b){f(b);v.fill()}function w(b,d,c,g,e,h,f,j,k,m,ha,o,p){var n,t;n=f.width-1;t=f.height-1;j*=n;k*=t;m*=n;ha*=t;o*=n;p*=t;c-=b;g-=d;e-=b;h-=d;m-=j;ha-=k;o-=j;p-=k;n=m*p-o*ha;n!=0&&(t=1/n,n=(p*c-ha*e)*t,ha=(p*g-ha*h)*t,c=(m*e-o*c)*t,g=(m*h-o*g)*t,
|
|
|
|
|
b=b-n*j-c*k,d=d-ha*j-g*k,v.save(),v.transform(n,ha,c,g,b,d),v.clip(),v.drawImage(f,0,0),v.restore())}function Pa(b,d,c,g){var e=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),f=~~(d.r*255),j=~~(d.g*255),d=~~(d.b*255),k=~~(c.r*255),m=~~(c.g*255),c=~~(c.b*255),ha=~~(g.r*255),o=~~(g.g*255),g=~~(g.b*255);ta[0]=e<0?0:e>255?255:e;ta[1]=h<0?0:h>255?255:h;ta[2]=b<0?0:b>255?255:b;ta[4]=f<0?0:f>255?255:f;ta[5]=j<0?0:j>255?255:j;ta[6]=d<0?0:d>255?255:d;ta[8]=k<0?0:k>255?255:k;ta[9]=m<0?0:m>255?255:m;ta[10]=c<0?0:c>
|
|
|
|
|
255?255:c;ta[12]=ha<0?0:ha>255?255:ha;ta[13]=o<0?0:o>255?255:o;ta[14]=g<0?0:g>255?255:g;Ka.putImageData(Ta,0,0);Oa.drawImage(Ja,0,0);return La}function Ca(b,d,c){b=(b-d)/(c-d);return b*b*(3-2*b)}function Ha(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function za(b,d){var c=d.x-b.x,g=d.y-b.y,e=1/Math.sqrt(c*c+g*g);c*=e;g*=e;d.x+=c;d.y+=g;b.x-=c;b.y-=g}var Qa,Ya,ja,ua,Aa,Ia,Ra,H;this.autoClear?this.clear():v.setTransform(1,0,0,-1,t,u);j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,h,this.sortElements);
|
|
|
|
|
(Sa=b.lights.length>0)&&o(b);Qa=0;for(Ya=k.length;Qa<Ya;Qa++){ja=k[Qa];pa.empty();if(ja instanceof THREE.RenderableParticle){G=ja;G.x*=t;G.y*=u;ua=0;for(Aa=ja.materials.length;ua<Aa;)H=ja.materials[ua++],H.opacity!=0&&n(G,ja,H,b)}else if(ja instanceof THREE.RenderableLine){if(G=ja.v1,M=ja.v2,G.positionScreen.x*=t,G.positionScreen.y*=u,M.positionScreen.x*=t,M.positionScreen.y*=u,pa.addPoint(G.positionScreen.x,G.positionScreen.y),pa.addPoint(M.positionScreen.x,M.positionScreen.y),qa.instersects(pa)){ua=
|
|
|
|
|
0;for(Aa=ja.materials.length;ua<Aa;)H=ja.materials[ua++],H.opacity!=0&&y(G,M,ja,H,b)}}else if(ja instanceof THREE.RenderableFace3){if(G=ja.v1,M=ja.v2,F=ja.v3,G.positionScreen.x*=t,G.positionScreen.y*=u,M.positionScreen.x*=t,M.positionScreen.y*=u,F.positionScreen.x*=t,F.positionScreen.y*=u,ja.overdraw&&(za(G.positionScreen,M.positionScreen),za(M.positionScreen,F.positionScreen),za(F.positionScreen,G.positionScreen)),pa.add3Points(G.positionScreen.x,G.positionScreen.y,M.positionScreen.x,M.positionScreen.y,
|
|
|
|
|
F.positionScreen.x,F.positionScreen.y),qa.instersects(pa)){ua=0;for(Aa=ja.meshMaterials.length;ua<Aa;)if(H=ja.meshMaterials[ua++],H instanceof THREE.MeshFaceMaterial){Ia=0;for(Ra=ja.faceMaterials.length;Ia<Ra;)(H=ja.faceMaterials[Ia++])&&H.opacity!=0&&x(G,M,F,0,1,2,ja,H,b)}else H.opacity!=0&&x(G,M,F,0,1,2,ja,H,b)}}else if(ja instanceof THREE.RenderableFace4&&(G=ja.v1,M=ja.v2,F=ja.v3,N=ja.v4,G.positionScreen.x*=t,G.positionScreen.y*=u,M.positionScreen.x*=t,M.positionScreen.y*=u,F.positionScreen.x*=
|
|
|
|
|
t,F.positionScreen.y*=u,N.positionScreen.x*=t,N.positionScreen.y*=u,g.positionScreen.copy(M.positionScreen),Y.positionScreen.copy(N.positionScreen),ja.overdraw&&(za(G.positionScreen,M.positionScreen),za(M.positionScreen,N.positionScreen),za(N.positionScreen,G.positionScreen),za(F.positionScreen,g.positionScreen),za(F.positionScreen,Y.positionScreen)),pa.addPoint(G.positionScreen.x,G.positionScreen.y),pa.addPoint(M.positionScreen.x,M.positionScreen.y),pa.addPoint(F.positionScreen.x,F.positionScreen.y),
|
|
|
|
|
pa.addPoint(N.positionScreen.x,N.positionScreen.y),qa.instersects(pa))){ua=0;for(Aa=ja.meshMaterials.length;ua<Aa;)if(H=ja.meshMaterials[ua++],H instanceof THREE.MeshFaceMaterial){Ia=0;for(Ra=ja.faceMaterials.length;Ia<Ra;)(H=ja.faceMaterials[Ia++])&&H.opacity!=0&&C(G,M,F,N,g,Y,ja,H,b)}else H.opacity!=0&&C(G,M,F,N,g,Y,ja,H,b)}ha.addRectangle(pa)}v.setTransform(1,0,0,1,0,0)}};
|
|
|
|
|
THREE.SVGRenderer=function(){function b(b,d,c){var g,e,h,f;g=0;for(e=b.lights.length;g<e;g++)h=b.lights[g],h instanceof THREE.DirectionalLight?(f=d.normalWorld.dot(h.position)*h.intensity,f>0&&(c.r+=h.color.r*f,c.g+=h.color.g*f,c.b+=h.color.b*f)):h instanceof THREE.PointLight&&(N.sub(h.position,d.centroidWorld),N.normalize(),f=d.normalWorld.dot(N)*h.intensity,f>0&&(c.r+=h.color.r*f,c.g+=h.color.g*f,c.b+=h.color.b*f))}function c(d,c,g,k,m,p){j.data.vertices+=3;j.data.faces++;O=e(V++);O.setAttribute("d",
|
|
|
|
|
"M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+g.positionScreen.x+","+g.positionScreen.y+"z");m instanceof THREE.MeshBasicMaterial?A.hex=m.color.hex:m instanceof THREE.MeshLambertMaterial?I?(z.r=S.r,z.g=S.g,z.b=S.b,b(p,k,z),A.r=Math.max(0,Math.min(m.color.r*z.r,1)),A.g=Math.max(0,Math.min(m.color.g*z.g,1)),A.b=Math.max(0,Math.min(m.color.b*z.b,1)),A.updateHex()):A.hex=m.color.hex:m instanceof THREE.MeshDepthMaterial?(F=1-m.__2near/(m.__farPlusNear-
|
|
|
|
|
k.z*m.__farMinusNear),A.setRGB(F,F,F)):m instanceof THREE.MeshNormalMaterial&&A.setRGB(f(k.normalWorld.x),f(k.normalWorld.y),f(k.normalWorld.z));m.wireframe?O.setAttribute("style","fill: none; stroke: #"+h(A.hex.toString(16))+"; stroke-width: "+m.wireframeLinewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframeLinecap+"; stroke-linejoin: "+m.wireframeLinejoin):O.setAttribute("style","fill: #"+h(A.hex.toString(16))+"; fill-opacity: "+m.opacity);o.appendChild(O)}function d(d,c,g,k,
|
|
|
|
|
m,p,n){j.data.vertices+=4;j.data.faces++;O=e(V++);O.setAttribute("d","M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+g.positionScreen.x+","+g.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?A.hex=p.color.hex:p instanceof THREE.MeshLambertMaterial?I?(z.r=S.r,z.g=S.g,z.b=S.b,b(n,m,z),A.r=Math.max(0,Math.min(p.color.r*z.r,1)),A.g=Math.max(0,Math.min(p.color.g*z.g,1)),A.b=Math.max(0,Math.min(p.color.b*
|
|
|
|
|
z.b,1)),A.updateHex()):A.hex=p.color.hex:p instanceof THREE.MeshDepthMaterial?(F=1-p.__2near/(p.__farPlusNear-m.z*p.__farMinusNear),A.setRGB(F,F,F)):p instanceof THREE.MeshNormalMaterial&&A.setRGB(f(m.normalWorld.x),f(m.normalWorld.y),f(m.normalWorld.z));p.wireframe?O.setAttribute("style","fill: none; stroke: #"+h(A.hex.toString(16))+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):O.setAttribute("style",
|
|
|
|
|
"fill: #"+h(A.hex.toString(16))+"; fill-opacity: "+p.opacity);o.appendChild(O)}function e(b){g[b]==null&&(g[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),$==0&&g[b].setAttribute("shape-rendering","crispEdges"));return g[b]}function f(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function h(b){for(;b.length<6;)b="0"+b;return b}var j=this,k=null,m=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,p,t,u,v,C,E,y,D=new THREE.Rectangle,x=new THREE.Rectangle,I=
|
|
|
|
|
!1,A=new THREE.Color(16777215),z=new THREE.Color(16777215),S=new THREE.Color(0),G=new THREE.Color(0),M=new THREE.Color(0),F,N=new THREE.Vector3,g=[],Y=[],O,V,L,$=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":$=1;break;case "low":$=0}};this.setSize=function(b,d){n=b;p=d;t=n/2;u=p/2;o.setAttribute("viewBox",-t+" "+-u+" "+n+" "+p);o.setAttribute("width",n);o.setAttribute("height",p);D.set(-t,-u,
|
|
|
|
|
t,u)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(b,g){var e,f,p,n,z,A,F,P;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,g,this.sortElements);L=V=0;if(I=b.lights.length>0){F=b.lights;S.setRGB(0,0,0);G.setRGB(0,0,0);M.setRGB(0,0,0);e=0;for(f=F.length;e<f;e++)p=F[e],n=p.color,p instanceof THREE.AmbientLight?(S.r+=n.r,S.g+=n.g,S.b+=n.b):p instanceof THREE.DirectionalLight?(G.r+=n.r,G.g+=n.g,G.b+=n.b):p instanceof
|
|
|
|
|
THREE.PointLight&&(M.r+=n.r,M.g+=n.g,M.b+=n.b)}e=0;for(f=k.length;e<f;e++)if(F=k[e],x.empty(),F instanceof THREE.RenderableParticle){v=F;v.x*=t;v.y*=-u;p=0;for(n=F.materials.length;p<n;)p++}else if(F instanceof THREE.RenderableLine){if(v=F.v1,C=F.v2,v.positionScreen.x*=t,v.positionScreen.y*=-u,C.positionScreen.x*=t,C.positionScreen.y*=-u,x.addPoint(v.positionScreen.x,v.positionScreen.y),x.addPoint(C.positionScreen.x,C.positionScreen.y),D.instersects(x)){p=0;for(n=F.materials.length;p<n;)if((P=F.materials[p++])&&
|
|
|
|
|
P.opacity!=0){z=v;A=C;var N=L++;Y[N]==null&&(Y[N]=document.createElementNS("http://www.w3.org/2000/svg","line"),$==0&&Y[N].setAttribute("shape-rendering","crispEdges"));O=Y[N];O.setAttribute("x1",z.positionScreen.x);O.setAttribute("y1",z.positionScreen.y);O.setAttribute("x2",A.positionScreen.x);O.setAttribute("y2",A.positionScreen.y);P instanceof THREE.LineBasicMaterial&&(O.setAttribute("style","fill: none; stroke: ##"+h(P.color.hex.toString(16))+"; stroke-width: "+P.linewidth+"; stroke-opacity: "+
|
|
|
|
|
P.opacity+"; stroke-linecap: "+P.linecap+"; stroke-linejoin: "+P.linejoin),o.appendChild(O))}}}else if(F instanceof THREE.RenderableFace3){if(v=F.v1,C=F.v2,E=F.v3,v.positionScreen.x*=t,v.positionScreen.y*=-u,C.positionScreen.x*=t,C.positionScreen.y*=-u,E.positionScreen.x*=t,E.positionScreen.y*=-u,x.addPoint(v.positionScreen.x,v.positionScreen.y),x.addPoint(C.positionScreen.x,C.positionScreen.y),x.addPoint(E.positionScreen.x,E.positionScreen.y),D.instersects(x)){p=0;for(n=F.meshMaterials.length;p<
|
|
|
|
|
n;)if(P=F.meshMaterials[p++],P instanceof THREE.MeshFaceMaterial){z=0;for(A=F.faceMaterials.length;z<A;)(P=F.faceMaterials[z++])&&P.opacity!=0&&c(v,C,E,F,P,b)}else P&&P.opacity!=0&&c(v,C,E,F,P,b)}}else if(F instanceof THREE.RenderableFace4&&(v=F.v1,C=F.v2,E=F.v3,y=F.v4,v.positionScreen.x*=t,v.positionScreen.y*=-u,C.positionScreen.x*=t,C.positionScreen.y*=-u,E.positionScreen.x*=t,E.positionScreen.y*=-u,y.positionScreen.x*=t,y.positionScreen.y*=-u,x.addPoint(v.positionScreen.x,v.positionScreen.y),x.addPoint(C.positionScreen.x,
|
|
|
|
|
C.positionScreen.y),x.addPoint(E.positionScreen.x,E.positionScreen.y),x.addPoint(y.positionScreen.x,y.positionScreen.y),D.instersects(x))){p=0;for(n=F.meshMaterials.length;p<n;)if(P=F.meshMaterials[p++],P instanceof THREE.MeshFaceMaterial){z=0;for(A=F.faceMaterials.length;z<A;)(P=F.faceMaterials[z++])&&P.opacity!=0&&d(v,C,E,y,F,P,b)}else P&&P.opacity!=0&&d(v,C,E,y,F,P,b)}}};
|
|
|
|
|
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(b,c,e){this.color=new THREE.Color(b);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(b,c){this.color=new THREE.Color(b);this.density=c!==void 0?c:2.5E-4};
|
|
|
|
|
THREE.Projector=function(){function b(){var b=n[m]=n[m]||new THREE.RenderableVertex;m++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,j=b.z+b.w,g=e.z+e.w,k=-b.z+b.w,m=-e.z+e.w;return j>=0&&g>=0&&k>=0&&m>=0?!0:j<0&&g<0||k<0&&m<0?!1:(j<0?c=Math.max(c,j/(j-g)):g<0&&(f=Math.min(f,j/(j-g))),k<0?c=Math.max(c,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),f<c?!1:(b.lerpSelf(e,c),e.lerpSelf(b,1-f),!0))}var f,g,j=[],k,m,n=[],p,o,t=[],u,v=[],w,E,H=[],B,K,A=[],I=new THREE.Vector4,G=new THREE.Vector4,
|
|
|
|
|
C=new THREE.Matrix4,R=new THREE.Matrix4,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Vector4,J=new THREE.Vector4;this.projectVector=function(b,e){C.multiply(e.projectionMatrix,e.matrixWorldInverse);C.multiplyVector3(b);return b};this.unprojectVector=function(b,e){C.multiply(e.matrixWorld,THREE.Matrix4.makeInvert(e.projectionMatrix));C.multiplyVector3(b);return b};this.projectObjects=function(b,e,k){var e=[],m,n,p;g=0;n=
|
|
|
|
|
b.objects;b=0;for(m=n.length;b<m;b++){p=n[b];var t;if(!(t=!p.visible))if(t=p instanceof THREE.Mesh){a:{t=void 0;for(var o=p.matrixWorld,u=-p.geometry.boundingSphere.radius*Math.max(p.scale.x,Math.max(p.scale.y,p.scale.z)),v=0;v<6;v++)if(t=D[v].x*o.n14+D[v].y*o.n24+D[v].z*o.n34+D[v].w,t<=u){t=!1;break a}t=!0}t=!t}if(!t)t=j[g]=j[g]||new THREE.RenderableObject,g++,f=t,I.copy(p.position),C.multiplyVector3(I),f.object=p,f.z=I.z,e.push(f)}k&&e.sort(c);return e};this.projectScene=function(f,h,j){var g=[],
|
|
|
|
|
I=h.near,M=h.far,da,U,S,ja,W,ga,Y,ha,fa,Q,T,Z,ka,na,ca,ma,ia;K=E=u=o=0;h.matrixAutoUpdate&&h.update(void 0,!0);f.update(void 0,!1,h);C.multiply(h.projectionMatrix,h.matrixWorldInverse);D[0].set(C.n41-C.n11,C.n42-C.n12,C.n43-C.n13,C.n44-C.n14);D[1].set(C.n41+C.n11,C.n42+C.n12,C.n43+C.n13,C.n44+C.n14);D[2].set(C.n41+C.n21,C.n42+C.n22,C.n43+C.n23,C.n44+C.n24);D[3].set(C.n41-C.n21,C.n42-C.n22,C.n43-C.n23,C.n44-C.n24);D[4].set(C.n41-C.n31,C.n42-C.n32,C.n43-C.n33,C.n44-C.n34);D[5].set(C.n41+C.n31,C.n42+
|
|
|
|
|
C.n32,C.n43+C.n33,C.n44+C.n34);for(da=0;da<6;da++)fa=D[da],fa.divideScalar(Math.sqrt(fa.x*fa.x+fa.y*fa.y+fa.z*fa.z));fa=this.projectObjects(f,h,!0);f=0;for(da=fa.length;f<da;f++)if(Q=fa[f].object,Q.visible)if(T=Q.matrixWorld,Z=Q.matrixRotationWorld,ka=Q.materials,na=Q.overdraw,m=0,Q instanceof THREE.Mesh){ca=Q.geometry;ja=ca.vertices;ma=ca.faces;ca=ca.faceVertexUvs;U=0;for(S=ja.length;U<S;U++)k=b(),k.positionWorld.copy(ja[U].position),T.multiplyVector3(k.positionWorld),k.positionScreen.copy(k.positionWorld),
|
|
|
|
|
C.multiplyVector4(k.positionScreen),k.positionScreen.x/=k.positionScreen.w,k.positionScreen.y/=k.positionScreen.w,k.visible=k.positionScreen.z>I&&k.positionScreen.z<M;ja=0;for(U=ma.length;ja<U;ja++){S=ma[ja];if(S instanceof THREE.Face3)if(W=n[S.a],ga=n[S.b],Y=n[S.c],W.visible&&ga.visible&&Y.visible&&(Q.doubleSided||Q.flipSided!=(Y.positionScreen.x-W.positionScreen.x)*(ga.positionScreen.y-W.positionScreen.y)-(Y.positionScreen.y-W.positionScreen.y)*(ga.positionScreen.x-W.positionScreen.x)<0))ha=t[o]=
|
|
|
|
|
t[o]||new THREE.RenderableFace3,o++,p=ha,p.v1.copy(W),p.v2.copy(ga),p.v3.copy(Y);else continue;else if(S instanceof THREE.Face4)if(W=n[S.a],ga=n[S.b],Y=n[S.c],ha=n[S.d],W.visible&&ga.visible&&Y.visible&&ha.visible&&(Q.doubleSided||Q.flipSided!=((ha.positionScreen.x-W.positionScreen.x)*(ga.positionScreen.y-W.positionScreen.y)-(ha.positionScreen.y-W.positionScreen.y)*(ga.positionScreen.x-W.positionScreen.x)<0||(ga.positionScreen.x-Y.positionScreen.x)*(ha.positionScreen.y-Y.positionScreen.y)-(ga.positionScreen.y-
|
|
|
|
|
Y.positionScreen.y)*(ha.positionScreen.x-Y.positionScreen.x)<0)))ia=v[u]=v[u]||new THREE.RenderableFace4,u++,p=ia,p.v1.copy(W),p.v2.copy(ga),p.v3.copy(Y),p.v4.copy(ha);else continue;p.normalWorld.copy(S.normal);Z.multiplyVector3(p.normalWorld);p.centroidWorld.copy(S.centroid);T.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);C.multiplyVector3(p.centroidScreen);Y=S.vertexNormals;W=0;for(ga=Y.length;W<ga;W++)ha=p.vertexNormalsWorld[W],ha.copy(Y[W]),Z.multiplyVector3(ha);W=0;
|
|
|
|
|
for(ga=ca.length;W<ga;W++)if(ia=ca[W][ja]){Y=0;for(ha=ia.length;Y<ha;Y++)p.uvs[W][Y]=ia[Y]}p.meshMaterials=ka;p.faceMaterials=S.materials;p.overdraw=na;p.z=p.centroidScreen.z;g.push(p)}}else if(Q instanceof THREE.Line){R.multiply(C,T);ja=Q.geometry.vertices;W=b();W.positionScreen.copy(ja[0].position);R.multiplyVector4(W.positionScreen);U=1;for(S=ja.length;U<S;U++)if(W=b(),W.positionScreen.copy(ja[U].position),R.multiplyVector4(W.positionScreen),ga=n[m-2],N.copy(W.positionScreen),J.copy(ga.positionScreen),
|
|
|
|
|
e(N,J))N.multiplyScalar(1/N.w),J.multiplyScalar(1/J.w),T=H[E]=H[E]||new THREE.RenderableLine,E++,w=T,w.v1.positionScreen.copy(N),w.v2.positionScreen.copy(J),w.z=Math.max(N.z,J.z),w.materials=Q.materials,g.push(w)}else if(Q instanceof THREE.Particle&&(G.set(Q.matrixWorld.n14,Q.matrixWorld.n24,Q.matrixWorld.n34,1),C.multiplyVector4(G),G.z/=G.w,G.z>0&&G.z<1))T=A[K]=A[K]||new THREE.RenderableParticle,K++,B=T,B.x=G.x/G.w,B.y=G.y/G.w,B.z=G.z,B.rotation=Q.rotation.z,B.scale.x=Q.scale.x*Math.abs(B.x-(G.x+
|
|
|
|
|
h.projectionMatrix.n11)/(G.w+h.projectionMatrix.n14)),B.scale.y=Q.scale.y*Math.abs(B.y-(G.y+h.projectionMatrix.n22)/(G.w+h.projectionMatrix.n24)),B.materials=Q.materials,g.push(B);j&&g.sort(c);return g}};
|
|
|
|
|
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;j=f/2};this.render=function(e,f){var n,p,o,t,u,v,w,E;b=c.projectScene(e,f);n=0;for(p=b.length;n<p;n++)if(u=b[n],u instanceof THREE.RenderableParticle){w=u.x*g+g;E=u.y*j+j;o=0;for(t=u.material.length;o<t;o++)if(v=u.material[o],v instanceof THREE.ParticleDOMMaterial)v=v.domElement,v.style.left=w+"px",v.style.top=E+"px"}}};
|
|
|
|
|
THREE.CanvasRenderer=function(b){function c(b){if(B!=b)w.globalAlpha=B=b}function e(b){if(K!=b){switch(b){case THREE.NormalBlending:w.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:w.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:w.globalCompositeOperation="darker"}K=b}}function f(b){if(A!=b.hex)A=b.hex,w.strokeStyle="#"+j(A.toString(16))}function g(b){if(I!=b.hex)I=b.hex,w.fillStyle="#"+j(I.toString(16))}function j(b){for(;b.length<6;)b="0"+b;return b}
|
|
|
|
|
var k=this,m=null,n=new THREE.Projector,b=b||{},p=b.canvas!==void 0?b.canvas:document.createElement("canvas"),o,t,u,v,w=p.getContext("2d"),E=new THREE.Color(0),H=0,B=1,K=0,A=null,I=null,G=null,C=null,R=null,D,N,J,V,h=new THREE.RenderableVertex,X=new THREE.RenderableVertex,O,aa,M,da,U,S,ja,W,ga,Y,ha,fa,Q=new THREE.Color(0),T=new THREE.Color(0),Z=new THREE.Color(0),ka=new THREE.Color(0),na=new THREE.Color(0),ca,ma,ia,pa,la,Ba,ya,ea,P,za,ta=new THREE.Rectangle,$=new THREE.Rectangle,sa=new THREE.Rectangle,
|
|
|
|
|
Va=!1,va=new THREE.Color,ua=new THREE.Color,Pa=new THREE.Color,Qa=new THREE.Color,qa=new THREE.Vector3,Ma,Na,Wa,wa,Oa,Ra,b=16;Ma=document.createElement("canvas");Ma.width=Ma.height=2;Na=Ma.getContext("2d");Na.fillStyle="rgba(0,0,0,1)";Na.fillRect(0,0,2,2);Wa=Na.getImageData(0,0,2,2);wa=Wa.data;Oa=document.createElement("canvas");Oa.width=Oa.height=b;Ra=Oa.getContext("2d");Ra.translate(-b/2,-b/2);Ra.scale(b,b);b--;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,
|
|
|
|
|
faces:0};this.setSize=function(b,e){o=b;t=e;u=o/2;v=t/2;p.width=o;p.height=t;ta.set(-u,-v,u,v);B=1;K=0;R=C=G=I=A=null};this.setClearColor=function(b,e){E=b;H=e};this.setClearColorHex=function(b,e){E.setHex(b);H=e};this.clear=function(){w.setTransform(1,0,0,-1,u,v);if(!$.isEmpty())$.inflate(1),$.minSelf(ta),E.hex==0&&H==0?w.clearRect($.getX(),$.getY(),$.getWidth(),$.getHeight()):(e(THREE.NormalBlending),c(1),w.fillStyle="rgba("+Math.floor(E.r*255)+","+Math.floor(E.g*255)+","+Math.floor(E.b*255)+","+
|
|
|
|
|
H+")",w.fillRect($.getX(),$.getY(),$.getWidth(),$.getHeight())),$.empty()};this.render=function(b,j){function p(b){var e,c,f,h=b.lights;ua.setRGB(0,0,0);Pa.setRGB(0,0,0);Qa.setRGB(0,0,0);b=0;for(e=h.length;b<e;b++)c=h[b],f=c.color,c instanceof THREE.AmbientLight?(ua.r+=f.r,ua.g+=f.g,ua.b+=f.b):c instanceof THREE.DirectionalLight?(Pa.r+=f.r,Pa.g+=f.g,Pa.b+=f.b):c instanceof THREE.PointLight&&(Qa.r+=f.r,Qa.g+=f.g,Qa.b+=f.b)}function t(b,e,c,f){var h,j,g,k,m=b.lights,b=0;for(h=m.length;b<h;b++)j=m[b],
|
|
|
|
|
g=j.color,j instanceof THREE.DirectionalLight?(k=c.dot(j.position),k<=0||(k*=j.intensity,f.r+=g.r*k,f.g+=g.g*k,f.b+=g.b*k)):j instanceof THREE.PointLight&&(k=c.dot(qa.sub(j.position,e).normalize()),k<=0||(k*=j.distance==0?1:1-Math.min(e.distanceTo(j.position)/j.distance,1),k!=0&&(k*=j.intensity,f.r+=g.r*k,f.g+=g.g*k,f.b+=g.b*k)))}function o(b,h,j){c(j.opacity);e(j.blending);var k,m,$,n,p,t;if(j instanceof THREE.ParticleBasicMaterial){if(j.map)n=j.map.image,p=n.width>>1,t=n.height>>1,j=h.scale.x*u,
|
|
|
|
|
$=h.scale.y*v,k=j*p,m=$*t,sa.set(b.x-k,b.y-m,b.x+k,b.y+m),ta.instersects(sa)&&(w.save(),w.translate(b.x,b.y),w.rotate(-h.rotation),w.scale(j,-$),w.translate(-p,-t),w.drawImage(n,0,0),w.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*u,m=h.scale.y*v,sa.set(b.x-k,b.y-m,b.x+k,b.y+m),ta.instersects(sa)&&(f(j.color),g(j.color),w.save(),w.translate(b.x,b.y),w.rotate(-h.rotation),w.scale(k,m),j.program(w),w.restore()))}function B(b,h,j,g){c(g.opacity);e(g.blending);w.beginPath();
|
|
|
|
|
w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(h.positionScreen.x,h.positionScreen.y);w.closePath();if(g instanceof THREE.LineBasicMaterial){b=g.linewidth;if(G!=b)w.lineWidth=G=b;b=g.linecap;if(C!=b)w.lineCap=C=b;b=g.linejoin;if(R!=b)w.lineJoin=R=b;f(g.color);w.stroke();sa.inflate(g.linewidth*2)}}function A(b,f,h,g,m,$,n,p,o){k.data.vertices+=3;k.data.faces++;c(p.opacity);e(p.blending);O=b.positionScreen.x;aa=b.positionScreen.y;M=f.positionScreen.x;da=f.positionScreen.y;U=h.positionScreen.x;
|
|
|
|
|
S=h.positionScreen.y;H(O,aa,M,da,U,S);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(pa=n.uvs[0],z(O,aa,M,da,U,S,p.map.image,pa[g].u,pa[g].v,pa[m].u,pa[m].v,pa[$].u,pa[$].v));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=j.matrixWorldInverse,qa.copy(n.vertexNormalsWorld[0]),la=(qa.x*b.n11+qa.y*b.n12+qa.z*b.n13)*0.5+0.5,Ba=-(qa.x*b.n21+qa.y*b.n22+qa.z*b.n23)*0.5+0.5,qa.copy(n.vertexNormalsWorld[1]),ya=(qa.x*b.n11+qa.y*
|
|
|
|
|
b.n12+qa.z*b.n13)*0.5+0.5,ea=-(qa.x*b.n21+qa.y*b.n22+qa.z*b.n23)*0.5+0.5,qa.copy(n.vertexNormalsWorld[2]),P=(qa.x*b.n11+qa.y*b.n12+qa.z*b.n13)*0.5+0.5,za=-(qa.x*b.n21+qa.y*b.n22+qa.z*b.n23)*0.5+0.5,z(O,aa,M,da,U,S,p.envMap.image,la,Ba,ya,ea,P,za)}else p.wireframe?F(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):I(p.color);else if(p instanceof THREE.MeshLambertMaterial)p.map&&!p.wireframe&&(p.map.mapping instanceof THREE.UVMapping&&(pa=n.uvs[0],z(O,aa,M,da,U,S,p.map.image,pa[g].u,
|
|
|
|
|
pa[g].v,pa[m].u,pa[m].v,pa[$].u,pa[$].v)),e(THREE.SubtractiveBlending)),Va?!p.wireframe&&p.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==3?(T.r=Z.r=ka.r=ua.r,T.g=Z.g=ka.g=ua.g,T.b=Z.b=ka.b=ua.b,t(o,n.v1.positionWorld,n.vertexNormalsWorld[0],T),t(o,n.v2.positionWorld,n.vertexNormalsWorld[1],Z),t(o,n.v3.positionWorld,n.vertexNormalsWorld[2],ka),na.r=(Z.r+ka.r)*0.5,na.g=(Z.g+ka.g)*0.5,na.b=(Z.b+ka.b)*0.5,ia=Sa(T,Z,ka,na),z(O,aa,M,da,U,S,ia,0,0,1,0,0,1)):(va.r=ua.r,va.g=ua.g,va.b=ua.b,t(o,
|
|
|
|
|
n.centroidWorld,n.normalWorld,va),Q.r=Math.max(0,Math.min(p.color.r*va.r,1)),Q.g=Math.max(0,Math.min(p.color.g*va.g,1)),Q.b=Math.max(0,Math.min(p.color.b*va.b,1)),Q.updateHex(),p.wireframe?F(Q,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):I(Q)):p.wireframe?F(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):I(p.color);else if(p instanceof THREE.MeshDepthMaterial)ca=j.near,ma=j.far,T.r=T.g=T.b=1-Fa(b.positionScreen.z,ca,ma),Z.r=Z.g=Z.b=1-Fa(f.positionScreen.z,ca,ma),
|
|
|
|
|
ka.r=ka.g=ka.b=1-Fa(h.positionScreen.z,ca,ma),na.r=(Z.r+ka.r)*0.5,na.g=(Z.g+ka.g)*0.5,na.b=(Z.b+ka.b)*0.5,ia=Sa(T,Z,ka,na),z(O,aa,M,da,U,S,ia,0,0,1,0,0,1);else if(p instanceof THREE.MeshNormalMaterial)Q.r=Ka(n.normalWorld.x),Q.g=Ka(n.normalWorld.y),Q.b=Ka(n.normalWorld.z),Q.updateHex(),p.wireframe?F(Q,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):I(Q)}function E(b,f,h,g,m,p,n,$,o){k.data.vertices+=4;k.data.faces++;c($.opacity);e($.blending);if($.map||$.envMap)A(b,f,g,0,1,3,n,$,o),A(m,
|
|
|
|
|
h,p,1,2,3,n,$,o);else if(O=b.positionScreen.x,aa=b.positionScreen.y,M=f.positionScreen.x,da=f.positionScreen.y,U=h.positionScreen.x,S=h.positionScreen.y,ja=g.positionScreen.x,W=g.positionScreen.y,ga=m.positionScreen.x,Y=m.positionScreen.y,ha=p.positionScreen.x,fa=p.positionScreen.y,$ instanceof THREE.MeshBasicMaterial)K(O,aa,M,da,U,S,ja,W),$.wireframe?F($.color,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):I($.color);else if($ instanceof THREE.MeshLambertMaterial)Va?!$.wireframe&&$.shading==
|
|
|
|
|
THREE.SmoothShading&&n.vertexNormalsWorld.length==4?(T.r=Z.r=ka.r=na.r=ua.r,T.g=Z.g=ka.g=na.g=ua.g,T.b=Z.b=ka.b=na.b=ua.b,t(o,n.v1.positionWorld,n.vertexNormalsWorld[0],T),t(o,n.v2.positionWorld,n.vertexNormalsWorld[1],Z),t(o,n.v4.positionWorld,n.vertexNormalsWorld[3],ka),t(o,n.v3.positionWorld,n.vertexNormalsWorld[2],na),ia=Sa(T,Z,ka,na),H(O,aa,M,da,ja,W),z(O,aa,M,da,ja,W,ia,0,0,1,0,0,1),H(ga,Y,U,S,ha,fa),z(ga,Y,U,S,ha,fa,ia,1,0,1,1,0,1)):(va.r=ua.r,va.g=ua.g,va.b=ua.b,t(o,n.centroidWorld,n.normalWorld,
|
|
|
|
|
va),Q.r=Math.max(0,Math.min($.color.r*va.r,1)),Q.g=Math.max(0,Math.min($.color.g*va.g,1)),Q.b=Math.max(0,Math.min($.color.b*va.b,1)),Q.updateHex(),K(O,aa,M,da,U,S,ja,W),$.wireframe?F(Q,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):I(Q)):(K(O,aa,M,da,U,S,ja,W),$.wireframe?F($.color,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):I($.color));else if($ instanceof THREE.MeshNormalMaterial)Q.r=Ka(n.normalWorld.x),Q.g=Ka(n.normalWorld.y),Q.b=Ka(n.normalWorld.z),Q.updateHex(),
|
|
|
|
|
K(O,aa,M,da,U,S,ja,W),$.wireframe?F(Q,$.wireframeLinewidth,$.wireframeLinecap,$.wireframeLinejoin):I(Q);else if($ instanceof THREE.MeshDepthMaterial)ca=j.near,ma=j.far,T.r=T.g=T.b=1-Fa(b.positionScreen.z,ca,ma),Z.r=Z.g=Z.b=1-Fa(f.positionScreen.z,ca,ma),ka.r=ka.g=ka.b=1-Fa(g.positionScreen.z,ca,ma),na.r=na.g=na.b=1-Fa(h.positionScreen.z,ca,ma),ia=Sa(T,Z,ka,na),H(O,aa,M,da,ja,W),z(O,aa,M,da,ja,W,ia,0,0,1,0,0,1),H(ga,Y,U,S,ha,fa),z(ga,Y,U,S,ha,fa,ia,1,0,1,1,0,1)}function H(b,e,c,f,h,j){w.beginPath();
|
|
|
|
|
w.moveTo(b,e);w.lineTo(c,f);w.lineTo(h,j);w.lineTo(b,e);w.closePath()}function K(b,e,c,f,h,j,g,k){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(h,j);w.lineTo(g,k);w.lineTo(b,e);w.closePath()}function F(b,e,c,h){if(G!=e)w.lineWidth=G=e;if(C!=c)w.lineCap=C=c;if(R!=h)w.lineJoin=R=h;f(b);w.stroke();sa.inflate(e*2)}function I(b){g(b);w.fill()}function z(b,e,c,f,h,j,g,k,m,$,n,p,t){var o,u;o=g.width-1;u=g.height-1;k*=o;m*=u;$*=o;n*=u;p*=o;t*=u;c-=b;f-=e;h-=b;j-=e;$-=k;n-=m;p-=k;t-=m;o=$*t-p*n;o!=0&&
|
|
|
|
|
(u=1/o,o=(t*c-n*h)*u,n=(t*f-n*j)*u,c=($*h-p*c)*u,f=($*j-p*f)*u,b=b-o*k-c*m,e=e-n*k-f*m,w.save(),w.transform(o,n,c,f,b,e),w.clip(),w.drawImage(g,0,0),w.restore())}function Sa(b,e,c,f){var h=~~(b.r*255),j=~~(b.g*255),b=~~(b.b*255),g=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),$=~~(c.g*255),c=~~(c.b*255),n=~~(f.r*255),p=~~(f.g*255),f=~~(f.b*255);wa[0]=h<0?0:h>255?255:h;wa[1]=j<0?0:j>255?255:j;wa[2]=b<0?0:b>255?255:b;wa[4]=g<0?0:g>255?255:g;wa[5]=k<0?0:k>255?255:k;wa[6]=e<0?0:e>255?255:e;wa[8]=
|
|
|
|
|
m<0?0:m>255?255:m;wa[9]=$<0?0:$>255?255:$;wa[10]=c<0?0:c>255?255:c;wa[12]=n<0?0:n>255?255:n;wa[13]=p<0?0:p>255?255:p;wa[14]=f<0?0:f>255?255:f;Na.putImageData(Wa,0,0);Ra.drawImage(Ma,0,0);return Oa}function Fa(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Ka(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ca(b,e){var c=e.x-b.x,f=e.y-b.y,h=1/Math.sqrt(c*c+f*f);c*=h;f*=h;e.x+=c;e.y+=f;b.x-=c;b.y-=f}var Ta,$a,oa,xa,Da,La,Ua,L;this.autoClear?this.clear():w.setTransform(1,0,0,-1,u,v);k.data.vertices=0;
|
|
|
|
|
k.data.faces=0;m=n.projectScene(b,j,this.sortElements);(Va=b.lights.length>0)&&p(b);Ta=0;for($a=m.length;Ta<$a;Ta++){oa=m[Ta];sa.empty();if(oa instanceof THREE.RenderableParticle){D=oa;D.x*=u;D.y*=v;xa=0;for(Da=oa.materials.length;xa<Da;)L=oa.materials[xa++],L.opacity!=0&&o(D,oa,L,b)}else if(oa instanceof THREE.RenderableLine){if(D=oa.v1,N=oa.v2,D.positionScreen.x*=u,D.positionScreen.y*=v,N.positionScreen.x*=u,N.positionScreen.y*=v,sa.addPoint(D.positionScreen.x,D.positionScreen.y),sa.addPoint(N.positionScreen.x,
|
|
|
|
|
N.positionScreen.y),ta.instersects(sa)){xa=0;for(Da=oa.materials.length;xa<Da;)L=oa.materials[xa++],L.opacity!=0&&B(D,N,oa,L,b)}}else if(oa instanceof THREE.RenderableFace3){if(D=oa.v1,N=oa.v2,J=oa.v3,D.positionScreen.x*=u,D.positionScreen.y*=v,N.positionScreen.x*=u,N.positionScreen.y*=v,J.positionScreen.x*=u,J.positionScreen.y*=v,oa.overdraw&&(Ca(D.positionScreen,N.positionScreen),Ca(N.positionScreen,J.positionScreen),Ca(J.positionScreen,D.positionScreen)),sa.add3Points(D.positionScreen.x,D.positionScreen.y,
|
|
|
|
|
N.positionScreen.x,N.positionScreen.y,J.positionScreen.x,J.positionScreen.y),ta.instersects(sa)){xa=0;for(Da=oa.meshMaterials.length;xa<Da;)if(L=oa.meshMaterials[xa++],L instanceof THREE.MeshFaceMaterial){La=0;for(Ua=oa.faceMaterials.length;La<Ua;)(L=oa.faceMaterials[La++])&&L.opacity!=0&&A(D,N,J,0,1,2,oa,L,b)}else L.opacity!=0&&A(D,N,J,0,1,2,oa,L,b)}}else if(oa instanceof THREE.RenderableFace4&&(D=oa.v1,N=oa.v2,J=oa.v3,V=oa.v4,D.positionScreen.x*=u,D.positionScreen.y*=v,N.positionScreen.x*=u,N.positionScreen.y*=
|
|
|
|
|
v,J.positionScreen.x*=u,J.positionScreen.y*=v,V.positionScreen.x*=u,V.positionScreen.y*=v,h.positionScreen.copy(N.positionScreen),X.positionScreen.copy(V.positionScreen),oa.overdraw&&(Ca(D.positionScreen,N.positionScreen),Ca(N.positionScreen,V.positionScreen),Ca(V.positionScreen,D.positionScreen),Ca(J.positionScreen,h.positionScreen),Ca(J.positionScreen,X.positionScreen)),sa.addPoint(D.positionScreen.x,D.positionScreen.y),sa.addPoint(N.positionScreen.x,N.positionScreen.y),sa.addPoint(J.positionScreen.x,
|
|
|
|
|
J.positionScreen.y),sa.addPoint(V.positionScreen.x,V.positionScreen.y),ta.instersects(sa))){xa=0;for(Da=oa.meshMaterials.length;xa<Da;)if(L=oa.meshMaterials[xa++],L instanceof THREE.MeshFaceMaterial){La=0;for(Ua=oa.faceMaterials.length;La<Ua;)(L=oa.faceMaterials[La++])&&L.opacity!=0&&E(D,N,J,V,h,X,oa,L,b)}else L.opacity!=0&&E(D,N,J,V,h,X,oa,L,b)}$.addRectangle(sa)}w.setTransform(1,0,0,1,0,0)}};
|
|
|
|
|
THREE.SVGRenderer=function(){function b(b,e,c){var f,h,j,g;f=0;for(h=b.lights.length;f<h;f++)j=b.lights[f],j instanceof THREE.DirectionalLight?(g=e.normalWorld.dot(j.position)*j.intensity,g>0&&(c.r+=j.color.r*g,c.g+=j.color.g*g,c.b+=j.color.b*g)):j instanceof THREE.PointLight&&(V.sub(j.position,e.centroidWorld),V.normalize(),g=e.normalWorld.dot(V)*j.intensity,g>0&&(c.r+=j.color.r*g,c.g+=j.color.g*g,c.b+=j.color.b*g))}function c(e,c,h,m,n,t){k.data.vertices+=3;k.data.faces++;O=f(aa++);O.setAttribute("d",
|
|
|
|
|
"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.hex=n.color.hex:n instanceof THREE.MeshLambertMaterial?I?(C.r=R.r,C.g=R.g,C.b=R.b,b(t,m,C),G.r=Math.max(0,Math.min(n.color.r*C.r,1)),G.g=Math.max(0,Math.min(n.color.g*C.g,1)),G.b=Math.max(0,Math.min(n.color.b*C.b,1)),G.updateHex()):G.hex=n.color.hex:n instanceof THREE.MeshDepthMaterial?(J=1-n.__2near/(n.__farPlusNear-
|
|
|
|
|
m.z*n.__farMinusNear),G.setRGB(J,J,J)):n instanceof THREE.MeshNormalMaterial&&G.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));n.wireframe?O.setAttribute("style","fill: none; stroke: #"+j(G.hex.toString(16))+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):O.setAttribute("style","fill: #"+j(G.hex.toString(16))+"; fill-opacity: "+n.opacity);p.appendChild(O)}function e(e,c,h,m,
|
|
|
|
|
n,t,o){k.data.vertices+=4;k.data.faces++;O=f(aa++);O.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?G.hex=t.color.hex:t instanceof THREE.MeshLambertMaterial?I?(C.r=R.r,C.g=R.g,C.b=R.b,b(o,n,C),G.r=Math.max(0,Math.min(t.color.r*C.r,1)),G.g=Math.max(0,Math.min(t.color.g*C.g,1)),G.b=Math.max(0,Math.min(t.color.b*
|
|
|
|
|
C.b,1)),G.updateHex()):G.hex=t.color.hex:t instanceof THREE.MeshDepthMaterial?(J=1-t.__2near/(t.__farPlusNear-n.z*t.__farMinusNear),G.setRGB(J,J,J)):t instanceof THREE.MeshNormalMaterial&&G.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));t.wireframe?O.setAttribute("style","fill: none; stroke: #"+j(G.hex.toString(16))+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):O.setAttribute("style",
|
|
|
|
|
"fill: #"+j(G.hex.toString(16))+"; fill-opacity: "+t.opacity);p.appendChild(O)}function f(b){h[b]==null&&(h[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),da==0&&h[b].setAttribute("shape-rendering","crispEdges"));return h[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function j(b){for(;b.length<6;)b="0"+b;return b}var k=this,m=null,n=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,t,u,v,w,E,H,B,K=new THREE.Rectangle,A=new THREE.Rectangle,
|
|
|
|
|
I=!1,G=new THREE.Color(16777215),C=new THREE.Color(16777215),R=new THREE.Color(0),D=new THREE.Color(0),N=new THREE.Color(0),J,V=new THREE.Vector3,h=[],X=[],O,aa,M,da=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":da=1;break;case "low":da=0}};this.setSize=function(b,e){o=b;t=e;u=o/2;v=t/2;p.setAttribute("viewBox",-u+" "+-v+" "+o+" "+t);p.setAttribute("width",o);p.setAttribute("height",t);K.set(-u,
|
|
|
|
|
-v,u,v)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};this.render=function(b,f){var h,g,t,o,C,G,J,T;this.autoClear&&this.clear();k.data.vertices=0;k.data.faces=0;m=n.projectScene(b,f,this.sortElements);M=aa=0;if(I=b.lights.length>0){J=b.lights;R.setRGB(0,0,0);D.setRGB(0,0,0);N.setRGB(0,0,0);h=0;for(g=J.length;h<g;h++)t=J[h],o=t.color,t instanceof THREE.AmbientLight?(R.r+=o.r,R.g+=o.g,R.b+=o.b):t instanceof THREE.DirectionalLight?(D.r+=o.r,D.g+=o.g,D.b+=o.b):t instanceof
|
|
|
|
|
THREE.PointLight&&(N.r+=o.r,N.g+=o.g,N.b+=o.b)}h=0;for(g=m.length;h<g;h++)if(J=m[h],A.empty(),J instanceof THREE.RenderableParticle){w=J;w.x*=u;w.y*=-v;t=0;for(o=J.materials.length;t<o;)t++}else if(J instanceof THREE.RenderableLine){if(w=J.v1,E=J.v2,w.positionScreen.x*=u,w.positionScreen.y*=-v,E.positionScreen.x*=u,E.positionScreen.y*=-v,A.addPoint(w.positionScreen.x,w.positionScreen.y),A.addPoint(E.positionScreen.x,E.positionScreen.y),K.instersects(A)){t=0;for(o=J.materials.length;t<o;)if((T=J.materials[t++])&&
|
|
|
|
|
T.opacity!=0){C=w;G=E;var V=M++;X[V]==null&&(X[V]=document.createElementNS("http://www.w3.org/2000/svg","line"),da==0&&X[V].setAttribute("shape-rendering","crispEdges"));O=X[V];O.setAttribute("x1",C.positionScreen.x);O.setAttribute("y1",C.positionScreen.y);O.setAttribute("x2",G.positionScreen.x);O.setAttribute("y2",G.positionScreen.y);T instanceof THREE.LineBasicMaterial&&(O.setAttribute("style","fill: none; stroke: ##"+j(T.color.hex.toString(16))+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+
|
|
|
|
|
T.opacity+"; stroke-linecap: "+T.linecap+"; stroke-linejoin: "+T.linejoin),p.appendChild(O))}}}else if(J instanceof THREE.RenderableFace3){if(w=J.v1,E=J.v2,H=J.v3,w.positionScreen.x*=u,w.positionScreen.y*=-v,E.positionScreen.x*=u,E.positionScreen.y*=-v,H.positionScreen.x*=u,H.positionScreen.y*=-v,A.addPoint(w.positionScreen.x,w.positionScreen.y),A.addPoint(E.positionScreen.x,E.positionScreen.y),A.addPoint(H.positionScreen.x,H.positionScreen.y),K.instersects(A)){t=0;for(o=J.meshMaterials.length;t<
|
|
|
|
|
o;)if(T=J.meshMaterials[t++],T instanceof THREE.MeshFaceMaterial){C=0;for(G=J.faceMaterials.length;C<G;)(T=J.faceMaterials[C++])&&T.opacity!=0&&c(w,E,H,J,T,b)}else T&&T.opacity!=0&&c(w,E,H,J,T,b)}}else if(J instanceof THREE.RenderableFace4&&(w=J.v1,E=J.v2,H=J.v3,B=J.v4,w.positionScreen.x*=u,w.positionScreen.y*=-v,E.positionScreen.x*=u,E.positionScreen.y*=-v,H.positionScreen.x*=u,H.positionScreen.y*=-v,B.positionScreen.x*=u,B.positionScreen.y*=-v,A.addPoint(w.positionScreen.x,w.positionScreen.y),A.addPoint(E.positionScreen.x,
|
|
|
|
|
E.positionScreen.y),A.addPoint(H.positionScreen.x,H.positionScreen.y),A.addPoint(B.positionScreen.x,B.positionScreen.y),K.instersects(A))){t=0;for(o=J.meshMaterials.length;t<o;)if(T=J.meshMaterials[t++],T instanceof THREE.MeshFaceMaterial){C=0;for(G=J.faceMaterials.length;C<G;)(T=J.faceMaterials[C++])&&T.opacity!=0&&e(w,E,H,B,J,T,b)}else T&&T.opacity!=0&&e(w,E,H,B,J,T,b)}}};
|
|
|
|
|
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",
|
|
|
|
@@ -197,7 +198,7 @@ lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else
|
|
|
|
|
lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
|
|
|
|
|
color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif",
|
|
|
|
|
morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif",
|
|
|
|
|
default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var c,d,e,f={};for(c=0;c<b.length;c++)for(d in e=this.clone(b[c]),e)f[d]=e[d];return f},clone:function(b){var c,d,e,f={};for(c in b)for(d in f[c]={},b[c])e=b[c][d],f[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e;return f}};
|
|
|
|
|
default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var c,e,f,g={};for(c=0;c<b.length;c++)for(e in f=this.clone(b[c]),f)g[e]=f[e];return g},clone:function(b){var c,e,f,g={};for(c in b)for(e in g[c]={},b[c])f=b[c][e],g[c][e]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f;return g}};
|
|
|
|
|
THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",
|
|
|
|
|
value:new THREE.Color(16777215)},morphTargetInfluences:{type:"f",value:0}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},
|
|
|
|
|
map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
|
|
|
|
@@ -219,134 +220,134 @@ THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.Shade
|
|
|
|
|
"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,
|
|
|
|
|
THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",
|
|
|
|
|
THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
|
|
|
|
|
THREE.WebGLRenderer=function(b){function c(b,d,c){var e,h,f,j=b.vertices,k=j.length,m=b.colors,o=m.length,p=b.__vertexArray,n=b.__colorArray,t=b.__sortArray,u=b.__dirtyVertices,v=b.__dirtyColors;if(c.sortParticles){R.multiplySelf(c.matrixWorld);for(e=0;e<k;e++)h=j[e].position,X.copy(h),R.multiplyVector3(X),t[e]=[X.z,e];t.sort(function(b,d){return d[0]-b[0]});for(e=0;e<k;e++)h=j[t[e][1]].position,f=e*3,p[f]=h.x,p[f+1]=h.y,p[f+2]=h.z;for(e=0;e<o;e++)f=e*3,color=m[t[e][1]],n[f]=color.r,n[f+1]=color.g,
|
|
|
|
|
n[f+2]=color.b}else{if(u)for(e=0;e<k;e++)h=j[e].position,f=e*3,p[f]=h.x,p[f+1]=h.y,p[f+2]=h.z;if(v)for(e=0;e<o;e++)color=m[e],f=e*3,n[f]=color.r,n[f+1]=color.g,n[f+2]=color.b}if(u||c.sortParticles)g.bindBuffer(g.ARRAY_BUFFER,b.__webglVertexBuffer),g.bufferData(g.ARRAY_BUFFER,p,d);if(v||c.sortParticles)g.bindBuffer(g.ARRAY_BUFFER,b.__webglColorBuffer),g.bufferData(g.ARRAY_BUFFER,n,d)}function d(b,d,c,e,h){e.program||N.initMaterial(e,d,c,h);var f=e.program,j=f.uniforms,k=e.uniforms;f!=O&&(g.useProgram(f),
|
|
|
|
|
O=f);g.uniformMatrix4fv(j.projectionMatrix,!1,P);if(c&&(e instanceof THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial||e instanceof THREE.LineBasicMaterial||e instanceof THREE.ParticleBasicMaterial||e.fog))if(k.fogColor.value=c.color,c instanceof THREE.Fog)k.fogNear.value=c.near,k.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)k.fogDensity.value=c.density;if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e.lights){var m,
|
|
|
|
|
o,p=0,n=0,t=0,u,v,y,x,E=ea,C=E.directional.colors,F=E.directional.positions,D=E.point.colors,I=E.point.positions,J=E.point.distances,G=0,B=0,c=o=x=0;for(m=d.length;c<m;c++)if(o=d[c],u=o.color,v=o.position,y=o.intensity,x=o.distance,o instanceof THREE.AmbientLight)p+=u.r,n+=u.g,t+=u.b;else if(o instanceof THREE.DirectionalLight)x=G*3,C[x]=u.r*y,C[x+1]=u.g*y,C[x+2]=u.b*y,F[x]=v.x,F[x+1]=v.y,F[x+2]=v.z,G+=1;else if(o instanceof THREE.PointLight)o=B*3,D[o]=u.r*y,D[o+1]=u.g*y,D[o+2]=u.b*y,I[o]=v.x,I[o+
|
|
|
|
|
1]=v.y,I[o+2]=v.z,J[B]=x,B+=1;for(c=G*3;c<C.length;c++)C[c]=0;for(c=B*3;c<D.length;c++)D[c]=0;E.point.length=B;E.directional.length=G;E.ambient[0]=p;E.ambient[1]=n;E.ambient[2]=t;c=ea;k.enableLighting.value=c.directional.length+c.point.length;k.ambientLightColor.value=c.ambient;k.directionalLightColor.value=c.directional.colors;k.directionalLightDirection.value=c.directional.positions;k.pointLightColor.value=c.point.colors;k.pointLightPosition.value=c.point.positions;k.pointLightDistance.value=c.point.distances}if(e instanceof
|
|
|
|
|
THREE.MeshBasicMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshPhongMaterial)k.diffuse.value=e.color,k.opacity.value=e.opacity,(k.map.texture=e.map)&&k.offsetRepeat.value.set(e.map.offset.x,e.map.offset.y,e.map.repeat.x,e.map.repeat.y),k.lightMap.texture=e.lightMap,k.envMap.texture=e.envMap,k.reflectivity.value=e.reflectivity,k.refractionRatio.value=e.refractionRatio,k.combine.value=e.combine,k.useRefract.value=e.envMap&&e.envMap.mapping instanceof THREE.CubeRefractionMapping;
|
|
|
|
|
if(e instanceof THREE.LineBasicMaterial)k.diffuse.value=e.color,k.opacity.value=e.opacity;else if(e instanceof THREE.ParticleBasicMaterial)k.psColor.value=e.color,k.opacity.value=e.opacity,k.size.value=e.size,k.scale.value=ia.height/2,k.map.texture=e.map;else if(e instanceof THREE.MeshPhongMaterial)k.ambient.value=e.ambient,k.specular.value=e.specular,k.shininess.value=e.shininess;else if(e instanceof THREE.MeshDepthMaterial)k.mNear.value=b.near,k.mFar.value=b.far,k.opacity.value=e.opacity;else if(e instanceof
|
|
|
|
|
THREE.MeshNormalMaterial)k.opacity.value=e.opacity;for(var Xa in k)if(n=f.uniforms[Xa])if(m=k[Xa],p=m.type,c=m.value,p=="i")g.uniform1i(n,c);else if(p=="f")g.uniform1f(n,c);else if(p=="fv1")g.uniform1fv(n,c);else if(p=="fv")g.uniform3fv(n,c);else if(p=="v2")g.uniform2f(n,c.x,c.y);else if(p=="v3")g.uniform3f(n,c.x,c.y,c.z);else if(p=="v4")g.uniform4f(n,c.x,c.y,c.z,c.w);else if(p=="c")g.uniform3f(n,c.r,c.g,c.b);else if(p=="t"&&(g.uniform1i(n,c),m=m.texture))if(m.image instanceof Array&&m.image.length==
|
|
|
|
|
6){if(m.image.length==6){if(m.needsUpdate){if(m.__webglInit){g.bindTexture(g.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(p=0;p<6;++p)g.texSubImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,0,0,g.RGBA,g.UNSIGNED_BYTE,m.image[p])}else{m.image.__webglTextureCube=g.createTexture();g.bindTexture(g.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(p=0;p<6;++p)g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,g.RGBA,g.RGBA,g.UNSIGNED_BYTE,m.image[p]);m.__webglInit=!0}A(g.TEXTURE_CUBE_MAP,m,m.image[0]);g.bindTexture(g.TEXTURE_CUBE_MAP,
|
|
|
|
|
null);m.needsUpdate=!1}g.activeTexture(g.TEXTURE0+c);g.bindTexture(g.TEXTURE_CUBE_MAP,m.image.__webglTextureCube)}}else z(m,c);g.uniformMatrix4fv(j.modelViewMatrix,!1,h._modelViewMatrixArray);g.uniformMatrix3fv(j.normalMatrix,!1,h._normalMatrixArray);(e instanceof THREE.MeshShaderMaterial||e instanceof THREE.MeshPhongMaterial||e.envMap)&&j.cameraPosition!==null&&g.uniform3f(j.cameraPosition,b.position.x,b.position.y,b.position.z);(e instanceof THREE.MeshShaderMaterial||e.envMap||e.skinning)&&j.objectMatrix!==
|
|
|
|
|
null&&g.uniformMatrix4fv(j.objectMatrix,!1,h._objectMatrixArray);(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshShaderMaterial||e.skinning)&&j.viewMatrix!==null&&g.uniformMatrix4fv(j.viewMatrix,!1,W);if(e instanceof THREE.ShadowVolumeDynamicMaterial)b=k.directionalLightDirection.value,b[0]=-d[1].position.x,b[1]=-d[1].position.y,b[2]=-d[1].position.z,g.uniform3fv(j.directionalLightDirection,b),g.uniformMatrix4fv(j.objectMatrix,!1,h._objectMatrixArray),
|
|
|
|
|
g.uniformMatrix4fv(j.viewMatrix,!1,W);e.skinning&&(g.uniformMatrix4fv(j.cameraInverseMatrix,!1,W),g.uniformMatrix4fv(j.boneGlobalMatrices,!1,h.boneMatrices));return f}function e(b,c,e,h,f,j){if(h.opacity!=0){var k,b=d(b,c,e,h,j).attributes;if(!h.morphTargets&&b.position>=0)g.bindBuffer(g.ARRAY_BUFFER,f.__webglVertexBuffer),g.vertexAttribPointer(b.position,3,g.FLOAT,!1,0,0);else{c=h.program.attributes;j.morphTargetBase!==-1?(g.bindBuffer(g.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[j.morphTargetBase]),
|
|
|
|
|
g.vertexAttribPointer(c.position,3,g.FLOAT,!1,0,0)):c.position>=0&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglVertexBuffer),g.vertexAttribPointer(c.position,3,g.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var e=0,m=j.morphTargetForcedOrder,o=j.morphTargetInfluences;e<h.numSupportedMorphTargets&&e<m.length;)g.bindBuffer(g.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[m[e]]),g.vertexAttribPointer(c["morphTarget"+e],3,g.FLOAT,!1,0,0),j.__webglMorphTargetInfluences[e]=o[m[e]],e++;else{var m=[],p=-1,
|
|
|
|
|
n=0,o=j.morphTargetInfluences,t,u=o.length,e=0;for(j.morphTargetBase!==-1&&(m[j.morphTargetBase]=!0);e<h.numSupportedMorphTargets;){for(t=0;t<u;t++)!m[t]&&o[t]>p&&(n=t,p=o[n]);g.bindBuffer(g.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[n]);g.vertexAttribPointer(c["morphTarget"+e],3,g.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[e]=p;m[n]=1;p=-1;e++}}h.program.uniforms.morphTargetInfluences!==null&&g.uniform1fv(h.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(f.__webglCustomAttributes)for(k in f.__webglCustomAttributes)b[k]>=
|
|
|
|
|
0&&(c=f.__webglCustomAttributes[k],g.bindBuffer(g.ARRAY_BUFFER,c.buffer),g.vertexAttribPointer(b[k],c.size,g.FLOAT,!1,0,0));b.color>=0&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglColorBuffer),g.vertexAttribPointer(b.color,3,g.FLOAT,!1,0,0));b.normal>=0&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglNormalBuffer),g.vertexAttribPointer(b.normal,3,g.FLOAT,!1,0,0));b.tangent>=0&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglTangentBuffer),g.vertexAttribPointer(b.tangent,4,g.FLOAT,!1,0,0));b.uv>=0&&(f.__webglUVBuffer?(g.bindBuffer(g.ARRAY_BUFFER,
|
|
|
|
|
f.__webglUVBuffer),g.vertexAttribPointer(b.uv,2,g.FLOAT,!1,0,0),g.enableVertexAttribArray(b.uv)):g.disableVertexAttribArray(b.uv));b.uv2>=0&&(f.__webglUV2Buffer?(g.bindBuffer(g.ARRAY_BUFFER,f.__webglUV2Buffer),g.vertexAttribPointer(b.uv2,2,g.FLOAT,!1,0,0),g.enableVertexAttribArray(b.uv2)):g.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglSkinVertexABuffer),g.vertexAttribPointer(b.skinVertexA,4,
|
|
|
|
|
g.FLOAT,!1,0,0),g.bindBuffer(g.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),g.vertexAttribPointer(b.skinVertexB,4,g.FLOAT,!1,0,0),g.bindBuffer(g.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),g.vertexAttribPointer(b.skinIndex,4,g.FLOAT,!1,0,0),g.bindBuffer(g.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),g.vertexAttribPointer(b.skinWeight,4,g.FLOAT,!1,0,0));j instanceof THREE.Mesh?(h.wireframe?(g.lineWidth(h.wireframeLinewidth),g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),g.drawElements(g.LINES,f.__webglLineCount,
|
|
|
|
|
g.UNSIGNED_SHORT,0)):(g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),g.drawElements(g.TRIANGLES,f.__webglFaceCount,g.UNSIGNED_SHORT,0)),N.data.vertices+=f.__webglFaceCount,N.data.faces+=f.__webglFaceCount/3,N.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?g.LINE_STRIP:g.LINES,g.lineWidth(h.linewidth),g.drawArrays(j,0,f.__webglLineCount),N.data.drawCalls++):j instanceof THREE.ParticleSystem?(g.drawArrays(g.POINTS,0,f.__webglParticleCount),N.data.drawCalls++):j instanceof
|
|
|
|
|
THREE.Ribbon&&(g.drawArrays(g.TRIANGLE_STRIP,0,f.__webglVertexCount),N.data.drawCalls++)}}function f(b,d,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=g.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=g.createBuffer();b.hasPos&&(g.bindBuffer(g.ARRAY_BUFFER,b.__webglVertexBuffer),g.bufferData(g.ARRAY_BUFFER,b.positionArray,g.DYNAMIC_DRAW),g.enableVertexAttribArray(d.attributes.position),g.vertexAttribPointer(d.attributes.position,3,g.FLOAT,!1,0,0));if(b.hasNormal){g.bindBuffer(g.ARRAY_BUFFER,
|
|
|
|
|
b.__webglNormalBuffer);if(c==THREE.FlatShading){var e,f,h,j,k,m,o,p,n,t,u=b.count*3;for(t=0;t<u;t+=9)c=b.normalArray,e=c[t],f=c[t+1],h=c[t+2],j=c[t+3],m=c[t+4],p=c[t+5],k=c[t+6],o=c[t+7],n=c[t+8],e=(e+j+k)/3,f=(f+m+o)/3,h=(h+p+n)/3,c[t]=e,c[t+1]=f,c[t+2]=h,c[t+3]=e,c[t+4]=f,c[t+5]=h,c[t+6]=e,c[t+7]=f,c[t+8]=h}g.bufferData(g.ARRAY_BUFFER,b.normalArray,g.DYNAMIC_DRAW);g.enableVertexAttribArray(d.attributes.normal);g.vertexAttribPointer(d.attributes.normal,3,g.FLOAT,!1,0,0)}g.drawArrays(g.TRIANGLES,
|
|
|
|
|
0,b.count);b.count=0}function h(b){if($!=b.doubleSided)b.doubleSided?g.disable(g.CULL_FACE):g.enable(g.CULL_FACE),$=b.doubleSided;if(T!=b.flipSided)b.flipSided?g.frontFace(g.CW):g.frontFace(g.CCW),T=b.flipSided}function j(b){fa!=b&&(b?g.enable(g.DEPTH_TEST):g.disable(g.DEPTH_TEST),fa=b)}function k(b){aa[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);aa[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);aa[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);aa[3].set(b.n41-b.n21,
|
|
|
|
|
b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);aa[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);aa[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var d,b=0;b<6;b++)d=aa[b],d.divideScalar(Math.sqrt(d.x*d.x+d.y*d.y+d.z*d.z))}function m(b){for(var d=b.matrixWorld,c=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),e=0;e<6;e++)if(b=aa[e].x*d.n14+aa[e].y*d.n24+aa[e].z*d.n34+aa[e].w,b<=c)return!1;return!0}function o(b,d){b.list[b.count]=d;b.count+=1}function n(b){var d,
|
|
|
|
|
c,e=b.object,g=b.opaque,f=b.transparent;f.count=0;b=g.count=0;for(d=e.materials.length;b<d;b++)c=e.materials[b],c.transparent?o(f,c):o(g,c)}function p(b){var d,c,e,g,f=b.object,h=b.buffer,j=b.opaque,k=b.transparent;k.count=0;b=j.count=0;for(e=f.materials.length;b<e;b++)if(d=f.materials[b],d instanceof THREE.MeshFaceMaterial){d=0;for(c=h.materials.length;d<c;d++)(g=h.materials[d])&&(g.transparent?o(k,g):o(j,g))}else(g=d)&&(g.transparent?o(k,g):o(j,g))}function t(b,d){return d.z-b.z}function u(b){g.enable(g.POLYGON_OFFSET_FILL);
|
|
|
|
|
g.polygonOffset(0.1,1);g.enable(g.STENCIL_TEST);g.enable(g.DEPTH_TEST);g.depthMask(!1);g.colorMask(!1,!1,!1,!1);g.stencilFunc(g.ALWAYS,1,255);g.stencilOpSeparate(g.BACK,g.KEEP,g.INCR,g.KEEP);g.stencilOpSeparate(g.FRONT,g.KEEP,g.DECR,g.KEEP);var d,c=b.lights.length,e,f=b.lights,h=[],j,k,m,o,p,n=b.__webglShadowVolumes.length;for(d=0;d<c;d++)if(e=b.lights[d],e instanceof THREE.DirectionalLight&&e.castShadow){h[0]=-e.position.x;h[1]=-e.position.y;h[2]=-e.position.z;for(p=0;p<n;p++)e=b.__webglShadowVolumes[p].object,
|
|
|
|
|
j=b.__webglShadowVolumes[p].buffer,k=e.materials[0],k.program||N.initMaterial(k,f,void 0,e),k=k.program,m=k.uniforms,o=k.attributes,O!==k&&(g.useProgram(k),O=k,g.uniformMatrix4fv(m.projectionMatrix,!1,P),g.uniformMatrix4fv(m.viewMatrix,!1,W),g.uniform3fv(m.directionalLightDirection,h)),e.matrixWorld.flattenToArray(e._objectMatrixArray),g.uniformMatrix4fv(m.objectMatrix,!1,e._objectMatrixArray),g.bindBuffer(g.ARRAY_BUFFER,j.__webglVertexBuffer),g.vertexAttribPointer(o.position,3,g.FLOAT,!1,0,0),g.bindBuffer(g.ARRAY_BUFFER,
|
|
|
|
|
j.__webglNormalBuffer),g.vertexAttribPointer(o.normal,3,g.FLOAT,!1,0,0),g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,j.__webglFaceBuffer),g.cullFace(g.FRONT),g.drawElements(g.TRIANGLES,j.__webglFaceCount,g.UNSIGNED_SHORT,0),g.cullFace(g.BACK),g.drawElements(g.TRIANGLES,j.__webglFaceCount,g.UNSIGNED_SHORT,0)}g.disable(g.POLYGON_OFFSET_FILL);g.colorMask(!0,!0,!0,!0);g.stencilFunc(g.NOTEQUAL,0,255);g.stencilOp(g.KEEP,g.KEEP,g.KEEP);g.disable(g.DEPTH_TEST);Q=-1;O=Z.program;g.useProgram(Z.program);g.uniformMatrix4fv(Z.projectionLocation,
|
|
|
|
|
!1,P);g.uniform1f(Z.darknessLocation,Z.darkness);g.bindBuffer(g.ARRAY_BUFFER,Z.vertexBuffer);g.vertexAttribPointer(Z.vertexLocation,3,g.FLOAT,!1,0,0);g.enableVertexAttribArray(Z.vertexLocation);g.blendFunc(g.ONE,g.ONE_MINUS_SRC_ALPHA);g.blendEquation(g.FUNC_ADD);g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,Z.elementBuffer);g.drawElements(g.TRIANGLES,6,g.UNSIGNED_SHORT,0);g.disable(g.STENCIL_TEST);g.enable(g.DEPTH_TEST);g.depthMask(L)}function v(b,d){var c,e,f;c=_sprite.attributes;var h=_sprite.uniforms,j=
|
|
|
|
|
ca/ga,k,m=[],o=ga*0.5,p=ca*0.5,n=!0;g.useProgram(_sprite.program);O=_sprite.program;Q=-1;qa||(g.enableVertexAttribArray(_sprite.attributes.position),g.enableVertexAttribArray(_sprite.attributes.uv),qa=!0);g.disable(g.CULL_FACE);g.enable(g.BLEND);g.depthMask(!0);g.bindBuffer(g.ARRAY_BUFFER,_sprite.vertexBuffer);g.vertexAttribPointer(c.position,2,g.FLOAT,!1,16,0);g.vertexAttribPointer(c.uv,2,g.FLOAT,!1,16,8);g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);g.uniformMatrix4fv(h.projectionMatrix,
|
|
|
|
|
!1,P);g.activeTexture(g.TEXTURE0);g.uniform1i(h.map,0);c=0;for(e=b.__webglSprites.length;c<e;c++)f=b.__webglSprites[c],f.useScreenCoordinates?f.z=-f.position.z:(f._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray),f.z=-f._modelViewMatrix.n34);b.__webglSprites.sort(t);c=0;for(e=b.__webglSprites.length;c<e;c++)f=b.__webglSprites[c],f.material===void 0&&f.map&&f.map.image&&f.map.image.width&&(f.useScreenCoordinates?(g.uniform1i(h.useScreenCoordinates,1),g.uniform3f(h.screenPosition,
|
|
|
|
|
(f.position.x-o)/o,(p-f.position.y)/p,Math.max(0,Math.min(1,f.position.z)))):(g.uniform1i(h.useScreenCoordinates,0),g.uniform1i(h.affectedByDistance,f.affectedByDistance?1:0),g.uniformMatrix4fv(h.modelViewMatrix,!1,f._modelViewMatrixArray)),k=f.map.image.width/(f.affectedByDistance?1:ca),m[0]=k*j*f.scale.x,m[1]=k*f.scale.y,g.uniform2f(h.uvScale,f.uvScale.x,f.uvScale.y),g.uniform2f(h.uvOffset,f.uvOffset.x,f.uvOffset.y),g.uniform2f(h.alignment,f.alignment.x,f.alignment.y),g.uniform1f(h.opacity,f.opacity),
|
|
|
|
|
g.uniform1f(h.rotation,f.rotation),g.uniform2fv(h.scale,m),f.mergeWith3D&&!n?(g.enable(g.DEPTH_TEST),n=!0):!f.mergeWith3D&&n&&(g.disable(g.DEPTH_TEST),n=!1),I(f.blending),z(f.map,0),g.drawElements(g.TRIANGLES,6,g.UNSIGNED_SHORT,0));g.enable(g.CULL_FACE);g.enable(g.DEPTH_TEST);g.depthMask(L)}function C(b,d){var c,e,f=b.__webglLensFlares.length,h,j,k,m=new THREE.Vector3,o=ca/ga,p=ga*0.5,n=ca*0.5,t=16/ca,u=[t*o,t],v=[1,1,0],y=[1,1],x=K.uniforms;c=K.attributes;g.useProgram(K.program);O=K.program;Q=-1;
|
|
|
|
|
wa||(g.enableVertexAttribArray(K.attributes.vertex),g.enableVertexAttribArray(K.attributes.uv),wa=!0);g.uniform1i(x.occlusionMap,0);g.uniform1i(x.map,1);g.bindBuffer(g.ARRAY_BUFFER,K.vertexBuffer);g.vertexAttribPointer(c.vertex,2,g.FLOAT,!1,16,0);g.vertexAttribPointer(c.uv,2,g.FLOAT,!1,16,8);g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,K.elementBuffer);g.disable(g.CULL_FACE);g.depthMask(!1);g.activeTexture(g.TEXTURE0);g.bindTexture(g.TEXTURE_2D,K.occlusionTexture);g.activeTexture(g.TEXTURE1);for(e=0;e<f;e++)if(c=
|
|
|
|
|
b.__webglLensFlares[e].object,m.set(c.matrixWorld.n14,c.matrixWorld.n24,c.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(m),d.projectionMatrix.multiplyVector3(m),v[0]=m.x,v[1]=m.y,v[2]=m.z,y[0]=v[0]*p+p,y[1]=v[1]*n+n,K.hasVertexTexture||y[0]>0&&y[0]<ga&&y[1]>0&&y[1]<ca){g.bindTexture(g.TEXTURE_2D,K.tempTexture);g.copyTexImage2D(g.TEXTURE_2D,0,g.RGB,y[0]-8,y[1]-8,16,16,0);g.uniform1i(x.renderType,0);g.uniform2fv(x.scale,u);g.uniform3fv(x.screenPosition,v);g.disable(g.BLEND);g.enable(g.DEPTH_TEST);
|
|
|
|
|
g.drawElements(g.TRIANGLES,6,g.UNSIGNED_SHORT,0);g.bindTexture(g.TEXTURE_2D,K.occlusionTexture);g.copyTexImage2D(g.TEXTURE_2D,0,g.RGBA,y[0]-8,y[1]-8,16,16,0);g.uniform1i(x.renderType,1);g.disable(g.DEPTH_TEST);g.bindTexture(g.TEXTURE_2D,K.tempTexture);g.drawElements(g.TRIANGLES,6,g.UNSIGNED_SHORT,0);c.positionScreen.x=v[0];c.positionScreen.y=v[1];c.positionScreen.z=v[2];c.customUpdateCallback?c.customUpdateCallback(c):c.updateLensFlares();g.uniform1i(x.renderType,2);g.enable(g.BLEND);h=0;for(j=c.lensFlares.length;h<
|
|
|
|
|
j;h++)if(k=c.lensFlares[h],k.opacity>0.0010&&k.scale>0.0010)v[0]=k.x,v[1]=k.y,v[2]=k.z,t=k.size*k.scale/ca,u[0]=t*o,u[1]=t,g.uniform3fv(x.screenPosition,v),g.uniform2fv(x.scale,u),g.uniform1f(x.rotation,k.rotation),g.uniform1f(x.opacity,k.opacity),I(k.blending),z(k.texture,1),g.drawElements(g.TRIANGLES,6,g.UNSIGNED_SHORT,0)}g.enable(g.CULL_FACE);g.enable(g.DEPTH_TEST);g.depthMask(L)}function E(b,d){b._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}
|
|
|
|
|
function y(b){var d,e,f,h,j;if(b instanceof THREE.Mesh){e=b.geometry;for(d in e.geometryGroups){f=e.geometryGroups[d];j=!1;for(h in f.__webglCustomAttributes)if(f.__webglCustomAttributes[h].needsUpdate){j=!0;break}if(e.__dirtyVertices||e.__dirtyMorphTargets||e.__dirtyElements||e.__dirtyUvs||e.__dirtyNormals||e.__dirtyColors||e.__dirtyTangents||j){j=b;var k=g.DYNAMIC_DRAW;if(f.__inittedArrays){var m=void 0,o=void 0,p=void 0,n=void 0,t=p=void 0,u=void 0,v=void 0,y=void 0,x=void 0,E=void 0,C=void 0,
|
|
|
|
|
F=void 0,ia=void 0,z=void 0,A=void 0,D=void 0,I=void 0,B=n=y=n=v=u=void 0,J=void 0,w=J=B=u=void 0,G=void 0,M=w=J=B=p=p=t=y=n=w=J=B=G=w=J=B=G=w=J=B=void 0,da=0,K=0,la=0,L=0,P=0,S=0,N=0,R=0,O=0,H=0,Q=0,J=B=0,U=f.__vertexArray,Z=f.__uvArray,$=f.__uv2Array,fa=f.__normalArray,T=f.__tangentArray,ma=f.__colorArray,V=f.__skinVertexAArray,W=f.__skinVertexBArray,X=f.__skinIndexArray,Y=f.__skinWeightArray,ga=f.__morphTargetsArrays,ca=f.__webglCustomAttributes,w=void 0,aa=f.__faceArray,ea=f.__lineArray,ka=f.__needsSmoothNormals,
|
|
|
|
|
E=f.__vertexColorType,x=f.__uvType,C=f.__normalType,oa=j.geometry,ya=oa.__dirtyVertices,va=oa.__dirtyElements,qa=oa.__dirtyUvs,wa=oa.__dirtyNormals,Ua=oa.__dirtyTangents,Va=oa.__dirtyColors,Wa=oa.__dirtyMorphTargets,Da=oa.vertices,Za=f.faces,bb=oa.faces,$a=oa.faceVertexUvs[0],ab=oa.faceVertexUvs[1],Ea=oa.skinVerticesA,Fa=oa.skinVerticesB,Ga=oa.skinIndices,xa=oa.skinWeights,Ba=j instanceof THREE.ShadowVolume?oa.edgeFaces:void 0;morphTargets=oa.morphTargets;if(ca)for(M in ca)ca[M].offset=0,ca[M].offsetSrc=
|
|
|
|
|
0;m=0;for(o=Za.length;m<o;m++)if(p=Za[m],n=bb[p],$a&&(F=$a[p]),ab&&(ia=ab[p]),p=n.vertexNormals,t=n.normal,u=n.vertexColors,v=n.color,y=n.vertexTangents,n instanceof THREE.Face3){if(ya)z=Da[n.a].position,A=Da[n.b].position,D=Da[n.c].position,U[K]=z.x,U[K+1]=z.y,U[K+2]=z.z,U[K+3]=A.x,U[K+4]=A.y,U[K+5]=A.z,U[K+6]=D.x,U[K+7]=D.y,U[K+8]=D.z,K+=9;if(ca)for(M in ca)if(w=ca[M],w.needsUpdate)B=w.offset,J=w.offsetSrc,w.size===1?(w.boundTo===void 0||w.boundTo==="vertices"?(w.array[B+0]=w.value[n.a],w.array[B+
|
|
|
|
|
1]=w.value[n.b],w.array[B+2]=w.value[n.c]):w.boundTo==="faces"?(w.array[B+0]=w.value[J],w.array[B+1]=w.value[J],w.array[B+2]=w.value[J],w.offsetSrc++):w.boundTo==="faceVertices"&&(w.array[B+0]=w.value[J+0],w.array[B+1]=w.value[J+1],w.array[B+2]=w.value[J+2],w.offsetSrc+=3),w.offset+=3):(w.boundTo===void 0||w.boundTo==="vertices"?(z=w.value[n.a],A=w.value[n.b],D=w.value[n.c]):w.boundTo==="faces"?(z=w.value[J],A=w.value[J],D=w.value[J],w.offsetSrc++):w.boundTo==="faceVertices"&&(z=w.value[J+0],A=w.value[J+
|
|
|
|
|
1],D=w.value[J+2],w.offsetSrc+=3),w.size===2?(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=A.x,w.array[B+3]=A.y,w.array[B+4]=D.x,w.array[B+5]=D.y,w.offset+=6):w.size===3?(w.type==="c"?(w.array[B+0]=z.r,w.array[B+1]=z.g,w.array[B+2]=z.b,w.array[B+3]=A.r,w.array[B+4]=A.g,w.array[B+5]=A.b,w.array[B+6]=D.r,w.array[B+7]=D.g,w.array[B+8]=D.b):(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=z.z,w.array[B+3]=A.x,w.array[B+4]=A.y,w.array[B+5]=A.z,w.array[B+6]=D.x,w.array[B+7]=D.y,w.array[B+8]=D.z),w.offset+=
|
|
|
|
|
9):(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=z.z,w.array[B+3]=z.w,w.array[B+4]=A.x,w.array[B+5]=A.y,w.array[B+6]=A.z,w.array[B+7]=A.w,w.array[B+8]=D.x,w.array[B+9]=D.y,w.array[B+10]=D.z,w.array[B+11]=D.w,w.offset+=12));if(Wa){B=0;for(J=morphTargets.length;B<J;B++)z=morphTargets[B].vertices[n.a].position,A=morphTargets[B].vertices[n.b].position,D=morphTargets[B].vertices[n.c].position,w=ga[B],w[Q+0]=z.x,w[Q+1]=z.y,w[Q+2]=z.z,w[Q+3]=A.x,w[Q+4]=A.y,w[Q+5]=A.z,w[Q+6]=D.x,w[Q+7]=D.y,w[Q+8]=D.z;Q+=
|
|
|
|
|
9}if(xa.length)B=xa[n.a],J=xa[n.b],w=xa[n.c],Y[H]=B.x,Y[H+1]=B.y,Y[H+2]=B.z,Y[H+3]=B.w,Y[H+4]=J.x,Y[H+5]=J.y,Y[H+6]=J.z,Y[H+7]=J.w,Y[H+8]=w.x,Y[H+9]=w.y,Y[H+10]=w.z,Y[H+11]=w.w,B=Ga[n.a],J=Ga[n.b],w=Ga[n.c],X[H]=B.x,X[H+1]=B.y,X[H+2]=B.z,X[H+3]=B.w,X[H+4]=J.x,X[H+5]=J.y,X[H+6]=J.z,X[H+7]=J.w,X[H+8]=w.x,X[H+9]=w.y,X[H+10]=w.z,X[H+11]=w.w,B=Ea[n.a],J=Ea[n.b],w=Ea[n.c],V[H]=B.x,V[H+1]=B.y,V[H+2]=B.z,V[H+3]=1,V[H+4]=J.x,V[H+5]=J.y,V[H+6]=J.z,V[H+7]=1,V[H+8]=w.x,V[H+9]=w.y,V[H+10]=w.z,V[H+11]=1,B=Fa[n.a],
|
|
|
|
|
J=Fa[n.b],w=Fa[n.c],W[H]=B.x,W[H+1]=B.y,W[H+2]=B.z,W[H+3]=1,W[H+4]=J.x,W[H+5]=J.y,W[H+6]=J.z,W[H+7]=1,W[H+8]=w.x,W[H+9]=w.y,W[H+10]=w.z,W[H+11]=1,H+=12;if(Va&&E)u.length==3&&E==THREE.VertexColors?(n=u[0],B=u[1],J=u[2]):J=B=n=v,ma[O]=n.r,ma[O+1]=n.g,ma[O+2]=n.b,ma[O+3]=B.r,ma[O+4]=B.g,ma[O+5]=B.b,ma[O+6]=J.r,ma[O+7]=J.g,ma[O+8]=J.b,O+=9;if(Ua&&oa.hasTangents)u=y[0],v=y[1],n=y[2],T[N]=u.x,T[N+1]=u.y,T[N+2]=u.z,T[N+3]=u.w,T[N+4]=v.x,T[N+5]=v.y,T[N+6]=v.z,T[N+7]=v.w,T[N+8]=n.x,T[N+9]=n.y,T[N+10]=n.z,
|
|
|
|
|
T[N+11]=n.w,N+=12;if(wa&&C)if(p.length==3&&ka)for(y=0;y<3;y++)t=p[y],fa[S]=t.x,fa[S+1]=t.y,fa[S+2]=t.z,S+=3;else for(y=0;y<3;y++)fa[S]=t.x,fa[S+1]=t.y,fa[S+2]=t.z,S+=3;if(qa&&F!==void 0&&x)for(y=0;y<3;y++)p=F[y],Z[la]=p.u,Z[la+1]=p.v,la+=2;if(qa&&ia!==void 0&&x)for(y=0;y<3;y++)p=ia[y],$[L]=p.u,$[L+1]=p.v,L+=2;va&&(aa[P]=da,aa[P+1]=da+1,aa[P+2]=da+2,P+=3,ea[R]=da,ea[R+1]=da+1,ea[R+2]=da,ea[R+3]=da+2,ea[R+4]=da+1,ea[R+5]=da+2,R+=6,da+=3)}else if(n instanceof THREE.Face4){if(ya)z=Da[n.a].position,A=
|
|
|
|
|
Da[n.b].position,D=Da[n.c].position,I=Da[n.d].position,U[K]=z.x,U[K+1]=z.y,U[K+2]=z.z,U[K+3]=A.x,U[K+4]=A.y,U[K+5]=A.z,U[K+6]=D.x,U[K+7]=D.y,U[K+8]=D.z,U[K+9]=I.x,U[K+10]=I.y,U[K+11]=I.z,K+=12;if(ca)for(M in ca)if(w=ca[M],w.needsUpdate)B=w.offset,J=w.offsetSrc,w.size===1?(w.boundTo===void 0||w.boundTo==="vertices"?(w.array[B+0]=w.value[n.a],w.array[B+1]=w.value[n.b],w.array[B+2]=w.value[n.c],w.array[B+3]=w.value[n.d]):w.boundTo==="faces"?(w.array[B+0]=w.value[J],w.array[B+1]=w.value[J],w.array[B+
|
|
|
|
|
2]=w.value[J],w.array[B+3]=w.value[J],w.offsetSrc++):w.boundTo==="faceVertices"&&(w.array[B+0]=w.value[J+0],w.array[B+1]=w.value[J+1],w.array[B+2]=w.value[J+2],w.array[B+3]=w.value[J+3],w.offsetSrc+=4),w.offset+=4):(w.boundTo===void 0||w.boundTo==="vertices"?(z=w.value[n.a],A=w.value[n.b],D=w.value[n.c],I=w.value[n.d]):w.boundTo==="faces"?(z=w.value[J],A=w.value[J],D=w.value[J],I=w.value[J],w.offsetSrc++):w.boundTo==="faceVertices"&&(z=w.value[J+0],A=w.value[J+1],D=w.value[J+2],I=w.value[J+3],w.offsetSrc+=
|
|
|
|
|
4),w.size===2?(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=A.x,w.array[B+3]=A.y,w.array[B+4]=D.x,w.array[B+5]=D.y,w.array[B+6]=I.x,w.array[B+7]=I.y,w.offset+=8):w.size===3?(w.type==="c"?(w.array[B+0]=z.r,w.array[B+1]=z.g,w.array[B+2]=z.b,w.array[B+3]=A.r,w.array[B+4]=A.g,w.array[B+5]=A.b,w.array[B+6]=D.r,w.array[B+7]=D.g,w.array[B+8]=D.b,w.array[B+9]=I.r,w.array[B+10]=I.g,w.array[B+11]=I.b):(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=z.z,w.array[B+3]=A.x,w.array[B+4]=A.y,w.array[B+5]=A.z,w.array[B+
|
|
|
|
|
6]=D.x,w.array[B+7]=D.y,w.array[B+8]=D.z,w.array[B+9]=I.x,w.array[B+10]=I.y,w.array[B+11]=I.z),w.offset+=12):(w.array[B+0]=z.x,w.array[B+1]=z.y,w.array[B+2]=z.z,w.array[B+3]=z.w,w.array[B+4]=A.x,w.array[B+5]=A.y,w.array[B+6]=A.z,w.array[B+7]=A.w,w.array[B+8]=D.x,w.array[B+9]=D.y,w.array[B+10]=D.z,w.array[B+11]=D.w,w.array[B+12]=I.x,w.array[B+13]=I.y,w.array[B+14]=I.z,w.array[B+15]=I.w,w.offset+=16));if(Wa){B=0;for(J=morphTargets.length;B<J;B++)z=morphTargets[B].vertices[n.a].position,A=morphTargets[B].vertices[n.b].position,
|
|
|
|
|
D=morphTargets[B].vertices[n.c].position,I=morphTargets[B].vertices[n.d].position,w=ga[B],w[Q+0]=z.x,w[Q+1]=z.y,w[Q+2]=z.z,w[Q+3]=A.x,w[Q+4]=A.y,w[Q+5]=A.z,w[Q+6]=D.x,w[Q+7]=D.y,w[Q+8]=D.z,w[Q+9]=I.x,w[Q+10]=I.y,w[Q+11]=I.z;Q+=12}if(xa.length)B=xa[n.a],J=xa[n.b],w=xa[n.c],G=xa[n.d],Y[H]=B.x,Y[H+1]=B.y,Y[H+2]=B.z,Y[H+3]=B.w,Y[H+4]=J.x,Y[H+5]=J.y,Y[H+6]=J.z,Y[H+7]=J.w,Y[H+8]=w.x,Y[H+9]=w.y,Y[H+10]=w.z,Y[H+11]=w.w,Y[H+12]=G.x,Y[H+13]=G.y,Y[H+14]=G.z,Y[H+15]=G.w,B=Ga[n.a],J=Ga[n.b],w=Ga[n.c],G=Ga[n.d],
|
|
|
|
|
X[H]=B.x,X[H+1]=B.y,X[H+2]=B.z,X[H+3]=B.w,X[H+4]=J.x,X[H+5]=J.y,X[H+6]=J.z,X[H+7]=J.w,X[H+8]=w.x,X[H+9]=w.y,X[H+10]=w.z,X[H+11]=w.w,X[H+12]=G.x,X[H+13]=G.y,X[H+14]=G.z,X[H+15]=G.w,B=Ea[n.a],J=Ea[n.b],w=Ea[n.c],G=Ea[n.d],V[H]=B.x,V[H+1]=B.y,V[H+2]=B.z,V[H+3]=1,V[H+4]=J.x,V[H+5]=J.y,V[H+6]=J.z,V[H+7]=1,V[H+8]=w.x,V[H+9]=w.y,V[H+10]=w.z,V[H+11]=1,V[H+12]=G.x,V[H+13]=G.y,V[H+14]=G.z,V[H+15]=1,B=Fa[n.a],J=Fa[n.b],w=Fa[n.c],n=Fa[n.d],W[H]=B.x,W[H+1]=B.y,W[H+2]=B.z,W[H+3]=1,W[H+4]=J.x,W[H+5]=J.y,W[H+6]=
|
|
|
|
|
J.z,W[H+7]=1,W[H+8]=w.x,W[H+9]=w.y,W[H+10]=w.z,W[H+11]=1,W[H+12]=n.x,W[H+13]=n.y,W[H+14]=n.z,W[H+15]=1,H+=16;if(Va&&E)u.length==4&&E==THREE.VertexColors?(n=u[0],B=u[1],J=u[2],u=u[3]):u=J=B=n=v,ma[O]=n.r,ma[O+1]=n.g,ma[O+2]=n.b,ma[O+3]=B.r,ma[O+4]=B.g,ma[O+5]=B.b,ma[O+6]=J.r,ma[O+7]=J.g,ma[O+8]=J.b,ma[O+9]=u.r,ma[O+10]=u.g,ma[O+11]=u.b,O+=12;if(Ua&&oa.hasTangents)u=y[0],v=y[1],n=y[2],y=y[3],T[N]=u.x,T[N+1]=u.y,T[N+2]=u.z,T[N+3]=u.w,T[N+4]=v.x,T[N+5]=v.y,T[N+6]=v.z,T[N+7]=v.w,T[N+8]=n.x,T[N+9]=n.y,
|
|
|
|
|
T[N+10]=n.z,T[N+11]=n.w,T[N+12]=y.x,T[N+13]=y.y,T[N+14]=y.z,T[N+15]=y.w,N+=16;if(wa&&C)if(p.length==4&&ka)for(y=0;y<4;y++)t=p[y],fa[S]=t.x,fa[S+1]=t.y,fa[S+2]=t.z,S+=3;else for(y=0;y<4;y++)fa[S]=t.x,fa[S+1]=t.y,fa[S+2]=t.z,S+=3;if(qa&&F!==void 0&&x)for(y=0;y<4;y++)p=F[y],Z[la]=p.u,Z[la+1]=p.v,la+=2;if(qa&&ia!==void 0&&x)for(y=0;y<4;y++)p=ia[y],$[L]=p.u,$[L+1]=p.v,L+=2;va&&(aa[P]=da,aa[P+1]=da+1,aa[P+2]=da+3,aa[P+3]=da+1,aa[P+4]=da+2,aa[P+5]=da+3,P+=6,ea[R]=da,ea[R+1]=da+1,ea[R+2]=da,ea[R+3]=da+3,
|
|
|
|
|
ea[R+4]=da+1,ea[R+5]=da+2,ea[R+6]=da+2,ea[R+7]=da+3,R+=8,da+=4)}if(Ba){m=0;for(o=Ba.length;m<o;m++)aa[P]=Ba[m].a,aa[P+1]=Ba[m].b,aa[P+2]=Ba[m].c,aa[P+3]=Ba[m].a,aa[P+4]=Ba[m].c,aa[P+5]=Ba[m].d,P+=6}ya&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglVertexBuffer),g.bufferData(g.ARRAY_BUFFER,U,k));if(ca)for(M in ca)if(w=ca[M],w.needsUpdate)g.bindBuffer(g.ARRAY_BUFFER,w.buffer),g.bufferData(g.ARRAY_BUFFER,w.array,k),w.needsUpdate=!1;if(Wa){B=0;for(J=morphTargets.length;B<J;B++)g.bindBuffer(g.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[B]),
|
|
|
|
|
g.bufferData(g.ARRAY_BUFFER,ga[B],k)}Va&&O>0&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglColorBuffer),g.bufferData(g.ARRAY_BUFFER,ma,k));wa&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglNormalBuffer),g.bufferData(g.ARRAY_BUFFER,fa,k));Ua&&oa.hasTangents&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglTangentBuffer),g.bufferData(g.ARRAY_BUFFER,T,k));qa&&la>0&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglUVBuffer),g.bufferData(g.ARRAY_BUFFER,Z,k));qa&&L>0&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglUV2Buffer),g.bufferData(g.ARRAY_BUFFER,
|
|
|
|
|
$,k));va&&(g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),g.bufferData(g.ELEMENT_ARRAY_BUFFER,aa,k),g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),g.bufferData(g.ELEMENT_ARRAY_BUFFER,ea,k));H>0&&(g.bindBuffer(g.ARRAY_BUFFER,f.__webglSkinVertexABuffer),g.bufferData(g.ARRAY_BUFFER,V,k),g.bindBuffer(g.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),g.bufferData(g.ARRAY_BUFFER,W,k),g.bindBuffer(g.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),g.bufferData(g.ARRAY_BUFFER,X,k),g.bindBuffer(g.ARRAY_BUFFER,
|
|
|
|
|
f.__webglSkinWeightsBuffer),g.bufferData(g.ARRAY_BUFFER,Y,k));j.dynamic||(delete f.__inittedArrays,delete f.__colorArray,delete f.__normalArray,delete f.__tangentArray,delete f.__uvArray,delete f.__uv2Array,delete f.__faceArray,delete f.__vertexArray,delete f.__lineArray,delete f.__skinVertexAArray,delete f.__skinVertexBArray,delete f.__skinIndexArray,delete f.__skinWeightArray)}}}e.__dirtyVertices=!1;e.__dirtyMorphTargets=!1;e.__dirtyElements=!1;e.__dirtyUvs=!1;e.__dirtyNormals=!1;e.__dirtyTangents=
|
|
|
|
|
!1;e.__dirtyColors=!1}else if(b instanceof THREE.Ribbon){e=b.geometry;if(e.__dirtyVertices||e.__dirtyColors){b=e;d=g.DYNAMIC_DRAW;x=b.vertices;f=b.colors;E=x.length;j=f.length;C=b.__vertexArray;k=b.__colorArray;F=b.__dirtyColors;if(b.__dirtyVertices){for(m=0;m<E;m++)o=x[m].position,h=m*3,C[h]=o.x,C[h+1]=o.y,C[h+2]=o.z;g.bindBuffer(g.ARRAY_BUFFER,b.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,C,d)}if(F){for(m=0;m<j;m++)color=f[m],h=m*3,k[h]=color.r,k[h+1]=color.g,k[h+2]=color.b;g.bindBuffer(g.ARRAY_BUFFER,
|
|
|
|
|
b.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,k,d)}}e.__dirtyVertices=!1;e.__dirtyColors=!1}else if(b instanceof THREE.Line){e=b.geometry;if(e.__dirtyVertices||e.__dirtyColors){b=e;d=g.DYNAMIC_DRAW;x=b.vertices;f=b.colors;E=x.length;j=f.length;C=b.__vertexArray;k=b.__colorArray;F=b.__dirtyColors;if(b.__dirtyVertices){for(m=0;m<E;m++)o=x[m].position,h=m*3,C[h]=o.x,C[h+1]=o.y,C[h+2]=o.z;g.bindBuffer(g.ARRAY_BUFFER,b.__webglVertexBuffer);g.bufferData(g.ARRAY_BUFFER,C,d)}if(F){for(m=0;m<j;m++)color=
|
|
|
|
|
f[m],h=m*3,k[h]=color.r,k[h+1]=color.g,k[h+2]=color.b;g.bindBuffer(g.ARRAY_BUFFER,b.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,k,d)}}e.__dirtyVertices=!1;e.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)e=b.geometry,(e.__dirtyVertices||e.__dirtyColors||b.sortParticles)&&c(e,g.DYNAMIC_DRAW,b),e.__dirtyVertices=!1,e.__dirtyColors=!1}function D(b){function d(b){var f=[];c=0;for(e=b.length;c<e;c++)b[c]==void 0?f.push("undefined"):f.push(b[c].id);return f.join("_")}var c,e,f,g,h,j,k,m,
|
|
|
|
|
n={},o=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(g=b.faces.length;f<g;f++)h=b.faces[f],j=h.materials,k=d(j),n[k]==void 0&&(n[k]={hash:k,counter:0}),m=n[k].hash+"_"+n[k].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:j,vertices:0,numMorphTargets:o}),h=h instanceof THREE.Face3?3:4,b.geometryGroups[m].vertices+h>65535&&(n[k].counter+=1,m=n[k].hash+"_"+n[k].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:j,
|
|
|
|
|
vertices:0,numMorphTargets:o})),b.geometryGroups[m].faces.push(f),b.geometryGroups[m].vertices+=h}function x(b,d,c){b.push({buffer:d,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function I(b){if(b!=Q){switch(b){case THREE.AdditiveBlending:g.blendEquation(g.FUNC_ADD);g.blendFunc(g.SRC_ALPHA,g.ONE);break;case THREE.SubtractiveBlending:g.blendEquation(g.FUNC_ADD);g.blendFunc(g.ZERO,g.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:g.blendEquation(g.FUNC_ADD);g.blendFunc(g.ZERO,
|
|
|
|
|
g.SRC_COLOR);break;default:g.blendEquationSeparate(g.FUNC_ADD,g.FUNC_ADD),g.blendFuncSeparate(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA,g.ONE,g.ONE_MINUS_SRC_ALPHA)}Q=b}}function A(b,d,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(g.texParameteri(b,g.TEXTURE_WRAP_S,F(d.wrapS)),g.texParameteri(b,g.TEXTURE_WRAP_T,F(d.wrapT)),g.texParameteri(b,g.TEXTURE_MAG_FILTER,F(d.magFilter)),g.texParameteri(b,g.TEXTURE_MIN_FILTER,F(d.minFilter)),g.generateMipmap(b)):(g.texParameteri(b,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE),
|
|
|
|
|
g.texParameteri(b,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE),g.texParameteri(b,g.TEXTURE_MAG_FILTER,M(d.magFilter)),g.texParameteri(b,g.TEXTURE_MIN_FILTER,M(d.minFilter)))}function z(b,d){if(b.needsUpdate){if(b.__webglTexture)b.__webglTexture=g.deleteTexture(b.__webglTexture);b.__webglTexture=g.createTexture();g.bindTexture(g.TEXTURE_2D,b.__webglTexture);g.texImage2D(g.TEXTURE_2D,0,g.RGBA,g.RGBA,g.UNSIGNED_BYTE,b.image);A(g.TEXTURE_2D,b,b.image);g.bindTexture(g.TEXTURE_2D,null);b.needsUpdate=!1}g.activeTexture(g.TEXTURE0+
|
|
|
|
|
d);g.bindTexture(g.TEXTURE_2D,b.__webglTexture)}function S(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=g.createFramebuffer();b.__webglRenderbuffer=g.createRenderbuffer();b.__webglTexture=g.createTexture();g.bindTexture(g.TEXTURE_2D,b.__webglTexture);g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_S,F(b.wrapS));g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_T,F(b.wrapT));g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MAG_FILTER,
|
|
|
|
|
F(b.magFilter));g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,F(b.minFilter));g.texImage2D(g.TEXTURE_2D,0,F(b.format),b.width,b.height,0,F(b.format),F(b.type),null);g.bindRenderbuffer(g.RENDERBUFFER,b.__webglRenderbuffer);g.bindFramebuffer(g.FRAMEBUFFER,b.__webglFramebuffer);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_COMPONENT16,b.width,b.height),g.framebufferRenderbuffer(g.FRAMEBUFFER,
|
|
|
|
|
g.DEPTH_ATTACHMENT,g.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_STENCIL,b.width,b.height),g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_STENCIL_ATTACHMENT,g.RENDERBUFFER,b.__webglRenderbuffer)):g.renderbufferStorage(g.RENDERBUFFER,g.RGBA4,b.width,b.height);g.bindTexture(g.TEXTURE_2D,null);g.bindRenderbuffer(g.RENDERBUFFER,null);g.bindFramebuffer(g.FRAMEBUFFER,null)}var d,c;b?(d=b.__webglFramebuffer,c=b.width,b=b.height):(d=null,
|
|
|
|
|
c=ga,b=ca);d!=V&&(g.bindFramebuffer(g.FRAMEBUFFER,d),g.viewport(U,ka,c,b),V=d)}function G(b,d){var c;b=="fragment"?c=g.createShader(g.FRAGMENT_SHADER):b=="vertex"&&(c=g.createShader(g.VERTEX_SHADER));g.shaderSource(c,d);g.compileShader(c);if(!g.getShaderParameter(c,g.COMPILE_STATUS))return console.error(g.getShaderInfoLog(c)),console.error(d),null;return c}function M(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return g.NEAREST;default:return g.LINEAR}}
|
|
|
|
|
function F(b){switch(b){case THREE.RepeatWrapping:return g.REPEAT;case THREE.ClampToEdgeWrapping:return g.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return g.MIRRORED_REPEAT;case THREE.NearestFilter:return g.NEAREST;case THREE.NearestMipMapNearestFilter:return g.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return g.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return g.LINEAR;case THREE.LinearMipMapNearestFilter:return g.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return g.LINEAR_MIPMAP_LINEAR;
|
|
|
|
|
case THREE.ByteType:return g.BYTE;case THREE.UnsignedByteType:return g.UNSIGNED_BYTE;case THREE.ShortType:return g.SHORT;case THREE.UnsignedShortType:return g.UNSIGNED_SHORT;case THREE.IntType:return g.INT;case THREE.UnsignedShortType:return g.UNSIGNED_INT;case THREE.FloatType:return g.FLOAT;case THREE.AlphaFormat:return g.ALPHA;case THREE.RGBFormat:return g.RGB;case THREE.RGBAFormat:return g.RGBA;case THREE.LuminanceFormat:return g.LUMINANCE;case THREE.LuminanceAlphaFormat:return g.LUMINANCE_ALPHA}return 0}
|
|
|
|
|
var N=this,g,Y=[],O=null,V=null,L=!0,$=null,T=null,Q=null,fa=null,U=0,ka=0,ga=0,ca=0,aa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],R=new THREE.Matrix4,P=new Float32Array(16),W=new Float32Array(16),X=new THREE.Vector4,ea={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},ia=b.canvas!==void 0?b.canvas:document.createElement("canvas"),J=b.stencil!==void 0?b.stencil:
|
|
|
|
|
!0,da=b.antialias!==void 0?b.antialias:!1,la=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ma=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=ia;this.sortObjects=this.autoClear=!0;try{if(!(g=ia.getContext("experimental-webgl",{antialias:da,stencil:J})))throw"Error creating WebGL context.";}catch(ya){console.error(ya)}console.log(navigator.userAgent+" | "+g.getParameter(g.VERSION)+" | "+g.getParameter(g.VENDOR)+
|
|
|
|
|
" | "+g.getParameter(g.RENDERER)+" | "+g.getParameter(g.SHADING_LANGUAGE_VERSION));g.clearColor(0,0,0,1);g.clearDepth(1);g.enable(g.DEPTH_TEST);g.depthFunc(g.LEQUAL);g.frontFace(g.CCW);g.cullFace(g.BACK);g.enable(g.CULL_FACE);g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA);g.clearColor(la.r,la.g,la.b,ma);this.context=g;var va=g.getParameter(g.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(J){var Z={};Z.vertices=new Float32Array(12);Z.faces=new Uint16Array(6);Z.darkness=
|
|
|
|
|
0.5;Z.vertices[0]=-20;Z.vertices[1]=-20;Z.vertices[2]=-1;Z.vertices[3]=20;Z.vertices[4]=-20;Z.vertices[5]=-1;Z.vertices[6]=20;Z.vertices[7]=20;Z.vertices[8]=-1;Z.vertices[9]=-20;Z.vertices[10]=20;Z.vertices[11]=-1;Z.faces[0]=0;Z.faces[1]=1;Z.faces[2]=2;Z.faces[3]=0;Z.faces[4]=2;Z.faces[5]=3;Z.vertexBuffer=g.createBuffer();Z.elementBuffer=g.createBuffer();g.bindBuffer(g.ARRAY_BUFFER,Z.vertexBuffer);g.bufferData(g.ARRAY_BUFFER,Z.vertices,g.STATIC_DRAW);g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,Z.elementBuffer);
|
|
|
|
|
g.bufferData(g.ELEMENT_ARRAY_BUFFER,Z.faces,g.STATIC_DRAW);Z.program=g.createProgram();g.attachShader(Z.program,G("fragment",THREE.ShaderLib.shadowPost.fragmentShader));g.attachShader(Z.program,G("vertex",THREE.ShaderLib.shadowPost.vertexShader));g.linkProgram(Z.program);Z.vertexLocation=g.getAttribLocation(Z.program,"position");Z.projectionLocation=g.getUniformLocation(Z.program,"projectionMatrix");Z.darknessLocation=g.getUniformLocation(Z.program,"darkness")}var K={};K.vertices=new Float32Array(16);
|
|
|
|
|
K.faces=new Uint16Array(6);b=0;K.vertices[b++]=-1;K.vertices[b++]=-1;K.vertices[b++]=0;K.vertices[b++]=0;K.vertices[b++]=1;K.vertices[b++]=-1;K.vertices[b++]=1;K.vertices[b++]=0;K.vertices[b++]=1;K.vertices[b++]=1;K.vertices[b++]=1;K.vertices[b++]=1;K.vertices[b++]=-1;K.vertices[b++]=1;K.vertices[b++]=0;K.vertices[b++]=1;b=0;K.faces[b++]=0;K.faces[b++]=1;K.faces[b++]=2;K.faces[b++]=0;K.faces[b++]=2;K.faces[b++]=3;K.vertexBuffer=g.createBuffer();K.elementBuffer=g.createBuffer();K.tempTexture=g.createTexture();
|
|
|
|
|
K.occlusionTexture=g.createTexture();g.bindBuffer(g.ARRAY_BUFFER,K.vertexBuffer);g.bufferData(g.ARRAY_BUFFER,K.vertices,g.STATIC_DRAW);g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,K.elementBuffer);g.bufferData(g.ELEMENT_ARRAY_BUFFER,K.faces,g.STATIC_DRAW);g.bindTexture(g.TEXTURE_2D,K.tempTexture);g.texImage2D(g.TEXTURE_2D,0,g.RGB,16,16,0,g.RGB,g.UNSIGNED_BYTE,null);g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE);g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE);g.texParameteri(g.TEXTURE_2D,
|
|
|
|
|
g.TEXTURE_MAG_FILTER,g.NEAREST);g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,g.NEAREST);g.bindTexture(g.TEXTURE_2D,K.occlusionTexture);g.texImage2D(g.TEXTURE_2D,0,g.RGBA,16,16,0,g.RGBA,g.UNSIGNED_BYTE,null);g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_S,g.CLAMP_TO_EDGE);g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_T,g.CLAMP_TO_EDGE);g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MAG_FILTER,g.NEAREST);g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,g.NEAREST);g.getParameter(g.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=
|
|
|
|
|
0?(K.hasVertexTexture=!1,K.program=g.createProgram(),g.attachShader(K.program,G("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),g.attachShader(K.program,G("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(K.hasVertexTexture=!0,K.program=g.createProgram(),g.attachShader(K.program,G("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),g.attachShader(K.program,G("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));g.linkProgram(K.program);K.attributes={};K.uniforms={};
|
|
|
|
|
K.attributes.vertex=g.getAttribLocation(K.program,"position");K.attributes.uv=g.getAttribLocation(K.program,"UV");K.uniforms.renderType=g.getUniformLocation(K.program,"renderType");K.uniforms.map=g.getUniformLocation(K.program,"map");K.uniforms.occlusionMap=g.getUniformLocation(K.program,"occlusionMap");K.uniforms.opacity=g.getUniformLocation(K.program,"opacity");K.uniforms.scale=g.getUniformLocation(K.program,"scale");K.uniforms.rotation=g.getUniformLocation(K.program,"rotation");K.uniforms.screenPosition=
|
|
|
|
|
g.getUniformLocation(K.program,"screenPosition");var wa=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=
|
|
|
|
|
0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=g.createBuffer();_sprite.elementBuffer=g.createBuffer();g.bindBuffer(g.ARRAY_BUFFER,_sprite.vertexBuffer);g.bufferData(g.ARRAY_BUFFER,_sprite.vertices,g.STATIC_DRAW);g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);g.bufferData(g.ELEMENT_ARRAY_BUFFER,_sprite.faces,g.STATIC_DRAW);_sprite.program=g.createProgram();
|
|
|
|
|
g.attachShader(_sprite.program,G("fragment",THREE.ShaderLib.sprite.fragmentShader));g.attachShader(_sprite.program,G("vertex",THREE.ShaderLib.sprite.vertexShader));g.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=g.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=g.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=g.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=g.getUniformLocation(_sprite.program,
|
|
|
|
|
"uvScale");_sprite.uniforms.rotation=g.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=g.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=g.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=g.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=g.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=g.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=
|
|
|
|
|
g.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=g.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=g.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=g.getUniformLocation(_sprite.program,"projectionMatrix");var qa=!1;this.setSize=function(b,d){ia.width=b;ia.height=d;this.setViewport(0,0,ia.width,ia.height)};this.setViewport=function(b,d,c,e){U=b;ka=d;ga=c;ca=e;g.viewport(U,ka,ga,
|
|
|
|
|
ca)};this.setScissor=function(b,d,c,e){g.scissor(b,d,c,e)};this.enableScissorTest=function(b){b?g.enable(g.SCISSOR_TEST):g.disable(g.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){L=b;g.depthMask(b)};this.setClearColorHex=function(b,d){la.setHex(b);ma=d;g.clearColor(la.r,la.g,la.b,ma)};this.setClearColor=function(b,d){la.copy(b);ma=d;g.clearColor(la.r,la.g,la.b,ma)};this.clear=function(){g.clear(g.COLOR_BUFFER_BIT|g.DEPTH_BUFFER_BIT|g.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){Z.darkness=
|
|
|
|
|
b};this.getContext=function(){return g};this.initMaterial=function(b,d,c,e){var f,h,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?j="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");
|
|
|
|
|
if(j){var k=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(k.uniforms);b.vertexShader=k.vertexShader;b.fragmentShader=k.fragmentShader}var m,n,o;m=o=k=0;for(n=d.length;m<n;m++)h=d[m],h instanceof THREE.DirectionalLight&&o++,h instanceof THREE.PointLight&&k++;k+o<=4?d=o:(d=Math.ceil(4*o/(k+o)),k=4-d);h={directional:d,point:k};o=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)o=e.bones.length;var p;a:{m=b.fragmentShader;n=b.vertexShader;var k=b.uniforms,d=b.attributes,c={map:!!b.map,envMap:!!b.envMap,
|
|
|
|
|
lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:c,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:h.directional,maxPointLights:h.point,maxBones:o},t;h=[];j?h.push(j):(h.push(m),h.push(n));for(t in c)h.push(t),h.push(c[t]);j=h.join();t=0;for(h=Y.length;t<h;t++)if(Y[t].code==j){p=Y[t].program;break a}t=g.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,
|
|
|
|
|
"#define MAX_POINT_LIGHTS "+c.maxPointLights,c.fog?"#define USE_FOG":"",c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[va?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_BONES "+c.maxBones,c.map?
|
|
|
|
|
THREE.WebGLRenderer=function(b){function c(b,e,c){var f,j,g,k=b.vertices,m=k.length,n=b.colors,p=n.length,t=b.__vertexArray,o=b.__colorArray,u=b.__sortArray,v=b.__dirtyVertices,w=b.__dirtyColors;if(c.sortParticles){Q.multiplySelf(c.matrixWorld);for(f=0;f<m;f++)j=k[f].position,ka.copy(j),Q.multiplyVector3(ka),u[f]=[ka.z,f];u.sort(function(b,e){return e[0]-b[0]});for(f=0;f<m;f++)j=k[u[f][1]].position,g=f*3,t[g]=j.x,t[g+1]=j.y,t[g+2]=j.z;for(f=0;f<p;f++)g=f*3,color=n[u[f][1]],o[g]=color.r,o[g+1]=color.g,
|
|
|
|
|
o[g+2]=color.b}else{if(v)for(f=0;f<m;f++)j=k[f].position,g=f*3,t[g]=j.x,t[g+1]=j.y,t[g+2]=j.z;if(w)for(f=0;f<p;f++)color=n[f],g=f*3,o[g]=color.r,o[g+1]=color.g,o[g+2]=color.b}if(v||c.sortParticles)h.bindBuffer(h.ARRAY_BUFFER,b.__webglVertexBuffer),h.bufferData(h.ARRAY_BUFFER,t,e);if(w||c.sortParticles)h.bindBuffer(h.ARRAY_BUFFER,b.__webglColorBuffer),h.bufferData(h.ARRAY_BUFFER,o,e)}function e(b,e,c,f,j){f.program||V.initMaterial(f,e,c,j);var g=f.program,k=g.uniforms,m=f.uniforms;g!=O&&(h.useProgram(g),
|
|
|
|
|
O=g);h.uniformMatrix4fv(k.projectionMatrix,!1,T);if(c&&(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial||f instanceof THREE.LineBasicMaterial||f instanceof THREE.ParticleBasicMaterial||f.fog))if(m.fogColor.value=c.color,c instanceof THREE.Fog)m.fogNear.value=c.near,m.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)m.fogDensity.value=c.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var n,
|
|
|
|
|
p,t=0,o=0,u=0,v,w,B,A,E=na,H=E.directional.colors,J=E.directional.positions,I=E.point.colors,K=E.point.positions,ma=E.point.distances,D=0,F=0,c=p=A=0;for(n=e.length;c<n;c++)if(p=e[c],v=p.color,w=p.position,B=p.intensity,A=p.distance,p instanceof THREE.AmbientLight)t+=v.r,o+=v.g,u+=v.b;else if(p instanceof THREE.DirectionalLight)A=D*3,H[A]=v.r*B,H[A+1]=v.g*B,H[A+2]=v.b*B,J[A]=w.x,J[A+1]=w.y,J[A+2]=w.z,D+=1;else if(p instanceof THREE.PointLight)p=F*3,I[p]=v.r*B,I[p+1]=v.g*B,I[p+2]=v.b*B,K[p]=w.x,K[p+
|
|
|
|
|
1]=w.y,K[p+2]=w.z,ma[F]=A,F+=1;for(c=D*3;c<H.length;c++)H[c]=0;for(c=F*3;c<I.length;c++)I[c]=0;E.point.length=F;E.directional.length=D;E.ambient[0]=t;E.ambient[1]=o;E.ambient[2]=u;c=na;m.enableLighting.value=c.directional.length+c.point.length;m.ambientLightColor.value=c.ambient;m.directionalLightColor.value=c.directional.colors;m.directionalLightDirection.value=c.directional.positions;m.pointLightColor.value=c.point.colors;m.pointLightPosition.value=c.point.positions;m.pointLightDistance.value=c.point.distances}if(f instanceof
|
|
|
|
|
THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)m.diffuse.value=f.color,m.opacity.value=f.opacity,(m.map.texture=f.map)&&m.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),m.lightMap.texture=f.lightMap,m.envMap.texture=f.envMap,m.reflectivity.value=f.reflectivity,m.refractionRatio.value=f.refractionRatio,m.combine.value=f.combine,m.useRefract.value=f.envMap&&f.envMap.mapping instanceof THREE.CubeRefractionMapping;
|
|
|
|
|
if(f instanceof THREE.LineBasicMaterial)m.diffuse.value=f.color,m.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)m.psColor.value=f.color,m.opacity.value=f.opacity,m.size.value=f.size,m.scale.value=ca.height/2,m.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)m.ambient.value=f.ambient,m.specular.value=f.specular,m.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)m.mNear.value=b.near,m.mFar.value=b.far,m.opacity.value=f.opacity;else if(f instanceof
|
|
|
|
|
THREE.MeshNormalMaterial)m.opacity.value=f.opacity;for(var N in m)if(o=g.uniforms[N])if(n=m[N],t=n.type,c=n.value,t=="i")h.uniform1i(o,c);else if(t=="f")h.uniform1f(o,c);else if(t=="fv1")h.uniform1fv(o,c);else if(t=="fv")h.uniform3fv(o,c);else if(t=="v2")h.uniform2f(o,c.x,c.y);else if(t=="v3")h.uniform3f(o,c.x,c.y,c.z);else if(t=="v4")h.uniform4f(o,c.x,c.y,c.z,c.w);else if(t=="c")h.uniform3f(o,c.r,c.g,c.b);else if(t=="t"&&(h.uniform1i(o,c),n=n.texture))if(n.image instanceof Array&&n.image.length==
|
|
|
|
|
6){if(n.image.length==6){if(n.needsUpdate){if(n.__webglInit){h.bindTexture(h.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);for(t=0;t<6;++t)h.texSubImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,h.RGBA,h.UNSIGNED_BYTE,n.image[t])}else{n.image.__webglTextureCube=h.createTexture();h.bindTexture(h.TEXTURE_CUBE_MAP,n.image.__webglTextureCube);for(t=0;t<6;++t)h.texImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,n.image[t]);n.__webglInit=!0}G(h.TEXTURE_CUBE_MAP,n,n.image[0]);h.bindTexture(h.TEXTURE_CUBE_MAP,
|
|
|
|
|
null);n.needsUpdate=!1}h.activeTexture(h.TEXTURE0+c);h.bindTexture(h.TEXTURE_CUBE_MAP,n.image.__webglTextureCube)}}else C(n,c);h.uniformMatrix4fv(k.modelViewMatrix,!1,j._modelViewMatrixArray);h.uniformMatrix3fv(k.normalMatrix,!1,j._normalMatrixArray);(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&k.cameraPosition!==null&&h.uniform3f(k.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning)&&k.objectMatrix!==
|
|
|
|
|
null&&h.uniformMatrix4fv(k.objectMatrix,!1,j._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&k.viewMatrix!==null&&h.uniformMatrix4fv(k.viewMatrix,!1,Z);if(f instanceof THREE.ShadowVolumeDynamicMaterial)b=m.directionalLightDirection.value,b[0]=-e[1].position.x,b[1]=-e[1].position.y,b[2]=-e[1].position.z,h.uniform3fv(k.directionalLightDirection,b),h.uniformMatrix4fv(k.objectMatrix,!1,j._objectMatrixArray),
|
|
|
|
|
h.uniformMatrix4fv(k.viewMatrix,!1,Z);f.skinning&&(h.uniformMatrix4fv(k.cameraInverseMatrix,!1,Z),h.uniformMatrix4fv(k.boneGlobalMatrices,!1,j.boneMatrices));return g}function f(b,c,f,j,g,k){if(j.opacity!=0){var m,b=e(b,c,f,j,k).attributes;if(!j.morphTargets&&b.position>=0)h.bindBuffer(h.ARRAY_BUFFER,g.__webglVertexBuffer),h.vertexAttribPointer(b.position,3,h.FLOAT,!1,0,0);else{c=j.program.attributes;k.morphTargetBase!==-1?(h.bindBuffer(h.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[k.morphTargetBase]),
|
|
|
|
|
h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0)):c.position>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglVertexBuffer),h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,n=k.morphTargetForcedOrder,p=k.morphTargetInfluences;f<j.numSupportedMorphTargets&&f<n.length;)h.bindBuffer(h.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[n[f]]),h.vertexAttribPointer(c["morphTarget"+f],3,h.FLOAT,!1,0,0),k.__webglMorphTargetInfluences[f]=p[n[f]],f++;else{var n=[],t=-1,
|
|
|
|
|
o=0,p=k.morphTargetInfluences,u,v=p.length,f=0;for(k.morphTargetBase!==-1&&(n[k.morphTargetBase]=!0);f<j.numSupportedMorphTargets;){for(u=0;u<v;u++)!n[u]&&p[u]>t&&(o=u,t=p[o]);h.bindBuffer(h.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[o]);h.vertexAttribPointer(c["morphTarget"+f],3,h.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=t;n[o]=1;t=-1;f++}}j.program.uniforms.morphTargetInfluences!==null&&h.uniform1fv(j.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(m in g.__webglCustomAttributes)b[m]>=
|
|
|
|
|
0&&(c=g.__webglCustomAttributes[m],h.bindBuffer(h.ARRAY_BUFFER,c.buffer),h.vertexAttribPointer(b[m],c.size,h.FLOAT,!1,0,0));b.color>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglColorBuffer),h.vertexAttribPointer(b.color,3,h.FLOAT,!1,0,0));b.normal>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglNormalBuffer),h.vertexAttribPointer(b.normal,3,h.FLOAT,!1,0,0));b.tangent>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglTangentBuffer),h.vertexAttribPointer(b.tangent,4,h.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(h.bindBuffer(h.ARRAY_BUFFER,
|
|
|
|
|
g.__webglUVBuffer),h.vertexAttribPointer(b.uv,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv)):h.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(h.bindBuffer(h.ARRAY_BUFFER,g.__webglUV2Buffer),h.vertexAttribPointer(b.uv2,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv2)):h.disableVertexAttribArray(b.uv2));j.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexABuffer),h.vertexAttribPointer(b.skinVertexA,4,
|
|
|
|
|
h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),h.vertexAttribPointer(b.skinVertexB,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),h.vertexAttribPointer(b.skinIndex,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),h.vertexAttribPointer(b.skinWeight,4,h.FLOAT,!1,0,0));k instanceof THREE.Mesh?(j.wireframe?(h.lineWidth(j.wireframeLinewidth),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),h.drawElements(h.LINES,g.__webglLineCount,
|
|
|
|
|
h.UNSIGNED_SHORT,0)):(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),h.drawElements(h.TRIANGLES,g.__webglFaceCount,h.UNSIGNED_SHORT,0)),V.data.vertices+=g.__webglFaceCount,V.data.faces+=g.__webglFaceCount/3,V.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip?h.LINE_STRIP:h.LINES,h.lineWidth(j.linewidth),h.drawArrays(k,0,g.__webglLineCount),V.data.drawCalls++):k instanceof THREE.ParticleSystem?(h.drawArrays(h.POINTS,0,g.__webglParticleCount),V.data.drawCalls++):k instanceof
|
|
|
|
|
THREE.Ribbon&&(h.drawArrays(h.TRIANGLE_STRIP,0,g.__webglVertexCount),V.data.drawCalls++)}}function g(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=h.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=h.createBuffer();b.hasPos&&(h.bindBuffer(h.ARRAY_BUFFER,b.__webglVertexBuffer),h.bufferData(h.ARRAY_BUFFER,b.positionArray,h.DYNAMIC_DRAW),h.enableVertexAttribArray(e.attributes.position),h.vertexAttribPointer(e.attributes.position,3,h.FLOAT,!1,0,0));if(b.hasNormal){h.bindBuffer(h.ARRAY_BUFFER,
|
|
|
|
|
b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,g,j,k,m,n,p,t,o,u,v=b.count*3;for(u=0;u<v;u+=9)c=b.normalArray,f=c[u],g=c[u+1],j=c[u+2],k=c[u+3],n=c[u+4],t=c[u+5],m=c[u+6],p=c[u+7],o=c[u+8],f=(f+k+m)/3,g=(g+n+p)/3,j=(j+t+o)/3,c[u]=f,c[u+1]=g,c[u+2]=j,c[u+3]=f,c[u+4]=g,c[u+5]=j,c[u+6]=f,c[u+7]=g,c[u+8]=j}h.bufferData(h.ARRAY_BUFFER,b.normalArray,h.DYNAMIC_DRAW);h.enableVertexAttribArray(e.attributes.normal);h.vertexAttribPointer(e.attributes.normal,3,h.FLOAT,!1,0,0)}h.drawArrays(h.TRIANGLES,
|
|
|
|
|
0,b.count);b.count=0}function j(b){if(da!=b.doubleSided)b.doubleSided?h.disable(h.CULL_FACE):h.enable(h.CULL_FACE),da=b.doubleSided;if(U!=b.flipSided)b.flipSided?h.frontFace(h.CW):h.frontFace(h.CCW),U=b.flipSided}function k(b){ja!=b&&(b?h.enable(h.DEPTH_TEST):h.disable(h.DEPTH_TEST),ja=b)}function m(b){fa[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);fa[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);fa[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);fa[3].set(b.n41-b.n21,
|
|
|
|
|
b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);fa[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);fa[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var e,b=0;b<6;b++)e=fa[b],e.divideScalar(Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z))}function n(b){for(var e=b.matrixWorld,c=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),f=0;f<6;f++)if(b=fa[f].x*e.n14+fa[f].y*e.n24+fa[f].z*e.n34+fa[f].w,b<=c)return!1;return!0}function p(b,e){b.list[b.count]=e;b.count+=1}function o(b){var e,
|
|
|
|
|
c,f=b.object,h=b.opaque,g=b.transparent;g.count=0;b=h.count=0;for(e=f.materials.length;b<e;b++)c=f.materials[b],c.transparent?p(g,c):p(h,c)}function t(b){var e,c,f,h,g=b.object,j=b.buffer,k=b.opaque,m=b.transparent;m.count=0;b=k.count=0;for(f=g.materials.length;b<f;b++)if(e=g.materials[b],e instanceof THREE.MeshFaceMaterial){e=0;for(c=j.materials.length;e<c;e++)(h=j.materials[e])&&(h.transparent?p(m,h):p(k,h))}else(h=e)&&(h.transparent?p(m,h):p(k,h))}function u(b,e){return e.z-b.z}function v(b){h.enable(h.POLYGON_OFFSET_FILL);
|
|
|
|
|
h.polygonOffset(0.1,1);h.enable(h.STENCIL_TEST);h.enable(h.DEPTH_TEST);h.depthMask(!1);h.colorMask(!1,!1,!1,!1);h.stencilFunc(h.ALWAYS,1,255);h.stencilOpSeparate(h.BACK,h.KEEP,h.INCR,h.KEEP);h.stencilOpSeparate(h.FRONT,h.KEEP,h.DECR,h.KEEP);var e,c=b.lights.length,f,g=b.lights,j=[],k,m,n,p,t,o=b.__webglShadowVolumes.length;for(e=0;e<c;e++)if(f=b.lights[e],f instanceof THREE.DirectionalLight&&f.castShadow){j[0]=-f.position.x;j[1]=-f.position.y;j[2]=-f.position.z;for(t=0;t<o;t++)f=b.__webglShadowVolumes[t].object,
|
|
|
|
|
k=b.__webglShadowVolumes[t].buffer,m=f.materials[0],m.program||V.initMaterial(m,g,void 0,f),m=m.program,n=m.uniforms,p=m.attributes,O!==m&&(h.useProgram(m),O=m,h.uniformMatrix4fv(n.projectionMatrix,!1,T),h.uniformMatrix4fv(n.viewMatrix,!1,Z),h.uniform3fv(n.directionalLightDirection,j)),f.matrixWorld.flattenToArray(f._objectMatrixArray),h.uniformMatrix4fv(n.objectMatrix,!1,f._objectMatrixArray),h.bindBuffer(h.ARRAY_BUFFER,k.__webglVertexBuffer),h.vertexAttribPointer(p.position,3,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,
|
|
|
|
|
k.__webglNormalBuffer),h.vertexAttribPointer(p.normal,3,h.FLOAT,!1,0,0),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,k.__webglFaceBuffer),h.cullFace(h.FRONT),h.drawElements(h.TRIANGLES,k.__webglFaceCount,h.UNSIGNED_SHORT,0),h.cullFace(h.BACK),h.drawElements(h.TRIANGLES,k.__webglFaceCount,h.UNSIGNED_SHORT,0)}h.disable(h.POLYGON_OFFSET_FILL);h.colorMask(!0,!0,!0,!0);h.stencilFunc(h.NOTEQUAL,0,255);h.stencilOp(h.KEEP,h.KEEP,h.KEEP);h.disable(h.DEPTH_TEST);S=-1;O=ea.program;h.useProgram(ea.program);h.uniformMatrix4fv(ea.projectionLocation,
|
|
|
|
|
!1,T);h.uniform1f(ea.darknessLocation,ea.darkness);h.bindBuffer(h.ARRAY_BUFFER,ea.vertexBuffer);h.vertexAttribPointer(ea.vertexLocation,3,h.FLOAT,!1,0,0);h.enableVertexAttribArray(ea.vertexLocation);h.blendFunc(h.ONE,h.ONE_MINUS_SRC_ALPHA);h.blendEquation(h.FUNC_ADD);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,ea.elementBuffer);h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0);h.disable(h.STENCIL_TEST);h.enable(h.DEPTH_TEST);h.depthMask(M)}function w(b,e){var c,f,g;c=_sprite.attributes;var j=_sprite.uniforms,
|
|
|
|
|
k=ha/Y,m,n=[],p=Y*0.5,t=ha*0.5,o=!0;h.useProgram(_sprite.program);O=_sprite.program;S=-1;ta||(h.enableVertexAttribArray(_sprite.attributes.position),h.enableVertexAttribArray(_sprite.attributes.uv),ta=!0);h.disable(h.CULL_FACE);h.enable(h.BLEND);h.depthMask(!0);h.bindBuffer(h.ARRAY_BUFFER,_sprite.vertexBuffer);h.vertexAttribPointer(c.position,2,h.FLOAT,!1,16,0);h.vertexAttribPointer(c.uv,2,h.FLOAT,!1,16,8);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);h.uniformMatrix4fv(j.projectionMatrix,
|
|
|
|
|
!1,T);h.activeTexture(h.TEXTURE0);h.uniform1i(j.map,0);c=0;for(f=b.__webglSprites.length;c<f;c++)g=b.__webglSprites[c],g.useScreenCoordinates?g.z=-g.position.z:(g._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,g.matrixWorld,g._modelViewMatrixArray),g.z=-g._modelViewMatrix.n34);b.__webglSprites.sort(u);c=0;for(f=b.__webglSprites.length;c<f;c++)g=b.__webglSprites[c],g.material===void 0&&g.map&&g.map.image&&g.map.image.width&&(g.useScreenCoordinates?(h.uniform1i(j.useScreenCoordinates,1),h.uniform3f(j.screenPosition,
|
|
|
|
|
(g.position.x-p)/p,(t-g.position.y)/t,Math.max(0,Math.min(1,g.position.z)))):(h.uniform1i(j.useScreenCoordinates,0),h.uniform1i(j.affectedByDistance,g.affectedByDistance?1:0),h.uniformMatrix4fv(j.modelViewMatrix,!1,g._modelViewMatrixArray)),m=g.map.image.width/(g.affectedByDistance?1:ha),n[0]=m*k*g.scale.x,n[1]=m*g.scale.y,h.uniform2f(j.uvScale,g.uvScale.x,g.uvScale.y),h.uniform2f(j.uvOffset,g.uvOffset.x,g.uvOffset.y),h.uniform2f(j.alignment,g.alignment.x,g.alignment.y),h.uniform1f(j.opacity,g.opacity),
|
|
|
|
|
h.uniform1f(j.rotation,g.rotation),h.uniform2fv(j.scale,n),g.mergeWith3D&&!o?(h.enable(h.DEPTH_TEST),o=!0):!g.mergeWith3D&&o&&(h.disable(h.DEPTH_TEST),o=!1),I(g.blending),C(g.map,0),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0));h.enable(h.CULL_FACE);h.enable(h.DEPTH_TEST);h.depthMask(M)}function E(b,e){var c,f,g=b.__webglLensFlares.length,j,k,m,n=new THREE.Vector3,p=ha/Y,t=Y*0.5,o=ha*0.5,u=16/ha,v=[u*p,u],w=[1,1,0],B=[1,1],A=P.uniforms;c=P.attributes;h.useProgram(P.program);O=P.program;S=-1;za||
|
|
|
|
|
(h.enableVertexAttribArray(P.attributes.vertex),h.enableVertexAttribArray(P.attributes.uv),za=!0);h.uniform1i(A.occlusionMap,0);h.uniform1i(A.map,1);h.bindBuffer(h.ARRAY_BUFFER,P.vertexBuffer);h.vertexAttribPointer(c.vertex,2,h.FLOAT,!1,16,0);h.vertexAttribPointer(c.uv,2,h.FLOAT,!1,16,8);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,P.elementBuffer);h.disable(h.CULL_FACE);h.depthMask(!1);h.activeTexture(h.TEXTURE0);h.bindTexture(h.TEXTURE_2D,P.occlusionTexture);h.activeTexture(h.TEXTURE1);for(f=0;f<g;f++)if(c=
|
|
|
|
|
b.__webglLensFlares[f].object,n.set(c.matrixWorld.n14,c.matrixWorld.n24,c.matrixWorld.n34),e.matrixWorldInverse.multiplyVector3(n),e.projectionMatrix.multiplyVector3(n),w[0]=n.x,w[1]=n.y,w[2]=n.z,B[0]=w[0]*t+t,B[1]=w[1]*o+o,P.hasVertexTexture||B[0]>0&&B[0]<Y&&B[1]>0&&B[1]<ha){h.bindTexture(h.TEXTURE_2D,P.tempTexture);h.copyTexImage2D(h.TEXTURE_2D,0,h.RGB,B[0]-8,B[1]-8,16,16,0);h.uniform1i(A.renderType,0);h.uniform2fv(A.scale,v);h.uniform3fv(A.screenPosition,w);h.disable(h.BLEND);h.enable(h.DEPTH_TEST);
|
|
|
|
|
h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0);h.bindTexture(h.TEXTURE_2D,P.occlusionTexture);h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,B[0]-8,B[1]-8,16,16,0);h.uniform1i(A.renderType,1);h.disable(h.DEPTH_TEST);h.bindTexture(h.TEXTURE_2D,P.tempTexture);h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0);c.positionScreen.x=w[0];c.positionScreen.y=w[1];c.positionScreen.z=w[2];c.customUpdateCallback?c.customUpdateCallback(c):c.updateLensFlares();h.uniform1i(A.renderType,2);h.enable(h.BLEND);j=0;for(k=c.lensFlares.length;j<
|
|
|
|
|
k;j++)if(m=c.lensFlares[j],m.opacity>0.0010&&m.scale>0.0010)w[0]=m.x,w[1]=m.y,w[2]=m.z,u=m.size*m.scale/ha,v[0]=u*p,v[1]=u,h.uniform3fv(A.screenPosition,w),h.uniform2fv(A.scale,v),h.uniform1f(A.rotation,m.rotation),h.uniform1f(A.opacity,m.opacity),I(m.blending),C(m.texture,1),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0)}h.enable(h.CULL_FACE);h.enable(h.DEPTH_TEST);h.depthMask(M)}function H(b,e){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}
|
|
|
|
|
function B(b){var e,f,g,j,k;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){g=f.geometryGroups[e];k=!1;for(j in g.__webglCustomAttributes)if(g.__webglCustomAttributes[j].needsUpdate){k=!0;break}if(f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||k){k=b;var m=h.DYNAMIC_DRAW;if(g.__inittedArrays){var n=void 0,p=void 0,t=void 0,o=void 0,u=t=void 0,v=void 0,w=void 0,B=void 0,A=void 0,E=void 0,H=void 0,
|
|
|
|
|
J=void 0,ca=void 0,C=void 0,G=void 0,I=void 0,K=void 0,F=o=B=o=w=v=void 0,D=void 0,z=D=F=v=void 0,ma=void 0,N=z=D=F=t=t=u=B=o=z=D=F=ma=z=D=F=ma=z=D=F=void 0,M=0,ia=0,P=0,pa=0,R=0,V=0,O=0,T=0,Q=0,L=0,S=0,D=F=0,W=g.__vertexArray,ea=g.__uvArray,da=g.__uv2Array,ja=g.__normalArray,U=g.__tangentArray,aa=g.__colorArray,la=g.__skinVertexAArray,X=g.__skinVertexBArray,Y=g.__skinIndexArray,Z=g.__skinWeightArray,ka=g.__morphTargetsArrays,ha=g.__webglCustomAttributes,z=void 0,fa=g.__faceArray,ga=g.__lineArray,
|
|
|
|
|
na=g.__needsSmoothNormals,E=g.__vertexColorType,A=g.__uvType,H=g.__normalType,ra=k.geometry,Ba=ra.__dirtyVertices,ya=ra.__dirtyElements,ta=ra.__dirtyUvs,za=ra.__dirtyNormals,Xa=ra.__dirtyTangents,Ya=ra.__dirtyColors,Za=ra.__dirtyMorphTargets,Ga=ra.vertices,ab=g.faces,db=ra.faces,bb=ra.faceVertexUvs[0],cb=ra.faceVertexUvs[1],Ha=ra.skinVerticesA,Ia=ra.skinVerticesB,Ja=ra.skinIndices,Aa=ra.skinWeights,Ea=k instanceof THREE.ShadowVolume?ra.edgeFaces:void 0;morphTargets=ra.morphTargets;if(ha)for(N in ha)ha[N].offset=
|
|
|
|
|
0,ha[N].offsetSrc=0;n=0;for(p=ab.length;n<p;n++)if(t=ab[n],o=db[t],bb&&(J=bb[t]),cb&&(ca=cb[t]),t=o.vertexNormals,u=o.normal,v=o.vertexColors,w=o.color,B=o.vertexTangents,o instanceof THREE.Face3){if(Ba)C=Ga[o.a].position,G=Ga[o.b].position,I=Ga[o.c].position,W[ia]=C.x,W[ia+1]=C.y,W[ia+2]=C.z,W[ia+3]=G.x,W[ia+4]=G.y,W[ia+5]=G.z,W[ia+6]=I.x,W[ia+7]=I.y,W[ia+8]=I.z,ia+=9;if(ha)for(N in ha)if(z=ha[N],z.needsUpdate)F=z.offset,D=z.offsetSrc,z.size===1?(z.boundTo===void 0||z.boundTo==="vertices"?(z.array[F+
|
|
|
|
|
0]=z.value[o.a],z.array[F+1]=z.value[o.b],z.array[F+2]=z.value[o.c]):z.boundTo==="faces"?(z.array[F+0]=z.value[D],z.array[F+1]=z.value[D],z.array[F+2]=z.value[D],z.offsetSrc++):z.boundTo==="faceVertices"&&(z.array[F+0]=z.value[D+0],z.array[F+1]=z.value[D+1],z.array[F+2]=z.value[D+2],z.offsetSrc+=3),z.offset+=3):(z.boundTo===void 0||z.boundTo==="vertices"?(C=z.value[o.a],G=z.value[o.b],I=z.value[o.c]):z.boundTo==="faces"?(C=z.value[D],G=z.value[D],I=z.value[D],z.offsetSrc++):z.boundTo==="faceVertices"&&
|
|
|
|
|
(C=z.value[D+0],G=z.value[D+1],I=z.value[D+2],z.offsetSrc+=3),z.size===2?(z.array[F+0]=C.x,z.array[F+1]=C.y,z.array[F+2]=G.x,z.array[F+3]=G.y,z.array[F+4]=I.x,z.array[F+5]=I.y,z.offset+=6):z.size===3?(z.type==="c"?(z.array[F+0]=C.r,z.array[F+1]=C.g,z.array[F+2]=C.b,z.array[F+3]=G.r,z.array[F+4]=G.g,z.array[F+5]=G.b,z.array[F+6]=I.r,z.array[F+7]=I.g,z.array[F+8]=I.b):(z.array[F+0]=C.x,z.array[F+1]=C.y,z.array[F+2]=C.z,z.array[F+3]=G.x,z.array[F+4]=G.y,z.array[F+5]=G.z,z.array[F+6]=I.x,z.array[F+7]=
|
|
|
|
|
I.y,z.array[F+8]=I.z),z.offset+=9):(z.array[F+0]=C.x,z.array[F+1]=C.y,z.array[F+2]=C.z,z.array[F+3]=C.w,z.array[F+4]=G.x,z.array[F+5]=G.y,z.array[F+6]=G.z,z.array[F+7]=G.w,z.array[F+8]=I.x,z.array[F+9]=I.y,z.array[F+10]=I.z,z.array[F+11]=I.w,z.offset+=12));if(Za){F=0;for(D=morphTargets.length;F<D;F++)C=morphTargets[F].vertices[o.a].position,G=morphTargets[F].vertices[o.b].position,I=morphTargets[F].vertices[o.c].position,z=ka[F],z[S+0]=C.x,z[S+1]=C.y,z[S+2]=C.z,z[S+3]=G.x,z[S+4]=G.y,z[S+5]=G.z,z[S+
|
|
|
|
|
6]=I.x,z[S+7]=I.y,z[S+8]=I.z;S+=9}if(Aa.length)F=Aa[o.a],D=Aa[o.b],z=Aa[o.c],Z[L]=F.x,Z[L+1]=F.y,Z[L+2]=F.z,Z[L+3]=F.w,Z[L+4]=D.x,Z[L+5]=D.y,Z[L+6]=D.z,Z[L+7]=D.w,Z[L+8]=z.x,Z[L+9]=z.y,Z[L+10]=z.z,Z[L+11]=z.w,F=Ja[o.a],D=Ja[o.b],z=Ja[o.c],Y[L]=F.x,Y[L+1]=F.y,Y[L+2]=F.z,Y[L+3]=F.w,Y[L+4]=D.x,Y[L+5]=D.y,Y[L+6]=D.z,Y[L+7]=D.w,Y[L+8]=z.x,Y[L+9]=z.y,Y[L+10]=z.z,Y[L+11]=z.w,F=Ha[o.a],D=Ha[o.b],z=Ha[o.c],la[L]=F.x,la[L+1]=F.y,la[L+2]=F.z,la[L+3]=1,la[L+4]=D.x,la[L+5]=D.y,la[L+6]=D.z,la[L+7]=1,la[L+8]=z.x,
|
|
|
|
|
la[L+9]=z.y,la[L+10]=z.z,la[L+11]=1,F=Ia[o.a],D=Ia[o.b],z=Ia[o.c],X[L]=F.x,X[L+1]=F.y,X[L+2]=F.z,X[L+3]=1,X[L+4]=D.x,X[L+5]=D.y,X[L+6]=D.z,X[L+7]=1,X[L+8]=z.x,X[L+9]=z.y,X[L+10]=z.z,X[L+11]=1,L+=12;if(Ya&&E)v.length==3&&E==THREE.VertexColors?(o=v[0],F=v[1],D=v[2]):D=F=o=w,aa[Q]=o.r,aa[Q+1]=o.g,aa[Q+2]=o.b,aa[Q+3]=F.r,aa[Q+4]=F.g,aa[Q+5]=F.b,aa[Q+6]=D.r,aa[Q+7]=D.g,aa[Q+8]=D.b,Q+=9;if(Xa&&ra.hasTangents)v=B[0],w=B[1],o=B[2],U[O]=v.x,U[O+1]=v.y,U[O+2]=v.z,U[O+3]=v.w,U[O+4]=w.x,U[O+5]=w.y,U[O+6]=w.z,
|
|
|
|
|
U[O+7]=w.w,U[O+8]=o.x,U[O+9]=o.y,U[O+10]=o.z,U[O+11]=o.w,O+=12;if(za&&H)if(t.length==3&&na)for(B=0;B<3;B++)u=t[B],ja[V]=u.x,ja[V+1]=u.y,ja[V+2]=u.z,V+=3;else for(B=0;B<3;B++)ja[V]=u.x,ja[V+1]=u.y,ja[V+2]=u.z,V+=3;if(ta&&J!==void 0&&A)for(B=0;B<3;B++)t=J[B],ea[P]=t.u,ea[P+1]=t.v,P+=2;if(ta&&ca!==void 0&&A)for(B=0;B<3;B++)t=ca[B],da[pa]=t.u,da[pa+1]=t.v,pa+=2;ya&&(fa[R]=M,fa[R+1]=M+1,fa[R+2]=M+2,R+=3,ga[T]=M,ga[T+1]=M+1,ga[T+2]=M,ga[T+3]=M+2,ga[T+4]=M+1,ga[T+5]=M+2,T+=6,M+=3)}else if(o instanceof THREE.Face4){if(Ba)C=
|
|
|
|
|
Ga[o.a].position,G=Ga[o.b].position,I=Ga[o.c].position,K=Ga[o.d].position,W[ia]=C.x,W[ia+1]=C.y,W[ia+2]=C.z,W[ia+3]=G.x,W[ia+4]=G.y,W[ia+5]=G.z,W[ia+6]=I.x,W[ia+7]=I.y,W[ia+8]=I.z,W[ia+9]=K.x,W[ia+10]=K.y,W[ia+11]=K.z,ia+=12;if(ha)for(N in ha)if(z=ha[N],z.needsUpdate)F=z.offset,D=z.offsetSrc,z.size===1?(z.boundTo===void 0||z.boundTo==="vertices"?(z.array[F+0]=z.value[o.a],z.array[F+1]=z.value[o.b],z.array[F+2]=z.value[o.c],z.array[F+3]=z.value[o.d]):z.boundTo==="faces"?(z.array[F+0]=z.value[D],z.array[F+
|
|
|
|
|
1]=z.value[D],z.array[F+2]=z.value[D],z.array[F+3]=z.value[D],z.offsetSrc++):z.boundTo==="faceVertices"&&(z.array[F+0]=z.value[D+0],z.array[F+1]=z.value[D+1],z.array[F+2]=z.value[D+2],z.array[F+3]=z.value[D+3],z.offsetSrc+=4),z.offset+=4):(z.boundTo===void 0||z.boundTo==="vertices"?(C=z.value[o.a],G=z.value[o.b],I=z.value[o.c],K=z.value[o.d]):z.boundTo==="faces"?(C=z.value[D],G=z.value[D],I=z.value[D],K=z.value[D],z.offsetSrc++):z.boundTo==="faceVertices"&&(C=z.value[D+0],G=z.value[D+1],I=z.value[D+
|
|
|
|
|
2],K=z.value[D+3],z.offsetSrc+=4),z.size===2?(z.array[F+0]=C.x,z.array[F+1]=C.y,z.array[F+2]=G.x,z.array[F+3]=G.y,z.array[F+4]=I.x,z.array[F+5]=I.y,z.array[F+6]=K.x,z.array[F+7]=K.y,z.offset+=8):z.size===3?(z.type==="c"?(z.array[F+0]=C.r,z.array[F+1]=C.g,z.array[F+2]=C.b,z.array[F+3]=G.r,z.array[F+4]=G.g,z.array[F+5]=G.b,z.array[F+6]=I.r,z.array[F+7]=I.g,z.array[F+8]=I.b,z.array[F+9]=K.r,z.array[F+10]=K.g,z.array[F+11]=K.b):(z.array[F+0]=C.x,z.array[F+1]=C.y,z.array[F+2]=C.z,z.array[F+3]=G.x,z.array[F+
|
|
|
|
|
4]=G.y,z.array[F+5]=G.z,z.array[F+6]=I.x,z.array[F+7]=I.y,z.array[F+8]=I.z,z.array[F+9]=K.x,z.array[F+10]=K.y,z.array[F+11]=K.z),z.offset+=12):(z.array[F+0]=C.x,z.array[F+1]=C.y,z.array[F+2]=C.z,z.array[F+3]=C.w,z.array[F+4]=G.x,z.array[F+5]=G.y,z.array[F+6]=G.z,z.array[F+7]=G.w,z.array[F+8]=I.x,z.array[F+9]=I.y,z.array[F+10]=I.z,z.array[F+11]=I.w,z.array[F+12]=K.x,z.array[F+13]=K.y,z.array[F+14]=K.z,z.array[F+15]=K.w,z.offset+=16));if(Za){F=0;for(D=morphTargets.length;F<D;F++)C=morphTargets[F].vertices[o.a].position,
|
|
|
|
|
G=morphTargets[F].vertices[o.b].position,I=morphTargets[F].vertices[o.c].position,K=morphTargets[F].vertices[o.d].position,z=ka[F],z[S+0]=C.x,z[S+1]=C.y,z[S+2]=C.z,z[S+3]=G.x,z[S+4]=G.y,z[S+5]=G.z,z[S+6]=I.x,z[S+7]=I.y,z[S+8]=I.z,z[S+9]=K.x,z[S+10]=K.y,z[S+11]=K.z;S+=12}if(Aa.length)F=Aa[o.a],D=Aa[o.b],z=Aa[o.c],ma=Aa[o.d],Z[L]=F.x,Z[L+1]=F.y,Z[L+2]=F.z,Z[L+3]=F.w,Z[L+4]=D.x,Z[L+5]=D.y,Z[L+6]=D.z,Z[L+7]=D.w,Z[L+8]=z.x,Z[L+9]=z.y,Z[L+10]=z.z,Z[L+11]=z.w,Z[L+12]=ma.x,Z[L+13]=ma.y,Z[L+14]=ma.z,Z[L+15]=
|
|
|
|
|
ma.w,F=Ja[o.a],D=Ja[o.b],z=Ja[o.c],ma=Ja[o.d],Y[L]=F.x,Y[L+1]=F.y,Y[L+2]=F.z,Y[L+3]=F.w,Y[L+4]=D.x,Y[L+5]=D.y,Y[L+6]=D.z,Y[L+7]=D.w,Y[L+8]=z.x,Y[L+9]=z.y,Y[L+10]=z.z,Y[L+11]=z.w,Y[L+12]=ma.x,Y[L+13]=ma.y,Y[L+14]=ma.z,Y[L+15]=ma.w,F=Ha[o.a],D=Ha[o.b],z=Ha[o.c],ma=Ha[o.d],la[L]=F.x,la[L+1]=F.y,la[L+2]=F.z,la[L+3]=1,la[L+4]=D.x,la[L+5]=D.y,la[L+6]=D.z,la[L+7]=1,la[L+8]=z.x,la[L+9]=z.y,la[L+10]=z.z,la[L+11]=1,la[L+12]=ma.x,la[L+13]=ma.y,la[L+14]=ma.z,la[L+15]=1,F=Ia[o.a],D=Ia[o.b],z=Ia[o.c],o=Ia[o.d],
|
|
|
|
|
X[L]=F.x,X[L+1]=F.y,X[L+2]=F.z,X[L+3]=1,X[L+4]=D.x,X[L+5]=D.y,X[L+6]=D.z,X[L+7]=1,X[L+8]=z.x,X[L+9]=z.y,X[L+10]=z.z,X[L+11]=1,X[L+12]=o.x,X[L+13]=o.y,X[L+14]=o.z,X[L+15]=1,L+=16;if(Ya&&E)v.length==4&&E==THREE.VertexColors?(o=v[0],F=v[1],D=v[2],v=v[3]):v=D=F=o=w,aa[Q]=o.r,aa[Q+1]=o.g,aa[Q+2]=o.b,aa[Q+3]=F.r,aa[Q+4]=F.g,aa[Q+5]=F.b,aa[Q+6]=D.r,aa[Q+7]=D.g,aa[Q+8]=D.b,aa[Q+9]=v.r,aa[Q+10]=v.g,aa[Q+11]=v.b,Q+=12;if(Xa&&ra.hasTangents)v=B[0],w=B[1],o=B[2],B=B[3],U[O]=v.x,U[O+1]=v.y,U[O+2]=v.z,U[O+3]=v.w,
|
|
|
|
|
U[O+4]=w.x,U[O+5]=w.y,U[O+6]=w.z,U[O+7]=w.w,U[O+8]=o.x,U[O+9]=o.y,U[O+10]=o.z,U[O+11]=o.w,U[O+12]=B.x,U[O+13]=B.y,U[O+14]=B.z,U[O+15]=B.w,O+=16;if(za&&H)if(t.length==4&&na)for(B=0;B<4;B++)u=t[B],ja[V]=u.x,ja[V+1]=u.y,ja[V+2]=u.z,V+=3;else for(B=0;B<4;B++)ja[V]=u.x,ja[V+1]=u.y,ja[V+2]=u.z,V+=3;if(ta&&J!==void 0&&A)for(B=0;B<4;B++)t=J[B],ea[P]=t.u,ea[P+1]=t.v,P+=2;if(ta&&ca!==void 0&&A)for(B=0;B<4;B++)t=ca[B],da[pa]=t.u,da[pa+1]=t.v,pa+=2;ya&&(fa[R]=M,fa[R+1]=M+1,fa[R+2]=M+3,fa[R+3]=M+1,fa[R+4]=M+2,
|
|
|
|
|
fa[R+5]=M+3,R+=6,ga[T]=M,ga[T+1]=M+1,ga[T+2]=M,ga[T+3]=M+3,ga[T+4]=M+1,ga[T+5]=M+2,ga[T+6]=M+2,ga[T+7]=M+3,T+=8,M+=4)}if(Ea){n=0;for(p=Ea.length;n<p;n++)fa[R]=Ea[n].a,fa[R+1]=Ea[n].b,fa[R+2]=Ea[n].c,fa[R+3]=Ea[n].a,fa[R+4]=Ea[n].c,fa[R+5]=Ea[n].d,R+=6}Ba&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglVertexBuffer),h.bufferData(h.ARRAY_BUFFER,W,m));if(ha)for(N in ha)if(z=ha[N],z.needsUpdate)h.bindBuffer(h.ARRAY_BUFFER,z.buffer),h.bufferData(h.ARRAY_BUFFER,z.array,m),z.needsUpdate=!1;if(Za){F=0;for(D=morphTargets.length;F<
|
|
|
|
|
D;F++)h.bindBuffer(h.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[F]),h.bufferData(h.ARRAY_BUFFER,ka[F],m)}Ya&&Q>0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglColorBuffer),h.bufferData(h.ARRAY_BUFFER,aa,m));za&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglNormalBuffer),h.bufferData(h.ARRAY_BUFFER,ja,m));Xa&&ra.hasTangents&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglTangentBuffer),h.bufferData(h.ARRAY_BUFFER,U,m));ta&&P>0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglUVBuffer),h.bufferData(h.ARRAY_BUFFER,ea,m));ta&&pa>0&&(h.bindBuffer(h.ARRAY_BUFFER,
|
|
|
|
|
g.__webglUV2Buffer),h.bufferData(h.ARRAY_BUFFER,da,m));ya&&(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,fa,m),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,ga,m));L>0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexABuffer),h.bufferData(h.ARRAY_BUFFER,la,m),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),h.bufferData(h.ARRAY_BUFFER,X,m),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),h.bufferData(h.ARRAY_BUFFER,
|
|
|
|
|
Y,m),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),h.bufferData(h.ARRAY_BUFFER,Z,m));k.dynamic||(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array,delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinVertexAArray,delete g.__skinVertexBArray,delete g.__skinIndexArray,delete g.__skinWeightArray)}}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=
|
|
|
|
|
!1;f.__dirtyTangents=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=h.DYNAMIC_DRAW;A=b.vertices;g=b.colors;E=A.length;k=g.length;H=b.__vertexArray;m=b.__colorArray;J=b.__dirtyColors;if(b.__dirtyVertices){for(n=0;n<E;n++)p=A[n].position,j=n*3,H[j]=p.x,H[j+1]=p.y,H[j+2]=p.z;h.bindBuffer(h.ARRAY_BUFFER,b.__webglVertexBuffer);h.bufferData(h.ARRAY_BUFFER,H,e)}if(J){for(n=0;n<k;n++)color=g[n],j=n*3,m[j]=color.r,m[j+1]=color.g,m[j+2]=color.b;
|
|
|
|
|
h.bindBuffer(h.ARRAY_BUFFER,b.__webglColorBuffer);h.bufferData(h.ARRAY_BUFFER,m,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Line){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=h.DYNAMIC_DRAW;A=b.vertices;g=b.colors;E=A.length;k=g.length;H=b.__vertexArray;m=b.__colorArray;J=b.__dirtyColors;if(b.__dirtyVertices){for(n=0;n<E;n++)p=A[n].position,j=n*3,H[j]=p.x,H[j+1]=p.y,H[j+2]=p.z;h.bindBuffer(h.ARRAY_BUFFER,b.__webglVertexBuffer);h.bufferData(h.ARRAY_BUFFER,H,
|
|
|
|
|
e)}if(J){for(n=0;n<k;n++)color=g[n],j=n*3,m[j]=color.r,m[j+1]=color.g,m[j+2]=color.b;h.bindBuffer(h.ARRAY_BUFFER,b.__webglColorBuffer);h.bufferData(h.ARRAY_BUFFER,m,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)f=b.geometry,(f.__dirtyVertices||f.__dirtyColors||b.sortParticles)&&c(f,h.DYNAMIC_DRAW,b),f.__dirtyVertices=!1,f.__dirtyColors=!1}function K(b){function e(b){var g=[];c=0;for(f=b.length;c<f;c++)b[c]==void 0?g.push("undefined"):g.push(b[c].id);return g.join("_")}
|
|
|
|
|
var c,f,g,j,h,k,m,n,o={},p=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};g=0;for(j=b.faces.length;g<j;g++)h=b.faces[g],k=h.materials,m=e(k),o[m]==void 0&&(o[m]={hash:m,counter:0}),n=o[m].hash+"_"+o[m].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:k,vertices:0,numMorphTargets:p}),h=h instanceof THREE.Face3?3:4,b.geometryGroups[n].vertices+h>65535&&(o[m].counter+=1,n=o[m].hash+"_"+o[m].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],
|
|
|
|
|
materials:k,vertices:0,numMorphTargets:p})),b.geometryGroups[n].faces.push(g),b.geometryGroups[n].vertices+=h}function A(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function I(b){if(b!=S){switch(b){case THREE.AdditiveBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.SRC_ALPHA,h.ONE);break;case THREE.SubtractiveBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.ZERO,h.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.ZERO,
|
|
|
|
|
h.SRC_COLOR);break;default:h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA)}S=b}}function G(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(h.texParameteri(b,h.TEXTURE_WRAP_S,J(e.wrapS)),h.texParameteri(b,h.TEXTURE_WRAP_T,J(e.wrapT)),h.texParameteri(b,h.TEXTURE_MAG_FILTER,J(e.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,J(e.minFilter)),h.generateMipmap(b)):(h.texParameteri(b,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),
|
|
|
|
|
h.texParameteri(b,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(b,h.TEXTURE_MAG_FILTER,N(e.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,N(e.minFilter)))}function C(b,e){if(b.needsUpdate){if(b.__webglTexture)b.__webglTexture=h.deleteTexture(b.__webglTexture);b.__webglTexture=h.createTexture();h.bindTexture(h.TEXTURE_2D,b.__webglTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,b.image);G(h.TEXTURE_2D,b,b.image);h.bindTexture(h.TEXTURE_2D,null);b.needsUpdate=!1}h.activeTexture(h.TEXTURE0+
|
|
|
|
|
e);h.bindTexture(h.TEXTURE_2D,b.__webglTexture)}function R(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=h.createFramebuffer();b.__webglRenderbuffer=h.createRenderbuffer();b.__webglTexture=h.createTexture();h.bindTexture(h.TEXTURE_2D,b.__webglTexture);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,J(b.wrapS));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,J(b.wrapT));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,
|
|
|
|
|
J(b.magFilter));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,J(b.minFilter));h.texImage2D(h.TEXTURE_2D,0,J(b.format),b.width,b.height,0,J(b.format),J(b.type),null);h.bindRenderbuffer(h.RENDERBUFFER,b.__webglRenderbuffer);h.bindFramebuffer(h.FRAMEBUFFER,b.__webglFramebuffer);h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(h.renderbufferStorage(h.RENDERBUFFER,h.DEPTH_COMPONENT16,b.width,b.height),h.framebufferRenderbuffer(h.FRAMEBUFFER,
|
|
|
|
|
h.DEPTH_ATTACHMENT,h.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(h.renderbufferStorage(h.RENDERBUFFER,h.DEPTH_STENCIL,b.width,b.height),h.framebufferRenderbuffer(h.FRAMEBUFFER,h.DEPTH_STENCIL_ATTACHMENT,h.RENDERBUFFER,b.__webglRenderbuffer)):h.renderbufferStorage(h.RENDERBUFFER,h.RGBA4,b.width,b.height);h.bindTexture(h.TEXTURE_2D,null);h.bindRenderbuffer(h.RENDERBUFFER,null);h.bindFramebuffer(h.FRAMEBUFFER,null)}var e,c;b?(e=b.__webglFramebuffer,c=b.width,b=b.height):(e=null,
|
|
|
|
|
c=Y,b=ha);e!=aa&&(h.bindFramebuffer(h.FRAMEBUFFER,e),h.viewport(W,ga,c,b),aa=e)}function D(b,e){var c;b=="fragment"?c=h.createShader(h.FRAGMENT_SHADER):b=="vertex"&&(c=h.createShader(h.VERTEX_SHADER));h.shaderSource(c,e);h.compileShader(c);if(!h.getShaderParameter(c,h.COMPILE_STATUS))return console.error(h.getShaderInfoLog(c)),console.error(e),null;return c}function N(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return h.NEAREST;
|
|
|
|
|
default:return h.LINEAR}}function J(b){switch(b){case THREE.RepeatWrapping:return h.REPEAT;case THREE.ClampToEdgeWrapping:return h.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return h.MIRRORED_REPEAT;case THREE.NearestFilter:return h.NEAREST;case THREE.NearestMipMapNearestFilter:return h.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return h.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return h.LINEAR;case THREE.LinearMipMapNearestFilter:return h.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return h.LINEAR_MIPMAP_LINEAR;
|
|
|
|
|
case THREE.ByteType:return h.BYTE;case THREE.UnsignedByteType:return h.UNSIGNED_BYTE;case THREE.ShortType:return h.SHORT;case THREE.UnsignedShortType:return h.UNSIGNED_SHORT;case THREE.IntType:return h.INT;case THREE.UnsignedShortType:return h.UNSIGNED_INT;case THREE.FloatType:return h.FLOAT;case THREE.AlphaFormat:return h.ALPHA;case THREE.RGBFormat:return h.RGB;case THREE.RGBAFormat:return h.RGBA;case THREE.LuminanceFormat:return h.LUMINANCE;case THREE.LuminanceAlphaFormat:return h.LUMINANCE_ALPHA}return 0}
|
|
|
|
|
var V=this,h,X=[],O=null,aa=null,M=!0,da=null,U=null,S=null,ja=null,W=0,ga=0,Y=0,ha=0,fa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Q=new THREE.Matrix4,T=new Float32Array(16),Z=new Float32Array(16),ka=new THREE.Vector4,na={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},ca=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ma=b.stencil!==void 0?b.stencil:
|
|
|
|
|
!0,ia=b.antialias!==void 0?b.antialias:!1,pa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),la=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=ca;this.sortObjects=this.autoClear=!0;try{if(!(h=ca.getContext("experimental-webgl",{antialias:ia,stencil:ma})))throw"Error creating WebGL context.";}catch(Ba){console.error(Ba)}console.log(navigator.userAgent+" | "+h.getParameter(h.VERSION)+" | "+h.getParameter(h.VENDOR)+
|
|
|
|
|
" | "+h.getParameter(h.RENDERER)+" | "+h.getParameter(h.SHADING_LANGUAGE_VERSION));h.clearColor(0,0,0,1);h.clearDepth(1);h.enable(h.DEPTH_TEST);h.depthFunc(h.LEQUAL);h.frontFace(h.CCW);h.cullFace(h.BACK);h.enable(h.CULL_FACE);h.enable(h.BLEND);h.blendEquation(h.FUNC_ADD);h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA);h.clearColor(pa.r,pa.g,pa.b,la);this.context=h;var ya=h.getParameter(h.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(ma){var ea={};ea.vertices=new Float32Array(12);ea.faces=new Uint16Array(6);
|
|
|
|
|
ea.darkness=0.5;ea.vertices[0]=-20;ea.vertices[1]=-20;ea.vertices[2]=-1;ea.vertices[3]=20;ea.vertices[4]=-20;ea.vertices[5]=-1;ea.vertices[6]=20;ea.vertices[7]=20;ea.vertices[8]=-1;ea.vertices[9]=-20;ea.vertices[10]=20;ea.vertices[11]=-1;ea.faces[0]=0;ea.faces[1]=1;ea.faces[2]=2;ea.faces[3]=0;ea.faces[4]=2;ea.faces[5]=3;ea.vertexBuffer=h.createBuffer();ea.elementBuffer=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,ea.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,ea.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,
|
|
|
|
|
ea.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,ea.faces,h.STATIC_DRAW);ea.program=h.createProgram();h.attachShader(ea.program,D("fragment",THREE.ShaderLib.shadowPost.fragmentShader));h.attachShader(ea.program,D("vertex",THREE.ShaderLib.shadowPost.vertexShader));h.linkProgram(ea.program);ea.vertexLocation=h.getAttribLocation(ea.program,"position");ea.projectionLocation=h.getUniformLocation(ea.program,"projectionMatrix");ea.darknessLocation=h.getUniformLocation(ea.program,"darkness")}var P={};
|
|
|
|
|
P.vertices=new Float32Array(16);P.faces=new Uint16Array(6);b=0;P.vertices[b++]=-1;P.vertices[b++]=-1;P.vertices[b++]=0;P.vertices[b++]=0;P.vertices[b++]=1;P.vertices[b++]=-1;P.vertices[b++]=1;P.vertices[b++]=0;P.vertices[b++]=1;P.vertices[b++]=1;P.vertices[b++]=1;P.vertices[b++]=1;P.vertices[b++]=-1;P.vertices[b++]=1;P.vertices[b++]=0;P.vertices[b++]=1;b=0;P.faces[b++]=0;P.faces[b++]=1;P.faces[b++]=2;P.faces[b++]=0;P.faces[b++]=2;P.faces[b++]=3;P.vertexBuffer=h.createBuffer();P.elementBuffer=h.createBuffer();
|
|
|
|
|
P.tempTexture=h.createTexture();P.occlusionTexture=h.createTexture();h.bindBuffer(h.ARRAY_BUFFER,P.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,P.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,P.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,P.faces,h.STATIC_DRAW);h.bindTexture(h.TEXTURE_2D,P.tempTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGB,16,16,0,h.RGB,h.UNSIGNED_BYTE,null);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE);
|
|
|
|
|
h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST);h.bindTexture(h.TEXTURE_2D,P.occlusionTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGBA,16,16,0,h.RGBA,h.UNSIGNED_BYTE,null);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST);h.getParameter(h.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=
|
|
|
|
|
0?(P.hasVertexTexture=!1,P.program=h.createProgram(),h.attachShader(P.program,D("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),h.attachShader(P.program,D("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(P.hasVertexTexture=!0,P.program=h.createProgram(),h.attachShader(P.program,D("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),h.attachShader(P.program,D("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));h.linkProgram(P.program);P.attributes={};P.uniforms={};
|
|
|
|
|
P.attributes.vertex=h.getAttribLocation(P.program,"position");P.attributes.uv=h.getAttribLocation(P.program,"UV");P.uniforms.renderType=h.getUniformLocation(P.program,"renderType");P.uniforms.map=h.getUniformLocation(P.program,"map");P.uniforms.occlusionMap=h.getUniformLocation(P.program,"occlusionMap");P.uniforms.opacity=h.getUniformLocation(P.program,"opacity");P.uniforms.scale=h.getUniformLocation(P.program,"scale");P.uniforms.rotation=h.getUniformLocation(P.program,"rotation");P.uniforms.screenPosition=
|
|
|
|
|
h.getUniformLocation(P.program,"screenPosition");var za=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=
|
|
|
|
|
0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=h.createBuffer();_sprite.elementBuffer=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,_sprite.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,_sprite.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,_sprite.faces,h.STATIC_DRAW);_sprite.program=h.createProgram();
|
|
|
|
|
h.attachShader(_sprite.program,D("fragment",THREE.ShaderLib.sprite.fragmentShader));h.attachShader(_sprite.program,D("vertex",THREE.ShaderLib.sprite.vertexShader));h.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=h.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=h.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=h.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=h.getUniformLocation(_sprite.program,
|
|
|
|
|
"uvScale");_sprite.uniforms.rotation=h.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=h.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=h.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=h.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=h.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=h.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=
|
|
|
|
|
h.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=h.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=h.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=h.getUniformLocation(_sprite.program,"projectionMatrix");var ta=!1;this.setSize=function(b,e){ca.width=b;ca.height=e;this.setViewport(0,0,ca.width,ca.height)};this.setViewport=function(b,e,c,f){W=b;ga=e;Y=c;ha=f;h.viewport(W,ga,Y,ha)};
|
|
|
|
|
this.setScissor=function(b,e,c,f){h.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?h.enable(h.SCISSOR_TEST):h.disable(h.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){M=b;h.depthMask(b)};this.setClearColorHex=function(b,e){pa.setHex(b);la=e;h.clearColor(pa.r,pa.g,pa.b,la)};this.setClearColor=function(b,e){pa.copy(b);la=e;h.clearColor(pa.r,pa.g,pa.b,la)};this.clear=function(){h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT|h.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){ea.darkness=
|
|
|
|
|
b};this.getContext=function(){return h};this.initMaterial=function(b,e,c,f){var g,j,k;b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?k="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");
|
|
|
|
|
if(k){var m=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var n,o,p;n=p=m=0;for(o=e.length;n<o;n++)j=e[n],j instanceof THREE.DirectionalLight&&p++,j instanceof THREE.PointLight&&m++;m+p<=4?e=p:(e=Math.ceil(4*p/(m+p)),m=4-e);j={directional:e,point:m};p=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)p=f.bones.length;var t;a:{n=b.fragmentShader;o=b.vertexShader;var m=b.uniforms,e=b.attributes,c={map:!!b.map,envMap:!!b.envMap,
|
|
|
|
|
lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:c,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:j.directional,maxPointLights:j.point,maxBones:p},u;j=[];k?j.push(k):(j.push(n),j.push(o));for(u in c)j.push(u),j.push(c[u]);k=j.join();u=0;for(j=X.length;u<j;u++)if(X[u].code==k){t=X[u].program;break a}u=h.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,
|
|
|
|
|
"#define MAX_POINT_LIGHTS "+c.maxPointLights,c.fog?"#define USE_FOG":"",c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[ya?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_BONES "+c.maxBones,c.map?
|
|
|
|
|
"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
|
|
|
|
|
g.attachShader(t,G("fragment",prefix_fragment+m));g.attachShader(t,G("vertex",prefix_vertex+n));g.linkProgram(t);g.getProgramParameter(t,g.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+g.getProgramParameter(t,g.VALIDATE_STATUS)+", gl error ["+g.getError()+"]");t.uniforms={};t.attributes={};var u;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(u in k)m.push(u);
|
|
|
|
|
u=m;k=0;for(m=u.length;k<m;k++)n=u[k],t.uniforms[n]=g.getUniformLocation(t,n);m=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(u=0;u<c.maxMorphTargets;u++)m.push("morphTarget"+u);for(p in d)m.push(p);p=m;u=0;for(d=p.length;u<d;u++)c=p[u],t.attributes[c]=g.getAttribLocation(t,c);Y.push({program:t,code:j});p=t}b.program=p;p=b.program.attributes;p.position>=0&&g.enableVertexAttribArray(p.position);p.color>=0&&g.enableVertexAttribArray(p.color);
|
|
|
|
|
p.normal>=0&&g.enableVertexAttribArray(p.normal);p.tangent>=0&&g.enableVertexAttribArray(p.tangent);b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(g.enableVertexAttribArray(p.skinVertexA),g.enableVertexAttribArray(p.skinVertexB),g.enableVertexAttribArray(p.skinIndex),g.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(f in b.attributes)p[f]!==void 0&&p[f]>=0&&g.enableVertexAttribArray(p[f]);if(b.morphTargets){b.numSupportedMorphTargets=0;p.morphTarget0>=
|
|
|
|
|
0&&(g.enableVertexAttribArray(p.morphTarget0),b.numSupportedMorphTargets++);p.morphTarget1>=0&&(g.enableVertexAttribArray(p.morphTarget1),b.numSupportedMorphTargets++);p.morphTarget2>=0&&(g.enableVertexAttribArray(p.morphTarget2),b.numSupportedMorphTargets++);p.morphTarget3>=0&&(g.enableVertexAttribArray(p.morphTarget3),b.numSupportedMorphTargets++);p.morphTarget4>=0&&(g.enableVertexAttribArray(p.morphTarget4),b.numSupportedMorphTargets++);p.morphTarget5>=0&&(g.enableVertexAttribArray(p.morphTarget5),
|
|
|
|
|
b.numSupportedMorphTargets++);p.morphTarget6>=0&&(g.enableVertexAttribArray(p.morphTarget6),b.numSupportedMorphTargets++);p.morphTarget7>=0&&(g.enableVertexAttribArray(p.morphTarget7),b.numSupportedMorphTargets++);e.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(f=this.maxMorphTargets;b<f;b++)e.__webglMorphTargetInfluences[b]=0}};this.render=function(b,c,o,y){var x,z,A,D,F,ia,G,da,K=b.lights,M=b.fog;N.data.vertices=0;N.data.faces=0;N.data.drawCalls=0;c.matrixAutoUpdate&&
|
|
|
|
|
c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(W);c.projectionMatrix.flattenToArray(P);R.multiply(c.projectionMatrix,c.matrixWorldInverse);k(R);this.initWebGLObjects(b);S(o);(this.autoClear||y)&&this.clear();F=b.__webglObjects.length;for(y=0;y<F;y++)if(x=b.__webglObjects[y],G=x.object,G.visible)if(!(G instanceof THREE.Mesh)||m(G)){if(G.matrixWorld.flattenToArray(G._objectMatrixArray),E(G,c),p(x),x.render=!0,this.sortObjects)X.copy(G.position),R.multiplyVector3(X),x.z=
|
|
|
|
|
X.z}else x.render=!1;else x.render=!1;this.sortObjects&&b.__webglObjects.sort(t);ia=b.__webglObjectsImmediate.length;for(y=0;y<ia;y++)x=b.__webglObjectsImmediate[y],G=x.object,G.visible&&(G.matrixAutoUpdate&&G.matrixWorld.flattenToArray(G._objectMatrixArray),E(G,c),n(x));I(THREE.NormalBlending);for(y=0;y<F;y++)if(x=b.__webglObjects[y],x.render){G=x.object;da=x.buffer;A=x.opaque;h(G);for(x=0;x<A.count;x++)D=A.list[x],j(D.depthTest),e(c,K,M,D,da,G)}for(y=0;y<ia;y++)if(x=b.__webglObjectsImmediate[y],
|
|
|
|
|
G=x.object,G.visible){A=x.opaque;h(G);for(x=0;x<A.count;x++)D=A.list[x],j(D.depthTest),z=d(c,K,M,D,G),G.render(function(b){f(b,z,D.shading)})}for(y=0;y<F;y++)if(x=b.__webglObjects[y],x.render){G=x.object;da=x.buffer;A=x.transparent;h(G);for(x=0;x<A.count;x++)D=A.list[x],I(D.blending),j(D.depthTest),e(c,K,M,D,da,G)}for(y=0;y<ia;y++)if(x=b.__webglObjectsImmediate[y],G=x.object,G.visible){A=x.transparent;h(G);for(x=0;x<A.count;x++)D=A.list[x],I(D.blending),j(D.depthTest),z=d(c,K,M,D,G),G.render(function(b){f(b,
|
|
|
|
|
z,D.shading)})}b.__webglSprites.length&&v(b,c);J&&b.__webglShadowVolumes.length&&b.lights.length&&u(b);b.__webglLensFlares.length&&C(b,c);o&&o.minFilter!==THREE.NearestFilter&&o.minFilter!==THREE.LinearFilter&&(g.bindTexture(g.TEXTURE_2D,o.__webglTexture),g.generateMipmap(g.TEXTURE_2D),g.bindTexture(g.TEXTURE_2D,null))};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglShadowVolumes=[],b.__webglLensFlares=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var c=
|
|
|
|
|
b.__objectsAdded[0],d=b,e=void 0,f=void 0,h=void 0;if(c._modelViewMatrix==void 0)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)for(e in f=c.geometry,f.geometryGroups==void 0&&D(f),f.geometryGroups){h=f.geometryGroups[e];if(!h.__webglVertexBuffer){var j=h;j.__webglVertexBuffer=g.createBuffer();j.__webglNormalBuffer=
|
|
|
|
|
g.createBuffer();j.__webglTangentBuffer=g.createBuffer();j.__webglColorBuffer=g.createBuffer();j.__webglUVBuffer=g.createBuffer();j.__webglUV2Buffer=g.createBuffer();j.__webglSkinVertexABuffer=g.createBuffer();j.__webglSkinVertexBBuffer=g.createBuffer();j.__webglSkinIndicesBuffer=g.createBuffer();j.__webglSkinWeightsBuffer=g.createBuffer();j.__webglFaceBuffer=g.createBuffer();j.__webglLineBuffer=g.createBuffer();if(j.numMorphTargets){var k=void 0,m=void 0;j.__webglMorphTargetsBuffers=[];k=0;for(m=
|
|
|
|
|
j.numMorphTargets;k<m;k++)j.__webglMorphTargetsBuffers.push(g.createBuffer())}for(var j=h,k=c,p=void 0,n=void 0,o=void 0,t=o=void 0,u=void 0,v=void 0,J=v=m=0,A=o=n=void 0,n=p=void 0,t=k.geometry,A=t.faces,u=j.faces,p=0,n=u.length;p<n;p++)o=u[p],o=A[o],o instanceof THREE.Face3?(m+=3,v+=1,J+=3):o instanceof THREE.Face4&&(m+=4,v+=2,J+=4);for(var p=j,n=k,z=u=A=void 0,E=void 0,z=void 0,o=[],A=0,u=n.materials.length;A<u;A++)if(z=n.materials[A],z instanceof THREE.MeshFaceMaterial){z=0;for(l=p.materials.length;z<
|
|
|
|
|
l;z++)(E=p.materials[z])&&o.push(E)}else(E=z)&&o.push(E);p=o;a:{A=n=void 0;u=p.length;for(n=0;n<u;n++)if(A=p[n],A.map||A.lightMap||A instanceof THREE.MeshShaderMaterial){n=!0;break a}n=!1}a:{A=p;o=u=void 0;z=A.length;for(u=0;u<z;u++)if(o=A[u],!(o instanceof THREE.MeshBasicMaterial&&!o.envMap||o instanceof THREE.MeshDepthMaterial)){A=o&&o.shading!=void 0&&o.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}A=!1}a:{o=u=void 0;z=p.length;for(u=0;u<z;u++)if(o=p[u],o.vertexColors){o=
|
|
|
|
|
o.vertexColors;break a}o=!1}j.__vertexArray=new Float32Array(m*3);if(A)j.__normalArray=new Float32Array(m*3);if(t.hasTangents)j.__tangentArray=new Float32Array(m*4);if(o)j.__colorArray=new Float32Array(m*3);if(n){if(t.faceUvs.length>0||t.faceVertexUvs.length>0)j.__uvArray=new Float32Array(m*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(m*2)}if(k.geometry.skinWeights.length&&k.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(m*4),j.__skinVertexBArray=
|
|
|
|
|
new Float32Array(m*4),j.__skinIndexArray=new Float32Array(m*4),j.__skinWeightArray=new Float32Array(m*4);j.__faceArray=new Uint16Array(v*3+(k.geometry.edgeFaces?k.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(J*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];t=0;for(u=j.numMorphTargets;t<u;t++)j.__morphTargetsArrays.push(new Float32Array(m*3))}j.__needsSmoothNormals=A==THREE.SmoothShading;j.__uvType=n;j.__vertexColorType=o;j.__normalType=A;j.__webglFaceCount=v*3+(k.geometry.edgeFaces?
|
|
|
|
|
k.geometry.edgeFaces.length*6:0);j.__webglLineCount=J*2;t=0;for(u=p.length;t<u;t++)if(p[t].attributes)for(a in j.__webglCustomAttributes={},p[t].attributes){n={};for(prop in p[t].attributes[a])n[prop]=p[t].attributes[a][prop];if(!n.__webglInitialized||n.createUniqueBuffers)n.__webglInitialized=!0,v=1,n.type==="v2"?v=2:n.type==="v3"?v=3:n.type==="v4"?v=4:n.type==="c"&&(v=3),n.size=v,n.needsUpdate=!0,n.array=new Float32Array(m*v),n.buffer=g.createBuffer(),n.buffer.belongsToAttribute=a;j.__webglCustomAttributes[a]=
|
|
|
|
|
n}j.__inittedArrays=!0;f.__dirtyVertices=!0;f.__dirtyMorphTargets=!0;f.__dirtyElements=!0;f.__dirtyUvs=!0;f.__dirtyNormals=!0;f.__dirtyTangents=!0;f.__dirtyColors=!0}c instanceof THREE.ShadowVolume?x(d.__webglShadowVolumes,h,c):x(d.__webglObjects,h,c)}else if(c instanceof THREE.LensFlare)x(d.__webglLensFlares,void 0,c);else if(c instanceof THREE.Ribbon){f=c.geometry;if(!f.__webglVertexBuffer)e=f,e.__webglVertexBuffer=g.createBuffer(),e.__webglColorBuffer=g.createBuffer(),e=f,h=e.vertices.length,e.__vertexArray=
|
|
|
|
|
new Float32Array(h*3),e.__colorArray=new Float32Array(h*3),e.__webglVertexCount=h,f.__dirtyVertices=!0,f.__dirtyColors=!0;x(d.__webglObjects,f,c)}else if(c instanceof THREE.Line){f=c.geometry;if(!f.__webglVertexBuffer)e=f,e.__webglVertexBuffer=g.createBuffer(),e.__webglColorBuffer=g.createBuffer(),e=f,h=e.vertices.length,e.__vertexArray=new Float32Array(h*3),e.__colorArray=new Float32Array(h*3),e.__webglLineCount=h,f.__dirtyVertices=!0,f.__dirtyColors=!0;x(d.__webglObjects,f,c)}else if(c instanceof
|
|
|
|
|
THREE.ParticleSystem){f=c.geometry;if(!f.__webglVertexBuffer)e=f,e.__webglVertexBuffer=g.createBuffer(),e.__webglColorBuffer=g.createBuffer(),e=f,h=e.vertices.length,e.__vertexArray=new Float32Array(h*3),e.__colorArray=new Float32Array(h*3),e.__sortArray=[],e.__webglParticleCount=h,f.__dirtyVertices=!0,f.__dirtyColors=!0;x(d.__webglObjects,f,c)}else THREE.MarchingCubes!==void 0&&c instanceof THREE.MarchingCubes?d.__webglObjectsImmediate.push({object:c,opaque:{list:[],count:0},transparent:{list:[],
|
|
|
|
|
count:0}}):c instanceof THREE.Sprite&&d.__webglSprites.push(c);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){c=b.__objectsRemoved[0];d=b;e=f=void 0;if(c instanceof THREE.Mesh)for(f=d.__webglObjects.length-1;f>=0;f--){if(e=d.__webglObjects[f].object,c==e){d.__webglObjects.splice(f,1);break}}else if(c instanceof THREE.Sprite)for(f=d.__webglSprites.length-1;f>=0;f--)if(e=d.__webglSprites[f],c==e){d.__webglSprites.splice(f,1);break}b.__objectsRemoved.splice(0,1)}c=0;for(d=b.__webglObjects.length;c<
|
|
|
|
|
d;c++)y(b.__webglObjects[c].object,b);c=0;for(d=b.__webglShadowVolumes.length;c<d;c++)y(b.__webglShadowVolumes[c].object,b);c=0;for(d=b.__webglLensFlares.length;c<d;c++)y(b.__webglLensFlares[c].object,b)};this.setFaceCulling=function(b,c){b?(!c||c=="ccw"?g.frontFace(g.CCW):g.frontFace(g.CW),b=="back"?g.cullFace(g.BACK):b=="front"?g.cullFace(g.FRONT):g.cullFace(g.FRONT_AND_BACK),g.enable(g.CULL_FACE)):g.disable(g.CULL_FACE)};this.supportsVertexTextures=function(){return va}};
|
|
|
|
|
THREE.WebGLRenderTarget=function(b,c,d){this.width=b;this.height=c;d=d||{};this.wrapS=d.wrapS!==void 0?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==void 0?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==void 0?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==void 0?d.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=d.format!==void 0?d.format:THREE.RGBAFormat;this.type=d.type!==void 0?d.type:
|
|
|
|
|
THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!==void 0?d.depthBuffer:!0;this.stencilBuffer=d.stencilBuffer!==void 0?d.stencilBuffer:!0};
|
|
|
|
|
THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,c,d){d&&b.update(void 0,!1,c);var d=b.sounds,e,f=d.length;for(e=0;e<f;e++)b=d[e],this.soundPosition.set(b.matrixWorld.n14,b.matrixWorld.n24,b.matrixWorld.n34),this.soundPosition.subSelf(c.position),b.isPlaying&&b.isLoaded&&(b.isAddedToDOM||b.addToDOM(this.domElement),b.calculateVolumeAndPan(this.soundPosition))}};
|
|
|
|
|
h.attachShader(u,D("fragment",prefix_fragment+n));h.attachShader(u,D("vertex",prefix_vertex+o));h.linkProgram(u);h.getProgramParameter(u,h.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+h.getProgramParameter(u,h.VALIDATE_STATUS)+", gl error ["+h.getError()+"]");u.uniforms={};u.attributes={};var v;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(v in m)n.push(v);
|
|
|
|
|
v=n;m=0;for(n=v.length;m<n;m++)o=v[m],u.uniforms[o]=h.getUniformLocation(u,o);n=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(v=0;v<c.maxMorphTargets;v++)n.push("morphTarget"+v);for(t in e)n.push(t);t=n;v=0;for(e=t.length;v<e;v++)c=t[v],u.attributes[c]=h.getAttribLocation(u,c);X.push({program:u,code:k});t=u}b.program=t;t=b.program.attributes;t.position>=0&&h.enableVertexAttribArray(t.position);t.color>=0&&h.enableVertexAttribArray(t.color);
|
|
|
|
|
t.normal>=0&&h.enableVertexAttribArray(t.normal);t.tangent>=0&&h.enableVertexAttribArray(t.tangent);b.skinning&&t.skinVertexA>=0&&t.skinVertexB>=0&&t.skinIndex>=0&&t.skinWeight>=0&&(h.enableVertexAttribArray(t.skinVertexA),h.enableVertexAttribArray(t.skinVertexB),h.enableVertexAttribArray(t.skinIndex),h.enableVertexAttribArray(t.skinWeight));if(b.attributes)for(g in b.attributes)t[g]!==void 0&&t[g]>=0&&h.enableVertexAttribArray(t[g]);if(b.morphTargets){b.numSupportedMorphTargets=0;t.morphTarget0>=
|
|
|
|
|
0&&(h.enableVertexAttribArray(t.morphTarget0),b.numSupportedMorphTargets++);t.morphTarget1>=0&&(h.enableVertexAttribArray(t.morphTarget1),b.numSupportedMorphTargets++);t.morphTarget2>=0&&(h.enableVertexAttribArray(t.morphTarget2),b.numSupportedMorphTargets++);t.morphTarget3>=0&&(h.enableVertexAttribArray(t.morphTarget3),b.numSupportedMorphTargets++);t.morphTarget4>=0&&(h.enableVertexAttribArray(t.morphTarget4),b.numSupportedMorphTargets++);t.morphTarget5>=0&&(h.enableVertexAttribArray(t.morphTarget5),
|
|
|
|
|
b.numSupportedMorphTargets++);t.morphTarget6>=0&&(h.enableVertexAttribArray(t.morphTarget6),b.numSupportedMorphTargets++);t.morphTarget7>=0&&(h.enableVertexAttribArray(t.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(g=this.maxMorphTargets;b<g;b++)f.__webglMorphTargetInfluences[b]=0}};this.render=function(b,c,p,B){var A,D,C,G,J,K,ca,M,ia=b.lights,N=b.fog;V.data.vertices=0;V.data.faces=0;V.data.drawCalls=0;c.matrixAutoUpdate&&
|
|
|
|
|
c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Z);c.projectionMatrix.flattenToArray(T);Q.multiply(c.projectionMatrix,c.matrixWorldInverse);m(Q);this.initWebGLObjects(b);R(p);(this.autoClear||B)&&this.clear();J=b.__webglObjects.length;for(B=0;B<J;B++)if(A=b.__webglObjects[B],ca=A.object,ca.visible)if(!(ca instanceof THREE.Mesh)||n(ca)){if(ca.matrixWorld.flattenToArray(ca._objectMatrixArray),H(ca,c),t(A),A.render=!0,this.sortObjects)ka.copy(ca.position),Q.multiplyVector3(ka),
|
|
|
|
|
A.z=ka.z}else A.render=!1;else A.render=!1;this.sortObjects&&b.__webglObjects.sort(u);K=b.__webglObjectsImmediate.length;for(B=0;B<K;B++)A=b.__webglObjectsImmediate[B],ca=A.object,ca.visible&&(ca.matrixAutoUpdate&&ca.matrixWorld.flattenToArray(ca._objectMatrixArray),H(ca,c),o(A));I(THREE.NormalBlending);for(B=0;B<J;B++)if(A=b.__webglObjects[B],A.render){ca=A.object;M=A.buffer;C=A.opaque;j(ca);for(A=0;A<C.count;A++)G=C.list[A],k(G.depthTest),f(c,ia,N,G,M,ca)}for(B=0;B<K;B++)if(A=b.__webglObjectsImmediate[B],
|
|
|
|
|
ca=A.object,ca.visible){C=A.opaque;j(ca);for(A=0;A<C.count;A++)G=C.list[A],k(G.depthTest),D=e(c,ia,N,G,ca),ca.render(function(b){g(b,D,G.shading)})}for(B=0;B<J;B++)if(A=b.__webglObjects[B],A.render){ca=A.object;M=A.buffer;C=A.transparent;j(ca);for(A=0;A<C.count;A++)G=C.list[A],I(G.blending),k(G.depthTest),f(c,ia,N,G,M,ca)}for(B=0;B<K;B++)if(A=b.__webglObjectsImmediate[B],ca=A.object,ca.visible){C=A.transparent;j(ca);for(A=0;A<C.count;A++)G=C.list[A],I(G.blending),k(G.depthTest),D=e(c,ia,N,G,ca),ca.render(function(b){g(b,
|
|
|
|
|
D,G.shading)})}b.__webglSprites.length&&w(b,c);ma&&b.__webglShadowVolumes.length&&b.lights.length&&v(b);b.__webglLensFlares.length&&E(b,c);p&&p.minFilter!==THREE.NearestFilter&&p.minFilter!==THREE.LinearFilter&&(h.bindTexture(h.TEXTURE_2D,p.__webglTexture),h.generateMipmap(h.TEXTURE_2D),h.bindTexture(h.TEXTURE_2D,null))};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglShadowVolumes=[],b.__webglLensFlares=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var c=
|
|
|
|
|
b.__objectsAdded[0],e=b,f=void 0,g=void 0,j=void 0;if(c._modelViewMatrix==void 0)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)for(f in g=c.geometry,g.geometryGroups==void 0&&K(g),g.geometryGroups){j=g.geometryGroups[f];if(!j.__webglVertexBuffer){var k=j;k.__webglVertexBuffer=h.createBuffer();k.__webglNormalBuffer=
|
|
|
|
|
h.createBuffer();k.__webglTangentBuffer=h.createBuffer();k.__webglColorBuffer=h.createBuffer();k.__webglUVBuffer=h.createBuffer();k.__webglUV2Buffer=h.createBuffer();k.__webglSkinVertexABuffer=h.createBuffer();k.__webglSkinVertexBBuffer=h.createBuffer();k.__webglSkinIndicesBuffer=h.createBuffer();k.__webglSkinWeightsBuffer=h.createBuffer();k.__webglFaceBuffer=h.createBuffer();k.__webglLineBuffer=h.createBuffer();if(k.numMorphTargets){var m=void 0,n=void 0;k.__webglMorphTargetsBuffers=[];m=0;for(n=
|
|
|
|
|
k.numMorphTargets;m<n;m++)k.__webglMorphTargetsBuffers.push(h.createBuffer())}for(var k=j,m=c,t=void 0,o=void 0,p=void 0,u=p=void 0,v=void 0,w=void 0,G=w=n=0,C=p=o=void 0,o=t=void 0,u=m.geometry,C=u.faces,v=k.faces,t=0,o=v.length;t<o;t++)p=v[t],p=C[p],p instanceof THREE.Face3?(n+=3,w+=1,G+=3):p instanceof THREE.Face4&&(n+=4,w+=2,G+=4);for(var t=k,o=m,D=v=C=void 0,E=void 0,D=void 0,p=[],C=0,v=o.materials.length;C<v;C++)if(D=o.materials[C],D instanceof THREE.MeshFaceMaterial){D=0;for(l=t.materials.length;D<
|
|
|
|
|
l;D++)(E=t.materials[D])&&p.push(E)}else(E=D)&&p.push(E);t=p;a:{C=o=void 0;v=t.length;for(o=0;o<v;o++)if(C=t[o],C.map||C.lightMap||C instanceof THREE.MeshShaderMaterial){o=!0;break a}o=!1}a:{C=t;p=v=void 0;D=C.length;for(v=0;v<D;v++)if(p=C[v],!(p instanceof THREE.MeshBasicMaterial&&!p.envMap||p instanceof THREE.MeshDepthMaterial)){C=p&&p.shading!=void 0&&p.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}C=!1}a:{p=v=void 0;D=t.length;for(v=0;v<D;v++)if(p=t[v],p.vertexColors){p=
|
|
|
|
|
p.vertexColors;break a}p=!1}k.__vertexArray=new Float32Array(n*3);if(C)k.__normalArray=new Float32Array(n*3);if(u.hasTangents)k.__tangentArray=new Float32Array(n*4);if(p)k.__colorArray=new Float32Array(n*3);if(o){if(u.faceUvs.length>0||u.faceVertexUvs.length>0)k.__uvArray=new Float32Array(n*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(n*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(n*4),k.__skinVertexBArray=
|
|
|
|
|
new Float32Array(n*4),k.__skinIndexArray=new Float32Array(n*4),k.__skinWeightArray=new Float32Array(n*4);k.__faceArray=new Uint16Array(w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));k.__lineArray=new Uint16Array(G*2);if(k.numMorphTargets){k.__morphTargetsArrays=[];u=0;for(v=k.numMorphTargets;u<v;u++)k.__morphTargetsArrays.push(new Float32Array(n*3))}k.__needsSmoothNormals=C==THREE.SmoothShading;k.__uvType=o;k.__vertexColorType=p;k.__normalType=C;k.__webglFaceCount=w*3+(m.geometry.edgeFaces?
|
|
|
|
|
m.geometry.edgeFaces.length*6:0);k.__webglLineCount=G*2;u=0;for(v=t.length;u<v;u++)if(t[u].attributes)for(a in k.__webglCustomAttributes={},t[u].attributes){o={};for(prop in t[u].attributes[a])o[prop]=t[u].attributes[a][prop];if(!o.__webglInitialized||o.createUniqueBuffers)o.__webglInitialized=!0,w=1,o.type==="v2"?w=2:o.type==="v3"?w=3:o.type==="v4"?w=4:o.type==="c"&&(w=3),o.size=w,o.needsUpdate=!0,o.array=new Float32Array(n*w),o.buffer=h.createBuffer(),o.buffer.belongsToAttribute=a;k.__webglCustomAttributes[a]=
|
|
|
|
|
o}k.__inittedArrays=!0;g.__dirtyVertices=!0;g.__dirtyMorphTargets=!0;g.__dirtyElements=!0;g.__dirtyUvs=!0;g.__dirtyNormals=!0;g.__dirtyTangents=!0;g.__dirtyColors=!0}c instanceof THREE.ShadowVolume?A(e.__webglShadowVolumes,j,c):A(e.__webglObjects,j,c)}else if(c instanceof THREE.LensFlare)A(e.__webglLensFlares,void 0,c);else if(c instanceof THREE.Ribbon){g=c.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=h.createBuffer(),f.__webglColorBuffer=h.createBuffer(),f=g,j=f.vertices.length,f.__vertexArray=
|
|
|
|
|
new Float32Array(j*3),f.__colorArray=new Float32Array(j*3),f.__webglVertexCount=j,g.__dirtyVertices=!0,g.__dirtyColors=!0;A(e.__webglObjects,g,c)}else if(c instanceof THREE.Line){g=c.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=h.createBuffer(),f.__webglColorBuffer=h.createBuffer(),f=g,j=f.vertices.length,f.__vertexArray=new Float32Array(j*3),f.__colorArray=new Float32Array(j*3),f.__webglLineCount=j,g.__dirtyVertices=!0,g.__dirtyColors=!0;A(e.__webglObjects,g,c)}else if(c instanceof
|
|
|
|
|
THREE.ParticleSystem){g=c.geometry;if(!g.__webglVertexBuffer)f=g,f.__webglVertexBuffer=h.createBuffer(),f.__webglColorBuffer=h.createBuffer(),f=g,j=f.vertices.length,f.__vertexArray=new Float32Array(j*3),f.__colorArray=new Float32Array(j*3),f.__sortArray=[],f.__webglParticleCount=j,g.__dirtyVertices=!0,g.__dirtyColors=!0;A(e.__webglObjects,g,c)}else THREE.MarchingCubes!==void 0&&c instanceof THREE.MarchingCubes?e.__webglObjectsImmediate.push({object:c,opaque:{list:[],count:0},transparent:{list:[],
|
|
|
|
|
count:0}}):c instanceof THREE.Sprite&&e.__webglSprites.push(c);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){c=b.__objectsRemoved[0];e=b;f=g=void 0;if(c instanceof THREE.Mesh)for(g=e.__webglObjects.length-1;g>=0;g--){if(f=e.__webglObjects[g].object,c==f){e.__webglObjects.splice(g,1);break}}else if(c instanceof THREE.Sprite)for(g=e.__webglSprites.length-1;g>=0;g--)if(f=e.__webglSprites[g],c==f){e.__webglSprites.splice(g,1);break}b.__objectsRemoved.splice(0,1)}c=0;for(e=b.__webglObjects.length;c<
|
|
|
|
|
e;c++)B(b.__webglObjects[c].object,b);c=0;for(e=b.__webglShadowVolumes.length;c<e;c++)B(b.__webglShadowVolumes[c].object,b);c=0;for(e=b.__webglLensFlares.length;c<e;c++)B(b.__webglLensFlares[c].object,b)};this.setFaceCulling=function(b,c){b?(!c||c=="ccw"?h.frontFace(h.CCW):h.frontFace(h.CW),b=="back"?h.cullFace(h.BACK):b=="front"?h.cullFace(h.FRONT):h.cullFace(h.FRONT_AND_BACK),h.enable(h.CULL_FACE)):h.disable(h.CULL_FACE)};this.supportsVertexTextures=function(){return ya}};
|
|
|
|
|
THREE.WebGLRenderTarget=function(b,c,e){this.width=b;this.height=c;e=e||{};this.wrapS=e.wrapS!==void 0?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==void 0?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==void 0?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==void 0?e.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=e.format!==void 0?e.format:THREE.RGBAFormat;this.type=e.type!==void 0?e.type:
|
|
|
|
|
THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!0};
|
|
|
|
|
THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,c,e){e&&b.update(void 0,!1,c);var e=b.sounds,f,g=e.length;for(f=0;f<g;f++)b=e[f],this.soundPosition.set(b.matrixWorld.n14,b.matrixWorld.n24,b.matrixWorld.n34),this.soundPosition.subSelf(c.position),b.isPlaying&&b.isLoaded&&(b.isAddedToDOM||b.addToDOM(this.domElement),b.calculateVolumeAndPan(this.soundPosition))}};
|
|
|
|
|
THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(b){this.positionWorld.copy(b.positionWorld);this.positionScreen.copy(b.positionScreen)};
|
|
|
|
|
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};
|
|
|
|
|
THREE.ColorUtils={adjustHSV:function(b,c,d,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,f);f.h=THREE.ColorUtils.clamp(f.h+c,0,1);f.s=THREE.ColorUtils.clamp(f.s+d,0,1);f.v=THREE.ColorUtils.clamp(f.v+e,0,1);b.setHSV(f.h,f.s,f.v)},rgbToHsv:function(b,c){var d=b.r,e=b.g,f=b.b,h=Math.max(Math.max(d,e),f),j=Math.min(Math.min(d,e),f);if(j==h)j=d=0;else{var k=h-j,j=k/h,d=d==h?(e-f)/k:e==h?2+(f-d)/k:4+(d-e)/k;d/=6;d<0&&(d+=1);d>1&&(d-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=d;c.s=j;c.v=h;return c},
|
|
|
|
|
clamp:function(b,c,d){return b<c?c:b>d?d:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
|
|
|
|
|
var GeometryUtils={merge:function(b,c){var d=c instanceof THREE.Mesh,e=b.vertices.length,f=d?c.geometry:c,h=b.vertices,j=f.vertices,k=b.faces,m=f.faces,o=b.faceVertexUvs[0],f=f.faceVertexUvs[0];d&&c.matrixAutoUpdate&&c.updateMatrix();for(var n=0,p=j.length;n<p;n++){var t=new THREE.Vertex(j[n].position.clone());d&&c.matrix.multiplyVector3(t.position);h.push(t)}n=0;for(p=m.length;n<p;n++){var j=m[n],u,v,C=j.vertexNormals,t=j.vertexColors;j instanceof THREE.Face3?u=new THREE.Face3(j.a+e,j.b+e,j.c+e):
|
|
|
|
|
j instanceof THREE.Face4&&(u=new THREE.Face4(j.a+e,j.b+e,j.c+e,j.d+e));u.normal.copy(j.normal);d=0;for(h=C.length;d<h;d++)v=C[d],u.vertexNormals.push(v.clone());u.color.copy(j.color);d=0;for(h=t.length;d<h;d++)v=t[d],u.vertexColors.push(v.clone());u.materials=j.materials.slice();u.centroid.copy(j.centroid);k.push(u)}n=0;for(p=f.length;n<p;n++){e=f[n];k=[];d=0;for(h=e.length;d<h;d++)k.push(new THREE.UV(e[d].u,e[d].v));o.push(k)}}};
|
|
|
|
|
THREE.ImageUtils={loadTexture:function(b,c,d){var e=new Image,f=new THREE.Texture(e,c);e.onload=function(){f.needsUpdate=!0;d&&d(this)};e.src=b;return f},loadTextureCube:function(b,c,d){var e,f=[],h=new THREE.Texture(f,c),c=f.loadCount=0;for(e=b.length;c<e;++c)f[c]=new Image,f[c].onload=function(){f.loadCount+=1;if(f.loadCount==6)h.needsUpdate=!0;d&&d(this)},f[c].src=b[c];return h}};
|
|
|
|
|
THREE.SceneUtils={addMesh:function(b,c,d,e,f,h,j,k,m,o){c=new THREE.Mesh(c,o);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=h;c.rotation.x=j;c.rotation.y=k;c.rotation.z=m;b.addObject(c);return c},addPanoramaCubeWebGL:function(b,c,d){var e=THREE.ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:e.uniforms});c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,1,null,!0),d);b.addObject(c);
|
|
|
|
|
return c},addPanoramaCube:function(b,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,e,!0),
|
|
|
|
|
new THREE.MeshFaceMaterial);b.addObject(c);return c},addPanoramaCubePlanes:function(b,c,d){var e=c/2,c=new THREE.Plane(c,c),f=Math.PI,h=Math.PI/2;THREE.SceneUtils.addMesh(b,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));THREE.SceneUtils.addMesh(b,c,1,-e,0,0,0,h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));THREE.SceneUtils.addMesh(b,c,1,e,0,0,0,-h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));THREE.SceneUtils.addMesh(b,c,1,0,e,0,h,0,f,
|
|
|
|
|
new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));THREE.SceneUtils.addMesh(b,c,1,0,-e,0,-h,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))},showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var d,e,f=b.children.length;for(e=0;e<f;e++)d=b.children[e],c(d),THREE.SceneUtils.traverseHierarchy(d,c)}};
|
|
|
|
|
THREE.ColorUtils={adjustHSV:function(b,c,e,f){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,g);g.h=THREE.ColorUtils.clamp(g.h+c,0,1);g.s=THREE.ColorUtils.clamp(g.s+e,0,1);g.v=THREE.ColorUtils.clamp(g.v+f,0,1);b.setHSV(g.h,g.s,g.v)},rgbToHsv:function(b,c){var e=b.r,f=b.g,g=b.b,j=Math.max(Math.max(e,f),g),k=Math.min(Math.min(e,f),g);if(k==j)k=e=0;else{var m=j-k,k=m/j,e=e==j?(f-g)/m:f==j?2+(g-e)/m:4+(e-f)/m;e/=6;e<0&&(e+=1);e>1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=k;c.v=j;return c},
|
|
|
|
|
clamp:function(b,c,e){return b<c?c:b>e?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
|
|
|
|
|
var GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,g=e?c.geometry:c,j=b.vertices,k=g.vertices,m=b.faces,n=g.faces,p=b.faceVertexUvs[0],g=g.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,t=k.length;o<t;o++){var u=new THREE.Vertex(k[o].position.clone());e&&c.matrix.multiplyVector3(u.position);j.push(u)}o=0;for(t=n.length;o<t;o++){var k=n[o],v,w,E=k.vertexNormals,u=k.vertexColors;k instanceof THREE.Face3?v=new THREE.Face3(k.a+f,k.b+f,k.c+f):
|
|
|
|
|
k instanceof THREE.Face4&&(v=new THREE.Face4(k.a+f,k.b+f,k.c+f,k.d+f));v.normal.copy(k.normal);e=0;for(j=E.length;e<j;e++)w=E[e],v.vertexNormals.push(w.clone());v.color.copy(k.color);e=0;for(j=u.length;e<j;e++)w=u[e],v.vertexColors.push(w.clone());v.materials=k.materials.slice();v.centroid.copy(k.centroid);m.push(v)}o=0;for(t=g.length;o<t;o++){f=g[o];m=[];e=0;for(j=f.length;e<j;e++)m.push(new THREE.UV(f[e].u,f[e].v));p.push(m)}}};
|
|
|
|
|
THREE.ImageUtils={loadTexture:function(b,c,e){var f=new Image,g=new THREE.Texture(f,c);f.onload=function(){g.needsUpdate=!0;e&&e(this)};f.src=b;return g},loadTextureCube:function(b,c,e){var f,g=[],j=new THREE.Texture(g,c),c=g.loadCount=0;for(f=b.length;c<f;++c)g[c]=new Image,g[c].onload=function(){g.loadCount+=1;if(g.loadCount==6)j.needsUpdate=!0;e&&e(this)},g[c].src=b[c];return j}};
|
|
|
|
|
THREE.SceneUtils={addMesh:function(b,c,e,f,g,j,k,m,n,p){c=new THREE.Mesh(c,p);c.scale.x=c.scale.y=c.scale.z=e;c.position.x=f;c.position.y=g;c.position.z=j;c.rotation.x=k;c.rotation.y=m;c.rotation.z=n;b.addObject(c);return c},addPanoramaCubeWebGL:function(b,c,e){var f=THREE.ShaderUtils.lib.cube;f.uniforms.tCube.texture=e;e=new THREE.MeshShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:f.uniforms});c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,1,null,!0),e);b.addObject(c);
|
|
|
|
|
return c},addPanoramaCube:function(b,c,e){var f=[];f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[3])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[4])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,f,!0),
|
|
|
|
|
new THREE.MeshFaceMaterial);b.addObject(c);return c},addPanoramaCubePlanes:function(b,c,e){var f=c/2,c=new THREE.Plane(c,c),g=Math.PI,j=Math.PI/2;THREE.SceneUtils.addMesh(b,c,1,0,0,-f,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[5])}));THREE.SceneUtils.addMesh(b,c,1,-f,0,0,0,j,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[0])}));THREE.SceneUtils.addMesh(b,c,1,f,0,0,0,-j,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[1])}));THREE.SceneUtils.addMesh(b,c,1,0,f,0,j,0,g,
|
|
|
|
|
new THREE.MeshBasicMaterial({map:new THREE.Texture(e[2])}));THREE.SceneUtils.addMesh(b,c,1,0,-f,0,-j,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(e[3])}))},showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,g=b.children.length;for(f=0;f<g;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
|
|
|
|
|
THREE.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},enableSpecular:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:5,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",
|
|
|
|
@@ -356,148 +357,161 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec
|
|
|
|
|
value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
|
|
|
|
|
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(b){var c,d,e,f,h=2*Math.ceil(b*3)+1;h>25&&(h=25);f=(h-1)*0.5;d=Array(h);for(c=e=0;c<h;++c)d[c]=Math.exp(-((c-f)*(c-f))/(2*b*b)),e+=d[c];for(c=0;c<h;++c)d[c]/=e;return d}};
|
|
|
|
|
THREE.AnimationHandler=function(){var b=[],c={},d={update:function(c){for(var d=0;d<b.length;d++)b[d].update(c)},addToUpdate:function(c){b.indexOf(c)===-1&&b.push(c)},removeFromUpdate:function(c){c=b.indexOf(c);c!==-1&&b.splice(c,1)},add:function(b){c[b.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+b.name+" already exists in library. Overwriting.");c[b.name]=b;if(b.initialized!==!0){for(var d=0;d<b.hierarchy.length;d++){for(var e=0;e<b.hierarchy[d].keys.length;e++){if(b.hierarchy[d].keys[e].time<
|
|
|
|
|
0)b.hierarchy[d].keys[e].time=0;if(b.hierarchy[d].keys[e].rot!==void 0&&!(b.hierarchy[d].keys[e].rot instanceof THREE.Quaternion)){var k=b.hierarchy[d].keys[e].rot;b.hierarchy[d].keys[e].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(b.hierarchy[d].keys[0].morphTargets!==void 0){k={};for(e=0;e<b.hierarchy[d].keys.length;e++)for(var m=0;m<b.hierarchy[d].keys[e].morphTargets.length;m++){var o=b.hierarchy[d].keys[e].morphTargets[m];k[o]=-1}b.hierarchy[d].usedMorphTargets=k;for(e=0;e<b.hierarchy[d].keys.length;e++){var n=
|
|
|
|
|
{};for(o in k){for(m=0;m<b.hierarchy[d].keys[e].morphTargets.length;m++)if(b.hierarchy[d].keys[e].morphTargets[m]===o){n[o]=b.hierarchy[d].keys[e].morphTargetsInfluences[m];break}m===b.hierarchy[d].keys[e].morphTargets.length&&(n[o]=0)}b.hierarchy[d].keys[e].morphTargetsInfluences=n}}for(e=1;e<b.hierarchy[d].keys.length;e++)b.hierarchy[d].keys[e].time===b.hierarchy[d].keys[e-1].time&&(b.hierarchy[d].keys.splice(e,1),e--);for(e=1;e<b.hierarchy[d].keys.length;e++)b.hierarchy[d].keys[e].index=e}e=parseInt(b.length*
|
|
|
|
|
b.fps,10);b.JIT={};b.JIT.hierarchy=[];for(d=0;d<b.hierarchy.length;d++)b.JIT.hierarchy.push(Array(e));b.initialized=!0}},get:function(b){if(typeof b==="string")return c[b]?c[b]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+b),null)},parse:function(b){var c=[];if(b instanceof THREE.SkinnedMesh)for(var d=0;d<b.bones.length;d++)c.push(b.bones[d]);else e(b,c);return c}},e=function(b,c){c.push(b);for(var d=0;d<b.children.length;d++)e(b.children[d],c)};d.LINEAR=0;d.CATMULLROM=1;d.CATMULLROM_FORWARD=
|
|
|
|
|
2;return d}();THREE.Animation=function(b,c,d,e){this.root=b;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(b);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=d!==void 0?d:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==void 0?e:!0;this.points=[];this.target=new THREE.Vector3};
|
|
|
|
|
THREE.Animation.prototype.play=function(b,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=b!==void 0?b:!0;this.currentTime=c!==void 0?c:0;var d,e=this.hierarchy.length,f;for(d=0;d<e;d++){f=this.hierarchy[d];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)f.useQuaternion=!0;f.matrixAutoUpdate=!0;if(f.animationCache===void 0)f.animationCache={},f.animationCache.prevKey={pos:0,rot:0,scl:0},f.animationCache.nextKey={pos:0,rot:0,scl:0},f.animationCache.originalMatrix=f instanceof
|
|
|
|
|
THREE.Bone?f.skinMatrix:f.matrix;var h=f.animationCache.prevKey;f=f.animationCache.nextKey;h.pos=this.data.hierarchy[d].keys[0];h.rot=this.data.hierarchy[d].keys[0];h.scl=this.data.hierarchy[d].keys[0];f.pos=this.getNextKeyWith("pos",d,1);f.rot=this.getNextKeyWith("rot",d,1);f.scl=this.getNextKeyWith("scl",d,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
|
|
|
|
|
fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(b){var c,e,f,g,j=2*Math.ceil(b*3)+1;j>25&&(j=25);g=(j-1)*0.5;e=Array(j);for(c=f=0;c<j;++c)e[c]=Math.exp(-((c-g)*(c-g))/(2*b*b)),f+=e[c];for(c=0;c<j;++c)e[c]/=f;return e}};
|
|
|
|
|
THREE.AnimationHandler=function(){var b=[],c={},e={update:function(c){for(var e=0;e<b.length;e++)b[e].update(c)},addToUpdate:function(c){b.indexOf(c)===-1&&b.push(c)},removeFromUpdate:function(c){c=b.indexOf(c);c!==-1&&b.splice(c,1)},add:function(b){c[b.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+b.name+" already exists in library. Overwriting.");c[b.name]=b;if(b.initialized!==!0){for(var e=0;e<b.hierarchy.length;e++){for(var f=0;f<b.hierarchy[e].keys.length;f++){if(b.hierarchy[e].keys[f].time<
|
|
|
|
|
0)b.hierarchy[e].keys[f].time=0;if(b.hierarchy[e].keys[f].rot!==void 0&&!(b.hierarchy[e].keys[f].rot instanceof THREE.Quaternion)){var m=b.hierarchy[e].keys[f].rot;b.hierarchy[e].keys[f].rot=new THREE.Quaternion(m[0],m[1],m[2],m[3])}}if(b.hierarchy[e].keys[0].morphTargets!==void 0){m={};for(f=0;f<b.hierarchy[e].keys.length;f++)for(var n=0;n<b.hierarchy[e].keys[f].morphTargets.length;n++){var p=b.hierarchy[e].keys[f].morphTargets[n];m[p]=-1}b.hierarchy[e].usedMorphTargets=m;for(f=0;f<b.hierarchy[e].keys.length;f++){var o=
|
|
|
|
|
{};for(p in m){for(n=0;n<b.hierarchy[e].keys[f].morphTargets.length;n++)if(b.hierarchy[e].keys[f].morphTargets[n]===p){o[p]=b.hierarchy[e].keys[f].morphTargetsInfluences[n];break}n===b.hierarchy[e].keys[f].morphTargets.length&&(o[p]=0)}b.hierarchy[e].keys[f].morphTargetsInfluences=o}}for(f=1;f<b.hierarchy[e].keys.length;f++)b.hierarchy[e].keys[f].time===b.hierarchy[e].keys[f-1].time&&(b.hierarchy[e].keys.splice(f,1),f--);for(f=1;f<b.hierarchy[e].keys.length;f++)b.hierarchy[e].keys[f].index=f}f=parseInt(b.length*
|
|
|
|
|
b.fps,10);b.JIT={};b.JIT.hierarchy=[];for(e=0;e<b.hierarchy.length;e++)b.JIT.hierarchy.push(Array(f));b.initialized=!0}},get:function(b){if(typeof b==="string")return c[b]?c[b]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+b),null)},parse:function(b){var c=[];if(b instanceof THREE.SkinnedMesh)for(var e=0;e<b.bones.length;e++)c.push(b.bones[e]);else f(b,c);return c}},f=function(b,c){c.push(b);for(var e=0;e<b.children.length;e++)f(b.children[e],c)};e.LINEAR=0;e.CATMULLROM=1;e.CATMULLROM_FORWARD=
|
|
|
|
|
2;return e}();THREE.Animation=function(b,c,e,f){this.root=b;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(b);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=e!==void 0?e:THREE.AnimationHandler.LINEAR;this.JITCompile=f!==void 0?f:!0;this.points=[];this.target=new THREE.Vector3};
|
|
|
|
|
THREE.Animation.prototype.play=function(b,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=b!==void 0?b:!0;this.currentTime=c!==void 0?c:0;var e,f=this.hierarchy.length,g;for(e=0;e<f;e++){g=this.hierarchy[e];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)g.useQuaternion=!0;g.matrixAutoUpdate=!0;if(g.animationCache===void 0)g.animationCache={},g.animationCache.prevKey={pos:0,rot:0,scl:0},g.animationCache.nextKey={pos:0,rot:0,scl:0},g.animationCache.originalMatrix=g instanceof
|
|
|
|
|
THREE.Bone?g.skinMatrix:g.matrix;var j=g.animationCache.prevKey;g=g.animationCache.nextKey;j.pos=this.data.hierarchy[e].keys[0];j.rot=this.data.hierarchy[e].keys[0];j.scl=this.data.hierarchy[e].keys[0];g.pos=this.getNextKeyWith("pos",e,1);g.rot=this.getNextKeyWith("rot",e,1);g.scl=this.getNextKeyWith("scl",e,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.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var b=0;b<this.hierarchy.length;b++)if(this.hierarchy[b].animationCache!==void 0)this.hierarchy[b]instanceof THREE.Bone?this.hierarchy[b].skinMatrix=this.hierarchy[b].animationCache.originalMatrix:this.hierarchy[b].matrix=this.hierarchy[b].animationCache.originalMatrix,delete this.hierarchy[b].animationCache};
|
|
|
|
|
THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],d,e,f,h,j,k,m,o,n=this.data.JIT.hierarchy,p,t;this.currentTime+=b*this.timeScale;t=this.currentTime;p=this.currentTime%=this.data.length;o=parseInt(Math.min(p*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,v=this.hierarchy.length;u<v;u++)if(b=this.hierarchy[u],m=b.animationCache,this.JITCompile&&n[u][o]!==void 0)b instanceof THREE.Bone?(b.skinMatrix=n[u][o],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=
|
|
|
|
|
!1):(b.matrix=n[u][o],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)b instanceof THREE.Bone?b.skinMatrix=b.animationCache.originalMatrix:b.matrix=b.animationCache.originalMatrix;for(var C=0;C<3;C++){d=c[C];j=m.prevKey[d];k=m.nextKey[d];if(k.time<=t){if(p<t)if(this.loop){j=this.data.hierarchy[u].keys[0];for(k=this.getNextKeyWith(d,u,1);k.time<p;)j=k,k=this.getNextKeyWith(d,u,k.index+1)}else{this.stop();return}else{do j=k,k=this.getNextKeyWith(d,u,k.index+1);while(k.time<
|
|
|
|
|
p)}m.prevKey[d]=j;m.nextKey[d]=k}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;e=(p-j.time)/(k.time-j.time);f=j[d];h=k[d];if(e<0||e>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+u),e=e<0?0:1;if(d==="pos")if(d=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)d.x=f[0]+(h[0]-f[0])*e,d.y=f[1]+(h[1]-f[1])*e,d.z=f[2]+(h[2]-f[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
|
|
|
|
|
this.getPrevKeyWith("pos",u,j.index-1).pos,this.points[1]=f,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos,e=e*0.33+0.33,f=this.interpolateCatmullRom(this.points,e),d.x=f[0],d.y=f[1],d.z=f[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(d),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,e,0)}else if(d===
|
|
|
|
|
"rot")THREE.Quaternion.slerp(f,h,b.quaternion,e);else if(d==="scl")d=b.scale,d.x=f[0]+(h[0]-f[0])*e,d.y=f[1]+(h[1]-f[1])*e,d.z=f[2]+(h[2]-f[2])*e}}if(this.JITCompile&&n[0][o]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;u<this.hierarchy.length;u++)n[u][o]=this.hierarchy[u]instanceof THREE.Bone?this.hierarchy[u].skinMatrix.clone():this.hierarchy[u].matrix.clone()}}};
|
|
|
|
|
THREE.Animation.prototype.interpolateCatmullRom=function(b,c){var d=[],e=[],f,h,j,k,m,o;f=(b.length-1)*c;h=Math.floor(f);f-=h;d[0]=h==0?h:h-1;d[1]=h;d[2]=h>b.length-2?h:h+1;d[3]=h>b.length-3?h:h+2;h=b[d[0]];k=b[d[1]];m=b[d[2]];o=b[d[3]];d=f*f;j=f*d;e[0]=this.interpolate(h[0],k[0],m[0],o[0],f,d,j);e[1]=this.interpolate(h[1],k[1],m[1],o[1],f,d,j);e[2]=this.interpolate(h[2],k[2],m[2],o[2],f,d,j);return e};
|
|
|
|
|
THREE.Animation.prototype.interpolate=function(b,c,d,e,f,h,j){b=(d-b)*0.5;e=(e-c)*0.5;return(2*(c-d)+b+e)*j+(-3*(c-d)-2*b-e)*h+b*f+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,d){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?d=d<e.length-1?d:e.length-1:d%=e.length;d<e.length;d++)if(e[d][b]!==void 0)return e[d];return this.data.hierarchy[c].keys[0]};
|
|
|
|
|
THREE.Animation.prototype.getPrevKeyWith=function(b,c,d){for(var e=this.data.hierarchy[c].keys,d=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?d>0?d:0:d>=0?d:d+e.length;d>=0;d--)if(e[d][b]!==void 0)return e[d];return this.data.hierarchy[c].keys[e.length-1]};
|
|
|
|
|
THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],e,f,g,j,k,m,n,p,o=this.data.JIT.hierarchy,t,u;this.currentTime+=b*this.timeScale;u=this.currentTime;t=this.currentTime%=this.data.length;p=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var v=0,w=this.hierarchy.length;v<w;v++)if(b=this.hierarchy[v],n=b.animationCache,this.JITCompile&&o[v][p]!==void 0)b instanceof THREE.Bone?(b.skinMatrix=o[v][p],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=
|
|
|
|
|
!1):(b.matrix=o[v][p],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)b instanceof THREE.Bone?b.skinMatrix=b.animationCache.originalMatrix:b.matrix=b.animationCache.originalMatrix;for(var E=0;E<3;E++){e=c[E];k=n.prevKey[e];m=n.nextKey[e];if(m.time<=u){if(t<u)if(this.loop){k=this.data.hierarchy[v].keys[0];for(m=this.getNextKeyWith(e,v,1);m.time<t;)k=m,m=this.getNextKeyWith(e,v,m.index+1)}else{this.stop();return}else{do k=m,m=this.getNextKeyWith(e,v,m.index+1);while(m.time<
|
|
|
|
|
t)}n.prevKey[e]=k;n.nextKey[e]=m}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(t-k.time)/(m.time-k.time);g=k[e];j=m[e];if(f<0||f>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+v),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
|
|
|
|
|
this.getPrevKeyWith("pos",v,k.index-1).pos,this.points[1]=g,this.points[2]=j,this.points[3]=this.getNextKeyWith("pos",v,m.index+1).pos,f=f*0.33+0.33,g=this.interpolateCatmullRom(this.points,f),e.x=g[0],e.y=g[1],e.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(e),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(e===
|
|
|
|
|
"rot")THREE.Quaternion.slerp(g,j,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f}}if(this.JITCompile&&o[0][p]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;v<this.hierarchy.length;v++)o[v][p]=this.hierarchy[v]instanceof THREE.Bone?this.hierarchy[v].skinMatrix.clone():this.hierarchy[v].matrix.clone()}}};
|
|
|
|
|
THREE.Animation.prototype.interpolateCatmullRom=function(b,c){var e=[],f=[],g,j,k,m,n,p;g=(b.length-1)*c;j=Math.floor(g);g-=j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>b.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];m=b[e[1]];n=b[e[2]];p=b[e[3]];e=g*g;k=g*e;f[0]=this.interpolate(j[0],m[0],n[0],p[0],g,e,k);f[1]=this.interpolate(j[1],m[1],n[1],p[1],g,e,k);f[2]=this.interpolate(j[2],m[2],n[2],p[2],g,e,k);return f};
|
|
|
|
|
THREE.Animation.prototype.interpolate=function(b,c,e,f,g,j,k){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*k+(-3*(c-e)-2*b-f)*j+b*g+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e<f.length-1?e:f.length-1:e%=f.length;e<f.length;e++)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[0]};
|
|
|
|
|
THREE.Animation.prototype.getPrevKeyWith=function(b,c,e){for(var f=this.data.hierarchy[c].keys,e=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e>0?e:0:e>=0?e:e+f.length;e>=0;e--)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[f.length-1]};
|
|
|
|
|
THREE.QuakeCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=
|
|
|
|
|
b.movementSpeed;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.noFly!==void 0)this.noFly=b.noFly;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.autoForward!==void 0)this.autoForward=b.autoForward;if(b.activeLook!==void 0)this.activeLook=b.activeLook;if(b.heightSpeed!==void 0)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==void 0)this.heightCoef=b.heightCoef;if(b.heightMin!==void 0)this.heightMin=b.heightMin;if(b.heightMax!==void 0)this.heightMax=b.heightMax;if(b.constrainVertical!==
|
|
|
|
|
void 0)this.constrainVertical=b.constrainVertical;if(b.verticalMin!==void 0)this.verticalMin=b.verticalMin;if(b.verticalMax!==void 0)this.verticalMax=b.verticalMax;if(b.domElement!==void 0)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();
|
|
|
|
|
b.stopPropagation();if(this.activeLook)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.activeLook)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;break;case 81:this.freeze=!this.freeze}};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=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=
|
|
|
|
|
this.heightSpeed?this.tdiff*((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c);this.moveRight&&this.translateX(c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&
|
|
|
|
|
(this.lat-=this.mouseY*c);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;var b=this.target.position,f=this.position;b.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=f.y+100*Math.cos(this.phi);b.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);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;if(this.constrainVertical)this.phi=
|
|
|
|
|
(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;f=this.position;b.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=f.y+100*Math.cos(this.phi);b.z=f.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),
|
|
|
|
|
(this.lat-=this.mouseY*c);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;var b=this.target.position,g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);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;if(this.constrainVertical)this.phi=
|
|
|
|
|
(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.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(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))};
|
|
|
|
|
THREE.PathCamera=function(b){function c(b,c,d,e){var f={name:d,fps:0.6,length:e,hierarchy:[]},h,j=c.getControlPointsArray(),k=c.getLength(),m=j.length,D=0;h=m-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[h]={time:e,pos:j[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<m-1;h++)D=e*k.chunks[h]/k.total,c.keys[h]={time:D,pos:j[h]};f.hierarchy[0]=c;THREE.AnimationHandler.add(f);return new THREE.Animation(b,d,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function d(b,c){var d,
|
|
|
|
|
e,f=new THREE.Geometry;for(d=0;d<b.points.length*c;d++)e=d/(b.points.length*c),e=b.getPoint(e),f.vertices[d]=new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z));return f}function e(b,c){var e=d(c,10),f=d(c,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(e,h);particleObj=new THREE.ParticleSystem(f,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.addChild(lineObj);particleObj.scale.set(1,1,1);b.addChild(particleObj);f=new THREE.Sphere(1,
|
|
|
|
|
16,8);h=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)e=new THREE.Mesh(f,h),e.position.copy(c.points[i]),e.updateMatrix(),b.addChild(e)}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.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.lookHorizontal=
|
|
|
|
|
THREE.PathCamera=function(b){function c(b,c,e,f){var g={name:e,fps:0.6,length:f,hierarchy:[]},j,k=c.getControlPointsArray(),m=c.getLength(),n=k.length,K=0;j=n-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:k[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[j]={time:f,pos:k[j],rot:[0,0,0,1],scl:[1,1,1]};for(j=1;j<n-1;j++)K=f*m.chunks[j]/m.total,c.keys[j]={time:K,pos:k[j]};g.hierarchy[0]=c;THREE.AnimationHandler.add(g);return new THREE.Animation(b,e,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,c){var e,
|
|
|
|
|
f,g=new THREE.Geometry;for(e=0;e<b.points.length*c;e++)f=e/(b.points.length*c),f=b.getPoint(f),g.vertices[e]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return g}function f(b,c){var f=e(c,10),g=e(c,10),j=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,j);particleObj=new THREE.ParticleSystem(g,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.addChild(lineObj);particleObj.scale.set(1,1,1);b.addChild(particleObj);g=new THREE.Sphere(1,
|
|
|
|
|
16,8);j=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(g,j),f.position.copy(c.points[i]),f.updateMatrix(),b.addChild(f)}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.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.lookHorizontal=
|
|
|
|
|
this.lookVertical=!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(b){if(b.duration!==void 0)this.duration=b.duration*1E3;if(b.waypoints!==void 0)this.waypoints=b.waypoints;if(b.useConstantSpeed!==void 0)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==void 0)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==void 0)this.createDebugPath=b.createDebugPath;if(b.createDebugDummy!==
|
|
|
|
|
void 0)this.createDebugDummy=b.createDebugDummy;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.lookHorizontal!==void 0)this.lookHorizontal=b.lookHorizontal;if(b.verticalAngleMap!==void 0)this.verticalAngleMap=b.verticalAngleMap;if(b.horizontalAngleMap!==void 0)this.horizontalAngleMap=b.horizontalAngleMap;if(b.domElement!==void 0)this.domElement=b.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 f=Math.PI*2,h=Math.PI/180;this.update=function(b,c,d){var e,j;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)*h;this.theta=this.lon*h;e=this.phi%f;this.phi=e>=0?e:e+f;e=this.verticalAngleMap.srcRange;j=this.verticalAngleMap.dstRange;var k=j[1]-j[0];this.phi=
|
|
|
|
|
TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(j[1]-j[0])/(e[1]-e[0])+j[0]-j[0])/k)*k+j[0];e=this.horizontalAngleMap.srcRange;j=this.horizontalAngleMap.dstRange;k=j[1]-j[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-e[0])*(j[1]-j[0])/(e[1]-e[0])+j[0]-j[0])/k)*k+j[0];e=this.target.position;e.x=100*Math.sin(this.phi)*Math.cos(this.theta);e.y=100*Math.cos(this.phi);e.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,c,d)};this.onMouseMove=function(b){this.mouseX=
|
|
|
|
|
b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),j=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.Cube(10,10,20),m=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.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(b)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,c){return function(){c.apply(b,arguments)}}(this,this.onMouseMove),!1)};
|
|
|
|
|
window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,j=Math.PI/180;this.update=function(b,c,e){var f,k;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)*j;this.theta=this.lon*j;f=this.phi%g;this.phi=f>=0?f:f+g;f=this.verticalAngleMap.srcRange;k=this.verticalAngleMap.dstRange;var m=k[1]-k[0];this.phi=
|
|
|
|
|
TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/m)*m+k[0];f=this.horizontalAngleMap.srcRange;k=this.horizontalAngleMap.dstRange;m=k[1]-k[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/m)*m+k[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,c,e)};this.onMouseMove=function(b){this.mouseX=
|
|
|
|
|
b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),k=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.Cube(10,10,20),n=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(n,k);b.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(b)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,c){return function(){c.apply(b,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;
|
|
|
|
|
THREE.FlyCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward=
|
|
|
|
|
b.autoForward;if(b.domElement!==void 0)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier=
|
|
|
|
|
0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};
|
|
|
|
|
this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;
|
|
|
|
|
case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(),f=c.size[0]/2,h=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-f)/f;this.moveState.pitchDown=(b.clientY-
|
|
|
|
|
c.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,c=this.tdiff*
|
|
|
|
|
case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(),g=c.size[0]/2,j=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY-
|
|
|
|
|
c.offset[1]-j)/j;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,c=this.tdiff*
|
|
|
|
|
this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var b=this.moveState.forward||
|
|
|
|
|
this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=
|
|
|
|
|
document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this,
|
|
|
|
|
this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype;
|
|
|
|
|
THREE.RollCamera=function(b,c,d,e){THREE.Camera.call(this,b,c,d,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var f=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Matrix4,m=!1,o=1,n=0,p=0,t=0,u=0,v=0,C=window.innerWidth/2,E=window.innerHeight/2;this.update=
|
|
|
|
|
function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*u),this.rotateVertically(b*v));b=this.delta*this.movementSpeed;this.translateZ(b*(n>0||this.autoForward&&!(n<0)?1:n));this.translateX(b*p);this.translateY(b*t);m&&(this.roll+=this.rollSpeed*this.delta*o);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
|
|
|
|
|
else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();j.copy(this.forward);h.set(0,1,0);f.cross(h,j).normalize();h.cross(j,f).normalize();this.matrix.n11=f.x;this.matrix.n12=h.x;this.matrix.n13=j.x;this.matrix.n21=f.y;this.matrix.n22=h.y;this.matrix.n23=j.y;this.matrix.n31=f.z;this.matrix.n32=h.z;this.matrix.n33=j.z;k.identity();k.n11=Math.cos(this.roll);k.n12=-Math.sin(this.roll);k.n21=Math.sin(this.roll);k.n22=Math.cos(this.roll);this.matrix.multiplySelf(k);
|
|
|
|
|
THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Matrix4,n=!1,p=1,o=0,t=0,u=0,v=0,w=0,E=window.innerWidth/2,H=window.innerHeight/2;this.update=
|
|
|
|
|
function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*v),this.rotateVertically(b*w));b=this.delta*this.movementSpeed;this.translateZ(b*(o>0||this.autoForward&&!(o<0)?1:o));this.translateX(b*t);this.translateY(b*u);n&&(this.roll+=this.rollSpeed*this.delta*p);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
|
|
|
|
|
else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();k.copy(this.forward);j.set(0,1,0);g.cross(j,k).normalize();j.cross(k,g).normalize();this.matrix.n11=g.x;this.matrix.n12=j.x;this.matrix.n13=k.x;this.matrix.n21=g.y;this.matrix.n22=j.y;this.matrix.n23=k.y;this.matrix.n31=g.z;this.matrix.n32=j.z;this.matrix.n33=k.z;m.identity();m.n11=Math.cos(this.roll);m.n12=-Math.sin(this.roll);m.n21=Math.sin(this.roll);m.n22=Math.cos(this.roll);this.matrix.multiplySelf(m);
|
|
|
|
|
this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(b){this.position.x+=this.matrix.n11*b;this.position.y+=this.matrix.n21*b;this.position.z+=this.matrix.n31*b};this.translateY=function(b){this.position.x+=this.matrix.n12*b;this.position.y+=this.matrix.n22*b;this.position.z+=this.matrix.n32*b};this.translateZ=function(b){this.position.x-=this.matrix.n13*b;this.position.y-=
|
|
|
|
|
this.matrix.n23*b;this.position.z-=this.matrix.n33*b};this.rotateHorizontally=function(b){f.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);f.multiplyScalar(b);this.forward.subSelf(f);this.forward.normalize()};this.rotateVertically=function(b){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(b);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
|
|
|
|
|
function(b){u=(b.clientX-C)/window.innerWidth;v=(b.clientY-E)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:n=1;break;case 2:n=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:n=0;break;case 2:n=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:n=1;break;case 37:case 65:p=-1;break;
|
|
|
|
|
case 40:case 83:n=-1;break;case 39:case 68:p=1;break;case 81:m=!0;o=1;break;case 69:m=!0;o=-1;break;case 82:t=1;break;case 70:t=-1}},!1);this.domElement.addEventListener("keyup",function(b){switch(b.keyCode){case 38:case 87:n=0;break;case 37:case 65:p=0;break;case 40:case 83:n=0;break;case 39:case 68:p=0;break;case 81:m=!1;break;case 69:m=!1;break;case 82:t=0;break;case 70:t=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
|
|
|
|
|
this.matrix.n23*b;this.position.z-=this.matrix.n33*b};this.rotateHorizontally=function(b){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(b);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(b){j.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);j.multiplyScalar(b);this.forward.addSelf(j);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
|
|
|
|
|
function(b){v=(b.clientX-E)/window.innerWidth;w=(b.clientY-H)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:o=1;break;case 2:o=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:o=0;break;case 2:o=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:o=1;break;case 37:case 65:t=-1;break;
|
|
|
|
|
case 40:case 83:o=-1;break;case 39:case 68:t=1;break;case 81:n=!0;p=1;break;case 69:n=!0;p=-1;break;case 82:u=1;break;case 70:u=-1}},!1);this.domElement.addEventListener("keyup",function(b){switch(b.keyCode){case 38:case 87:o=0;break;case 37:case 65:t=0;break;case 40:case 83:o=0;break;case 39:case 68:t=0;break;case 81:n=!1;break;case 69:n=!1;break;case 82:u=0;break;case 70:u=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
|
|
|
|
|
THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
|
|
|
|
|
THREE.TrackballCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}b=b||{};THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.domElement=b.domElement||document;this.screen=b.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=b.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=b.rotateSpeed||1;this.zoomSpeed=b.zoomSpeed||1.2;this.panSpeed=b.panSpeed||0.3;this.noZoom=b.noZoom||!1;this.noPan=b.noPan||
|
|
|
|
|
!1;this.staticMoving=b.staticMoving||!1;this.dynamicDampingFactor=b.dynamicDampingFactor||0.2;this.minDistance=b.minDistance||0;this.maxDistance=b.maxDistance||Infinity;this.keys=b.keys||[65,83,68];this.useTarget=!0;var d=!1,e=this.STATE.NONE,f=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector2,m=new THREE.Vector2,o=new THREE.Vector2,n=new THREE.Vector2;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.getMouseOnScreen=function(b,c){return new THREE.Vector2((b-
|
|
|
|
|
this.screen.offsetLeft)/this.radius*0.5,(c-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(b,c){var d=new THREE.Vector3((b-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-c)/this.radius,0),e=d.length();e>1?d.normalize():d.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(d.y);e.addSelf(this.up.clone().crossSelf(f).setLength(d.x));e.addSelf(f.setLength(d.z));return e};
|
|
|
|
|
this.rotateCamera=function(){var b=Math.acos(h.dot(j)/h.length()/j.length());if(b){var c=(new THREE.Vector3).cross(h,j).normalize(),d=new THREE.Quaternion;b*=this.rotateSpeed;d.setFromAxisAngle(c,-b);d.multiplyVector3(f);d.multiplyVector3(this.up);d.multiplyVector3(j);this.staticMoving?h=j:(d.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var b=1+(m.y-k.y)*this.zoomSpeed;b!==1&&b>0&&(f.multiplyScalar(b),this.staticMoving?k=m:k.y+=(m.y-k.y)*this.dynamicDampingFactor)};
|
|
|
|
|
this.panCamera=function(){var b=n.clone().subSelf(o);if(b.lengthSq()){b.multiplyScalar(f.length()*this.panSpeed);var c=f.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?o=n:o.addSelf(b.sub(n,o).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
|
|
|
|
|
f.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,f.setLength(this.minDistance))};this.update=function(b,c,d){f=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,f);this.checkDistances();this.supr.update.call(this,b,c,d)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
|
|
|
|
|
c(this,function(b){d&&(h=j=this.getMouseProjectionOnBall(b.clientX,b.clientY),k=m=this.getMouseOnScreen(b.clientX,b.clientY),o=n=this.getMouseOnScreen(b.clientX,b.clientY),d=!1);e!==this.STATE.NONE&&(e===this.STATE.ROTATE?j=this.getMouseProjectionOnBall(b.clientX,b.clientY):e===this.STATE.ZOOM&&!this.noZoom?m=this.getMouseOnScreen(b.clientX,b.clientY):e===this.STATE.PAN&&!this.noPan&&(n=this.getMouseOnScreen(b.clientX,b.clientY)))}),!1);this.domElement.addEventListener("mousedown",c(this,function(b){b.preventDefault();
|
|
|
|
|
b.stopPropagation();if(e===this.STATE.NONE)e=b.button,e===this.STATE.ROTATE?h=j=this.getMouseProjectionOnBall(b.clientX,b.clientY):e===this.STATE.ZOOM&&!this.noZoom?k=m=this.getMouseOnScreen(b.clientX,b.clientY):this.noPan||(o=n=this.getMouseOnScreen(b.clientX,b.clientY))}),!1);this.domElement.addEventListener("mouseup",c(this,function(b){b.preventDefault();b.stopPropagation();e=this.STATE.NONE}),!1);window.addEventListener("keydown",c(this,function(b){if(e===this.STATE.NONE){if(b.keyCode===this.keys[this.STATE.ROTATE])e=
|
|
|
|
|
this.STATE.ROTATE;else if(b.keyCode===this.keys[this.STATE.ZOOM]&&!this.noZoom)e=this.STATE.ZOOM;else if(b.keyCode===this.keys[this.STATE.PAN]&&!this.noPan)e=this.STATE.PAN;e!==this.STATE.NONE&&(d=!0)}}),!1);window.addEventListener("keyup",c(this,function(){if(e!==this.STATE.NONE)e=this.STATE.NONE}),!1)};THREE.TrackballCamera.prototype=new THREE.Camera;THREE.TrackballCamera.prototype.constructor=THREE.TrackballCamera;THREE.TrackballCamera.prototype.supr=THREE.Camera.prototype;
|
|
|
|
|
!1;this.staticMoving=b.staticMoving||!1;this.dynamicDampingFactor=b.dynamicDampingFactor||0.2;this.minDistance=b.minDistance||0;this.maxDistance=b.maxDistance||Infinity;this.keys=b.keys||[65,83,68];this.useTarget=!0;var e=!1,f=this.STATE.NONE,g=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Vector2,n=new THREE.Vector2,p=new THREE.Vector2,o=new THREE.Vector2;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.getMouseOnScreen=function(b,c){return new THREE.Vector2((b-
|
|
|
|
|
this.screen.offsetLeft)/this.radius*0.5,(c-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(b,c){var e=new THREE.Vector3((b-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-c)/this.radius,0),f=e.length();f>1?e.normalize():e.z=Math.sqrt(1-f*f);g=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(e.y);f.addSelf(this.up.clone().crossSelf(g).setLength(e.x));f.addSelf(g.setLength(e.z));return f};
|
|
|
|
|
this.rotateCamera=function(){var b=Math.acos(j.dot(k)/j.length()/k.length());if(b){var c=(new THREE.Vector3).cross(j,k).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(g);e.multiplyVector3(this.up);e.multiplyVector3(k);this.staticMoving?j=k:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(j))}};this.zoomCamera=function(){var b=1+(n.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?m=n:m.y+=(n.y-m.y)*this.dynamicDampingFactor)};
|
|
|
|
|
this.panCamera=function(){var b=o.clone().subSelf(p);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var c=g.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?p=o:p.addSelf(b.sub(o,p).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
|
|
|
|
|
g.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,g.setLength(this.minDistance))};this.update=function(b,c,e){g=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,g);this.checkDistances();this.supr.update.call(this,b,c,e)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
|
|
|
|
|
c(this,function(b){e&&(j=k=this.getMouseProjectionOnBall(b.clientX,b.clientY),m=n=this.getMouseOnScreen(b.clientX,b.clientY),p=o=this.getMouseOnScreen(b.clientX,b.clientY),e=!1);f!==this.STATE.NONE&&(f===this.STATE.ROTATE?k=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?n=this.getMouseOnScreen(b.clientX,b.clientY):f===this.STATE.PAN&&!this.noPan&&(o=this.getMouseOnScreen(b.clientX,b.clientY)))}),!1);this.domElement.addEventListener("mousedown",c(this,function(b){b.preventDefault();
|
|
|
|
|
b.stopPropagation();if(f===this.STATE.NONE)f=b.button,f===this.STATE.ROTATE?j=k=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?m=n=this.getMouseOnScreen(b.clientX,b.clientY):this.noPan||(p=o=this.getMouseOnScreen(b.clientX,b.clientY))}),!1);this.domElement.addEventListener("mouseup",c(this,function(b){b.preventDefault();b.stopPropagation();f=this.STATE.NONE}),!1);window.addEventListener("keydown",c(this,function(b){if(f===this.STATE.NONE){if(b.keyCode===this.keys[this.STATE.ROTATE])f=
|
|
|
|
|
this.STATE.ROTATE;else if(b.keyCode===this.keys[this.STATE.ZOOM]&&!this.noZoom)f=this.STATE.ZOOM;else if(b.keyCode===this.keys[this.STATE.PAN]&&!this.noPan)f=this.STATE.PAN;f!==this.STATE.NONE&&(e=!0)}}),!1);window.addEventListener("keyup",c(this,function(){if(f!==this.STATE.NONE)f=this.STATE.NONE}),!1)};THREE.TrackballCamera.prototype=new THREE.Camera;THREE.TrackballCamera.prototype.constructor=THREE.TrackballCamera;THREE.TrackballCamera.prototype.supr=THREE.Camera.prototype;
|
|
|
|
|
THREE.TrackballCamera.prototype.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};
|
|
|
|
|
THREE.Cube=function(b,c,d,e,f,h,j,k,m){function o(b,c,d,j,k,m,o,p){var t,u,v=e||1,C=f||1,g=k/2,Y=m/2,O=n.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")t="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")t="y",C=h||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")t="x",v=h||1;var V=v+1,L=C+1;k/=v;var $=m/C;for(u=0;u<L;u++)for(m=0;m<V;m++){var T=new THREE.Vector3;T[b]=(m*k-g)*d;T[c]=(u*$-Y)*j;T[t]=o;n.vertices.push(new THREE.Vertex(T))}for(u=0;u<C;u++)for(m=0;m<v;m++)n.faces.push(new THREE.Face4(m+V*u+O,m+V*(u+
|
|
|
|
|
1)+O,m+1+V*(u+1)+O,m+1+V*u+O,null,null,p)),n.faceVertexUvs[0].push([new THREE.UV(m/v,u/C),new THREE.UV(m/v,(u+1)/C),new THREE.UV((m+1)/v,(u+1)/C),new THREE.UV((m+1)/v,u/C)])}THREE.Geometry.call(this);var n=this,p=b/2,t=c/2,u=d/2,k=k?-1:1;if(j!==void 0)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var v=0;v<6;v++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(m!=void 0)for(var C in m)this.sides[C]!=void 0&&(this.sides[C]=m[C]);
|
|
|
|
|
this.sides.px&&o("z","y",1*k,-1,d,c,-p,this.materials[0]);this.sides.nx&&o("z","y",-1*k,-1,d,c,p,this.materials[1]);this.sides.py&&o("x","z",1*k,1,b,d,t,this.materials[2]);this.sides.ny&&o("x","z",1*k,-1,b,d,-t,this.materials[3]);this.sides.pz&&o("x","y",1*k,-1,b,c,u,this.materials[4]);this.sides.nz&&o("x","y",-1*k,-1,b,c,-u,this.materials[5]);(function(){for(var b=[],c=[],d=0,e=n.vertices.length;d<e;d++){for(var f=n.vertices[d],h=!1,j=0,k=b.length;j<k;j++){var m=b[j];if(f.position.x==m.position.x&&
|
|
|
|
|
f.position.y==m.position.y&&f.position.z==m.position.z){c[d]=j;h=!0;break}}if(!h)c[d]=b.length,b.push(new THREE.Vertex(f.position.clone()))}d=0;for(e=n.faces.length;d<e;d++)f=n.faces[d],f.a=c[f.a],f.b=c[f.b],f.c=c[f.c],f.d=c[f.d];n.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
|
|
|
|
|
THREE.Cylinder=function(b,c,d,e,f,h){function j(b,c,d){k.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,d)))}THREE.Geometry.call(this);var k=this,m,o=Math.PI*2,n=e/2;for(m=0;m<b;m++)j(Math.sin(o*m/b)*c,Math.cos(o*m/b)*c,-n);for(m=0;m<b;m++)j(Math.sin(o*m/b)*d,Math.cos(o*m/b)*d,n);for(m=0;m<b;m++)k.faces.push(new THREE.Face4(m,m+b,b+(m+1)%b,(m+1)%b));if(d>0){j(0,0,-n-(h||0));for(m=b;m<b+b/2;m++)k.faces.push(new THREE.Face4(2*b,(2*m-2*b)%b,(2*m-2*b+1)%b,(2*m-2*b+2)%b))}if(c>0){j(0,0,n+(f||0));
|
|
|
|
|
for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m<b;m++){var c=[],d=this.faces[m],f=this.vertices[d.a],h=this.vertices[d.b],n=this.vertices[d.c],p=this.vertices[d.d];c.push(new THREE.UV(0.5+Math.atan2(f.position.x,f.position.y)/o,0.5+f.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(h.position.x,h.position.y)/o,0.5+h.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(n.position.x,n.position.y)/o,0.5+n.position.z/
|
|
|
|
|
e));d instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(p.position.x,p.position.y)/o,0.5+p.position.z/e));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
|
|
|
|
|
THREE.Icosahedron=function(b){function c(b,c,d){var e=Math.sqrt(b*b+c*c+d*d);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(b/e,c/e,d/e)))-1}function d(b,c,d,e){e.faces.push(new THREE.Face3(b,c,d))}function e(b,d){var e=f.vertices[b].position,h=f.vertices[d].position;return c((e.x+h.x)/2,(e.y+h.y)/2,(e.z+h.z)/2)}var f=this,h=new THREE.Geometry,j;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;c(-1,b,0);c(1,b,0);c(-1,-b,0);c(1,-b,0);c(0,-1,b);c(0,1,b);c(0,-1,-b);c(0,
|
|
|
|
|
1,-b);c(b,0,-1);c(b,0,1);c(-b,0,-1);c(-b,0,1);d(0,11,5,h);d(0,5,1,h);d(0,1,7,h);d(0,7,10,h);d(0,10,11,h);d(1,5,9,h);d(5,11,4,h);d(11,10,2,h);d(10,7,6,h);d(7,1,8,h);d(3,9,4,h);d(3,4,2,h);d(3,2,6,h);d(3,6,8,h);d(3,8,9,h);d(4,9,5,h);d(2,4,11,h);d(6,2,10,h);d(8,6,7,h);d(9,8,1,h);for(b=0;b<this.subdivisions;b++){j=new THREE.Geometry;for(var k in h.faces){var m=e(h.faces[k].a,h.faces[k].b),o=e(h.faces[k].b,h.faces[k].c),n=e(h.faces[k].c,h.faces[k].a);d(h.faces[k].a,m,n,j);d(h.faces[k].b,o,m,j);d(h.faces[k].c,
|
|
|
|
|
n,o,j);d(m,o,n,j)}h.faces=j.faces}f.faces=h.faces;delete h;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
|
|
|
|
|
THREE.Lathe=function(b,c,d){THREE.Geometry.call(this);this.steps=c||12;this.angle=d||2*Math.PI;for(var c=this.angle/this.steps,d=[],e=[],f=[],h=[],j=(new THREE.Matrix4).setRotationZ(c),k=0;k<b.length;k++)this.vertices.push(new THREE.Vertex(b[k])),d[k]=b[k].clone(),e[k]=this.vertices.length-1;for(var m=0;m<=this.angle+0.0010;m+=c){for(k=0;k<d.length;k++)m<this.angle?(d[k]=j.multiplyVector3(d[k].clone()),this.vertices.push(new THREE.Vertex(d[k])),f[k]=this.vertices.length-1):f=h;m==0&&(h=e);for(k=0;k<
|
|
|
|
|
e.length-1;k++)this.faces.push(new THREE.Face4(f[k],f[k+1],e[k+1],e[k])),this.faceVertexUvs[0].push([new THREE.UV(1-m/this.angle,k/b.length),new THREE.UV(1-m/this.angle,(k+1)/b.length),new THREE.UV(1-(m-c)/this.angle,(k+1)/b.length),new THREE.UV(1-(m-c)/this.angle,k/b.length)]);e=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
|
|
|
|
|
THREE.Plane=function(b,c,d,e){THREE.Geometry.call(this);var f,h=b/2,j=c/2,d=d||1,e=e||1,k=d+1,m=e+1;b/=d;var o=c/e;for(f=0;f<m;f++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-h,-(f*o-j),0)));for(f=0;f<e;f++)for(c=0;c<d;c++)this.faces.push(new THREE.Face4(c+k*f,c+k*(f+1),c+1+k*(f+1),c+1+k*f)),this.faceVertexUvs[0].push([new THREE.UV(c/d,f/e),new THREE.UV(c/d,(f+1)/e),new THREE.UV((c+1)/d,(f+1)/e),new THREE.UV((c+1)/d,f/e)]);this.computeCentroids();this.computeFaceNormals()};
|
|
|
|
|
THREE.Cube=function(b,c,e,f,g,j,k,m,n){function p(b,c,e,k,m,n,p,t){var u,v,w=f||1,E=g||1,h=m/2,X=n/2,O=o.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")u="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")u="y",E=j||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")u="x",w=j||1;var aa=w+1,M=E+1;m/=w;var da=n/E;for(v=0;v<M;v++)for(n=0;n<aa;n++){var U=new THREE.Vector3;U[b]=(n*m-h)*e;U[c]=(v*da-X)*k;U[u]=p;o.vertices.push(new THREE.Vertex(U))}for(v=0;v<E;v++)for(n=0;n<w;n++)o.faces.push(new THREE.Face4(n+aa*v+O,
|
|
|
|
|
n+aa*(v+1)+O,n+1+aa*(v+1)+O,n+1+aa*v+O,null,null,t)),o.faceVertexUvs[0].push([new THREE.UV(n/w,v/E),new THREE.UV(n/w,(v+1)/E),new THREE.UV((n+1)/w,(v+1)/E),new THREE.UV((n+1)/w,v/E)])}THREE.Geometry.call(this);var o=this,t=b/2,u=c/2,v=e/2,m=m?-1:1;if(k!==void 0)if(k instanceof Array)this.materials=k;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([k])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(n!=void 0)for(var E in n)this.sides[E]!=void 0&&(this.sides[E]=
|
|
|
|
|
n[E]);this.sides.px&&p("z","y",1*m,-1,e,c,-t,this.materials[0]);this.sides.nx&&p("z","y",-1*m,-1,e,c,t,this.materials[1]);this.sides.py&&p("x","z",1*m,1,b,e,u,this.materials[2]);this.sides.ny&&p("x","z",1*m,-1,b,e,-u,this.materials[3]);this.sides.pz&&p("x","y",1*m,-1,b,c,v,this.materials[4]);this.sides.nz&&p("x","y",-1*m,-1,b,c,-v,this.materials[5]);(function(){for(var b=[],c=[],e=0,f=o.vertices.length;e<f;e++){for(var g=o.vertices[e],j=!1,k=0,m=b.length;k<m;k++){var n=b[k];if(g.position.x==n.position.x&&
|
|
|
|
|
g.position.y==n.position.y&&g.position.z==n.position.z){c[e]=k;j=!0;break}}if(!j)c[e]=b.length,b.push(new THREE.Vertex(g.position.clone()))}e=0;for(f=o.faces.length;e<f;e++)g=o.faces[e],g.a=c[g.a],g.b=c[g.b],g.c=c[g.c],g.d=c[g.d];o.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
|
|
|
|
|
THREE.Cylinder=function(b,c,e,f,g,j){function k(b,c,e){m.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}THREE.Geometry.call(this);var m=this,n,p=Math.PI*2,o=f/2;for(n=0;n<b;n++)k(Math.sin(p*n/b)*c,Math.cos(p*n/b)*c,-o);for(n=0;n<b;n++)k(Math.sin(p*n/b)*e,Math.cos(p*n/b)*e,o);for(n=0;n<b;n++)m.faces.push(new THREE.Face4(n,n+b,b+(n+1)%b,(n+1)%b));if(e>0){k(0,0,-o-(j||0));for(n=b;n<b+b/2;n++)m.faces.push(new THREE.Face4(2*b,(2*n-2*b)%b,(2*n-2*b+1)%b,(2*n-2*b+2)%b))}if(c>0){k(0,0,o+(g||0));
|
|
|
|
|
for(n=b+b/2;n<2*b;n++)m.faces.push(new THREE.Face4(2*b+1,(2*n-2*b+2)%b+b,(2*n-2*b+1)%b+b,(2*n-2*b)%b+b))}n=0;for(b=this.faces.length;n<b;n++){var c=[],e=this.faces[n],g=this.vertices[e.a],j=this.vertices[e.b],o=this.vertices[e.c],t=this.vertices[e.d];c.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/p,0.5+g.position.z/f));c.push(new THREE.UV(0.5+Math.atan2(j.position.x,j.position.y)/p,0.5+j.position.z/f));c.push(new THREE.UV(0.5+Math.atan2(o.position.x,o.position.y)/p,0.5+o.position.z/
|
|
|
|
|
f));e instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(t.position.x,t.position.y)/p,0.5+t.position.z/f));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
|
|
|
|
|
THREE.Icosahedron=function(b){function c(b,c,e){var f=Math.sqrt(b*b+c*c+e*e);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(b/f,c/f,e/f)))-1}function e(b,c,e,f){f.faces.push(new THREE.Face3(b,c,e))}function f(b,e){var f=g.vertices[b].position,j=g.vertices[e].position;return c((f.x+j.x)/2,(f.y+j.y)/2,(f.z+j.z)/2)}var g=this,j=new THREE.Geometry,k;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;c(-1,b,0);c(1,b,0);c(-1,-b,0);c(1,-b,0);c(0,-1,b);c(0,1,b);c(0,-1,-b);c(0,
|
|
|
|
|
1,-b);c(b,0,-1);c(b,0,1);c(-b,0,-1);c(-b,0,1);e(0,11,5,j);e(0,5,1,j);e(0,1,7,j);e(0,7,10,j);e(0,10,11,j);e(1,5,9,j);e(5,11,4,j);e(11,10,2,j);e(10,7,6,j);e(7,1,8,j);e(3,9,4,j);e(3,4,2,j);e(3,2,6,j);e(3,6,8,j);e(3,8,9,j);e(4,9,5,j);e(2,4,11,j);e(6,2,10,j);e(8,6,7,j);e(9,8,1,j);for(b=0;b<this.subdivisions;b++){k=new THREE.Geometry;for(var m in j.faces){var n=f(j.faces[m].a,j.faces[m].b),p=f(j.faces[m].b,j.faces[m].c),o=f(j.faces[m].c,j.faces[m].a);e(j.faces[m].a,n,o,k);e(j.faces[m].b,p,n,k);e(j.faces[m].c,
|
|
|
|
|
o,p,k);e(n,p,o,k)}j.faces=k.faces}g.faces=j.faces;delete j;delete k;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
|
|
|
|
|
THREE.Lathe=function(b,c,e){THREE.Geometry.call(this);this.steps=c||12;this.angle=e||2*Math.PI;for(var c=this.angle/this.steps,e=[],f=[],g=[],j=[],k=(new THREE.Matrix4).setRotationZ(c),m=0;m<b.length;m++)this.vertices.push(new THREE.Vertex(b[m])),e[m]=b[m].clone(),f[m]=this.vertices.length-1;for(var n=0;n<=this.angle+0.0010;n+=c){for(m=0;m<e.length;m++)n<this.angle?(e[m]=k.multiplyVector3(e[m].clone()),this.vertices.push(new THREE.Vertex(e[m])),g[m]=this.vertices.length-1):g=j;n==0&&(j=f);for(m=0;m<
|
|
|
|
|
f.length-1;m++)this.faces.push(new THREE.Face4(g[m],g[m+1],f[m+1],f[m])),this.faceVertexUvs[0].push([new THREE.UV(1-n/this.angle,m/b.length),new THREE.UV(1-n/this.angle,(m+1)/b.length),new THREE.UV(1-(n-c)/this.angle,(m+1)/b.length),new THREE.UV(1-(n-c)/this.angle,m/b.length)]);f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
|
|
|
|
|
THREE.Plane=function(b,c,e,f){THREE.Geometry.call(this);var g,j=b/2,k=c/2,e=e||1,f=f||1,m=e+1,n=f+1;b/=e;var p=c/f;for(g=0;g<n;g++)for(c=0;c<m;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-j,-(g*p-k),0)));for(g=0;g<f;g++)for(c=0;c<e;c++)this.faces.push(new THREE.Face4(c+m*g,c+m*(g+1),c+1+m*(g+1),c+1+m*g)),this.faceVertexUvs[0].push([new THREE.UV(c/e,g/f),new THREE.UV(c/e,(g+1)/f),new THREE.UV((c+1)/e,(g+1)/f),new THREE.UV((c+1)/e,g/f)]);this.computeCentroids();this.computeFaceNormals()};
|
|
|
|
|
THREE.Plane.prototype=new THREE.Geometry;THREE.Plane.prototype.constructor=THREE.Plane;
|
|
|
|
|
THREE.Sphere=function(b,c,d){THREE.Geometry.call(this);for(var e,f=Math.PI,h=Math.max(3,c||8),j=Math.max(2,d||6),c=[],d=0;d<j+1;d++){e=d/j;var k=b*Math.cos(e*f),m=b*Math.sin(e*f),o=[],n=0;for(e=0;e<h;e++){var p=2*e/h,t=m*Math.sin(p*f),p=m*Math.cos(p*f);(d==0||d==j)&&e>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,k,t)))-1);o.push(n)}c.push(o)}for(var u,v,C,f=c.length,d=0;d<f;d++)if(h=c[d].length,d>0)for(e=0;e<h;e++){o=e==h-1;j=c[d][o?0:e+1];k=c[d][o?h-1:e];m=c[d-1][o?h-1:e];o=c[d-
|
|
|
|
|
1][o?0:e+1];t=d/(f-1);u=(d-1)/(f-1);v=(e+1)/h;var p=e/h,n=new THREE.UV(1-v,t),t=new THREE.UV(1-p,t),p=new THREE.UV(1-p,u),E=new THREE.UV(1-v,u);d<c.length-1&&(u=this.vertices[j].position.clone(),v=this.vertices[k].position.clone(),C=this.vertices[m].position.clone(),u.normalize(),v.normalize(),C.normalize(),this.faces.push(new THREE.Face3(j,k,m,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(C.x,C.y,C.z)])),this.faceVertexUvs[0].push([n,t,p]));d>1&&(u=this.vertices[j].position.clone(),
|
|
|
|
|
v=this.vertices[m].position.clone(),C=this.vertices[o].position.clone(),u.normalize(),v.normalize(),C.normalize(),this.faces.push(new THREE.Face3(j,m,o,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(C.x,C.y,C.z)])),this.faceVertexUvs[0].push([n,p,E]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
|
|
|
|
|
THREE.Torus=function(b,c,d,e){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;b=[];for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){var e=d/this.segmentsT*2*Math.PI,f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));b.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
|
|
|
|
|
1;d<=this.segmentsT;++d){var e=(this.segmentsT+1)*c+d,f=(this.segmentsT+1)*c+d-1,h=(this.segmentsT+1)*(c-1)+d-1,j=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,f,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[e][0],b[e][1]),new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus;
|
|
|
|
|
THREE.TorusKnot=function(b,c,d,e,f,h,j){function k(b,c,d,e,f,h){c=d/e*b;d=Math.cos(c);return new THREE.Vector3(f*(2+d)*0.5*Math.cos(b),f*(2+d)*Math.sin(b)*0.5,h*f*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=d||64;this.segmentsT=e||8;this.p=f||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);d=new THREE.Vector3;e=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var m=
|
|
|
|
|
b/this.segmentsR*2*this.p*Math.PI,j=c/this.segmentsT*2*Math.PI,f=k(m,j,this.q,this.p,this.radius,this.heightScale),m=k(m+0.01,j,this.q,this.p,this.radius,this.heightScale);d.x=m.x-f.x;d.y=m.y-f.y;d.z=m.z-f.z;e.x=m.x+f.x;e.y=m.y+f.y;e.z=m.z+f.z;h.cross(d,e);e.cross(h,d);h.normalize();e.normalize();m=-this.tube*Math.cos(j);j=this.tube*Math.sin(j);f.x+=m*e.x+j*h.x;f.y+=m*e.y+j*h.y;f.z+=m*e.z+j*h.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=
|
|
|
|
|
0;c<this.segmentsT;++c){var e=(b+1)%this.segmentsR,h=(c+1)%this.segmentsT,f=this.grid[b][c],d=this.grid[e][c],e=this.grid[e][h],h=this.grid[b][h],j=new THREE.UV(b/this.segmentsR,c/this.segmentsT),m=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),o=new THREE.UV((b+1)/this.segmentsR,(c+1)/this.segmentsT),n=new THREE.UV(b/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(f,d,e,h));this.faceVertexUvs[0].push([j,m,o,n])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
|
|
|
|
|
THREE.TorusKnot.prototype=new THREE.Geometry;THREE.TorusKnot.prototype.constructor=THREE.TorusKnot;THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
|
|
|
|
|
THREE.Sphere=function(b,c,e){THREE.Geometry.call(this);for(var f,g=Math.PI,j=Math.max(3,c||8),k=Math.max(2,e||6),c=[],e=0;e<k+1;e++){f=e/k;var m=b*Math.cos(f*g),n=b*Math.sin(f*g),p=[],o=0;for(f=0;f<j;f++){var t=2*f/j,u=n*Math.sin(t*g),t=n*Math.cos(t*g);(e==0||e==k)&&f>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,m,u)))-1);p.push(o)}c.push(p)}for(var v,w,E,g=c.length,e=0;e<g;e++)if(j=c[e].length,e>0)for(f=0;f<j;f++){p=f==j-1;k=c[e][p?0:f+1];m=c[e][p?j-1:f];n=c[e-1][p?j-1:f];p=c[e-
|
|
|
|
|
1][p?0:f+1];u=e/(g-1);v=(e-1)/(g-1);w=(f+1)/j;var t=f/j,o=new THREE.UV(1-w,u),u=new THREE.UV(1-t,u),t=new THREE.UV(1-t,v),H=new THREE.UV(1-w,v);e<c.length-1&&(v=this.vertices[k].position.clone(),w=this.vertices[m].position.clone(),E=this.vertices[n].position.clone(),v.normalize(),w.normalize(),E.normalize(),this.faces.push(new THREE.Face3(k,m,n,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(E.x,E.y,E.z)])),this.faceVertexUvs[0].push([o,u,t]));e>1&&(v=this.vertices[k].position.clone(),
|
|
|
|
|
w=this.vertices[n].position.clone(),E=this.vertices[p].position.clone(),v.normalize(),w.normalize(),E.normalize(),this.faces.push(new THREE.Face3(k,n,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(E.x,E.y,E.z)])),this.faceVertexUvs[0].push([o,t,H]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
|
|
|
|
|
THREE.Torus=function(b,c,e,f){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=e||8;this.segmentsT=f||6;b=[];for(c=0;c<=this.segmentsR;++c)for(e=0;e<=this.segmentsT;++e){var f=e/this.segmentsT*2*Math.PI,g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([e/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(e=
|
|
|
|
|
1;e<=this.segmentsT;++e){var f=(this.segmentsT+1)*c+e,g=(this.segmentsT+1)*c+e-1,j=(this.segmentsT+1)*(c-1)+e-1,k=(this.segmentsT+1)*(c-1)+e;this.faces.push(new THREE.Face4(f,g,j,k));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[j][0],b[j][1]),new THREE.UV(b[k][0],b[k][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus;
|
|
|
|
|
THREE.TorusKnot=function(b,c,e,f,g,j,k){function m(b,c,e,f,g,j){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(g*(2+e)*0.5*Math.cos(b),g*(2+e)*Math.sin(b)*0.5,j*g*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=g||2;this.q=j||3;this.heightScale=k||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;j=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var n=
|
|
|
|
|
b/this.segmentsR*2*this.p*Math.PI,k=c/this.segmentsT*2*Math.PI,g=m(n,k,this.q,this.p,this.radius,this.heightScale),n=m(n+0.01,k,this.q,this.p,this.radius,this.heightScale);e.x=n.x-g.x;e.y=n.y-g.y;e.z=n.z-g.z;f.x=n.x+g.x;f.y=n.y+g.y;f.z=n.z+g.z;j.cross(e,f);f.cross(j,e);j.normalize();f.normalize();n=-this.tube*Math.cos(k);k=this.tube*Math.sin(k);g.x+=n*f.x+k*j.x;g.y+=n*f.y+k*j.y;g.z+=n*f.z+k*j.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,g.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=
|
|
|
|
|
0;c<this.segmentsT;++c){var f=(b+1)%this.segmentsR,j=(c+1)%this.segmentsT,g=this.grid[b][c],e=this.grid[f][c],f=this.grid[f][j],j=this.grid[b][j],k=new THREE.UV(b/this.segmentsR,c/this.segmentsT),n=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),p=new THREE.UV((b+1)/this.segmentsR,(c+1)/this.segmentsT),o=new THREE.UV(b/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,e,f,j));this.faceVertexUvs[0].push([k,n,p,o])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
|
|
|
|
|
THREE.TorusKnot.prototype=new THREE.Geometry;THREE.TorusKnot.prototype.constructor=THREE.TorusKnot;
|
|
|
|
|
THREE.Text=function(b,c){THREE.Geometry.call(this);var c=c||{},e=c.height!==void 0?c.height:50,f=c.curveSegments!==void 0?c.curveSegments:4;THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=f;f=THREE.FontUtils.drawText(b);vertices=f.points;faces=f.faces;contour=f.contour;var g,j,f=0;for(g in vertices)j=vertices[g],this.vertices.push(new THREE.Vertex(new THREE.Vector3(j.x,j.y,0))),f++;for(g in vertices)j=vertices[g],this.vertices.push(new THREE.Vertex(new THREE.Vector3(j.x,
|
|
|
|
|
j.y,e)));for(g in faces)e=faces[g],this.faces.push(new THREE.Face3(e[2],e[1],e[0]));for(g in faces)e=faces[g],this.faces.push(new THREE.Face3(e[0]+f,e[1]+f,e[2]+f));g=contour.length;for(var k;--g>0;){if(k){if(k.equals(contour[g])){k=null;continue}}else k=contour[g];for(e=0;e<vertices.length;e++)if(vertices[e].equals(contour[g]))break;for(j=0;j<vertices.length;j++)if(vertices[j].equals(contour[g-1]))break;this.faces.push(new THREE.Face4(e,j,j+f,e+f))}this.computeCentroids();this.computeFaceNormals()};
|
|
|
|
|
THREE.Text.prototype=new THREE.Geometry;THREE.Text.prototype.constructor=THREE.Text;
|
|
|
|
|
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},extractPoints:function(b){if(b.length<3)console.log("not valid polygon");
|
|
|
|
|
else{var c=[],e,f,g=[],j;for(j in b)e=b[j],c.push(e.x+","+e.y);e=c[0];e=c.slice(1).indexOf(e);e<c.length&&(e++,f=b.slice(0,e));for(holes=[];e<c.length;){firstIndex=e+1;e=c[firstIndex];e=c.slice(firstIndex+1).indexOf(e)+firstIndex;if(e<=firstIndex)break;var k=b.slice(firstIndex,e+1);this.Triangulate.area(k)<0?(g.push({shape:f,holes:holes}),f=k,holes=[]):holes.push(k);e++}g.push({shape:f,holes:holes});var c=[],m;for(m in g){e=g[m];f=e.shape;holes=e.holes;for(var n in holes){var b=holes[n],k=Number.POSITIVE_INFINITY,
|
|
|
|
|
p,o,t;for(t in b){var u=b[t];for(j in f)d=u.distanceTo(f[j]),d<k&&(k=d,p=t,o=j)}prevShapeVert=o-1>=0?o-1:f.length-1;nextShapeVert=o+1<f.length?o+1:0;prevHoleVert=p-1>=0?p-1:b.length-1;nextHoleVert=p+1<b.length?p+1:0;var k=f.slice(0,o),u=f.slice(o),v=b.slice(p),w=b.slice(0,p);c.push(b[p]);c.push(f[o]);c.push(f[prevShapeVert]);c.push(b[p]);c.push(b[prevHoleVert]);c.push(f[o]);e.shape=k.concat(v).concat(w).concat(u)}}b=[];j=[];p=0;for(m in g){e=g[m];f=e.shape;b=b.concat(f);o=THREE.FontUtils.Triangulate(f,
|
|
|
|
|
!0);for(var E in o)n=o[E],n[0]+=p,n[1]+=p,n[2]+=p;j=j.concat(o);p+=f.length}for(E=0;E<c.length/3;E++){n=[];for(g=0;g<3;g++)for(f=0;f<b.length;f++)if(b[f].equals(c[E*3+g])){n.push(f);break}j.push(n)}return{points:b,faces:j}}},drawText:function(b){for(var c=[],e=this.getFace(),f=this.size/e.resolution,g=0,j=String(b).split(""),k=j.length,b=0;b<k;b++)g+=this.extractGlyphPoints(c,j[b],e,f,g);var e=g/2,m;for(m in c)c[m].x-=e;m=this.extractPoints(c);m.contour=c;return m},b2p0:function(b,c){return(1-b)*
|
|
|
|
|
(1-b)*c},b2p1:function(b,c){return 2*(1-b)*b*c},b2p2:function(b,c){return b*b*c},b2:function(b,c,e,f){return this.b2p0(b,c)+this.b2p1(b,e)+this.b2p2(b,f)},b3p0:function(b,c){var e=1-b;return e*e*e*c},b3p1:function(b,c){var e=1-b;return 3*e*e*b*c},b3p2:function(b,c){return 3*(1-b)*b*b*c},b3p3:function(b,c){return b*b*b*c},b3:function(b,c,e,f,g){return this.b3p0(b,c)+this.b3p1(b,e)+this.b3p2(b,f)+this.b3p3(b,g)},extractGlyphPoints:function(b,c,e,f,g){var j,k,m,n=e.glyphs[c]||e.glyphs[ctxt.options.fallbackCharacter];
|
|
|
|
|
if(n){if(n.o){e=n._cachedOutline||(n._cachedOutline=n.o.split(" "));m=e.length;for(c=0;c<m;)switch(j=e[c++],j){case "m":x=e[c++]*f+g;y=e[c++]*f;b.push(new THREE.Vector2(x,y));break;case "l":x=e[c++]*f+g;y=e[c++]*f;b.push(new THREE.Vector2(x,y));break;case "q":j=e[c++]*f+g;k=e[c++]*f;cpx1=e[c++]*f+g;cpy1=e[c++]*f;var p=b[b.length-1];if(p){cpx0=p.x;cpy0=p.y;for(var p=1,o=this.divisions;p<=o;p++){var t=p/o,u=THREE.FontUtils.b2(t,cpx0,cpx1,j),t=THREE.FontUtils.b2(t,cpy0,cpy1,k);b.push(new THREE.Vector2(u,
|
|
|
|
|
t))}}break;case "b":if(j=e[c++]*f+g,k=e[c++]*f,cpx1=e[c++]*f+g,cpy1=e[c++]*-f,cpx2=e[c++]*f+g,cpy2=e[c++]*-f,p=b[b.length-1]){cpx0=p.x;cpy0=p.y;p=1;for(o=this.divisions;p<=o;p++)t=p/o,u=THREE.FontUtils.b3(t,cpx0,cpx1,cpx2,j),t=THREE.FontUtils.b3(t,cpy0,cpy1,cpy2,k),b.push(new THREE.Vector2(u,t))}}}return n.ha*f}}};
|
|
|
|
|
(function(b){var c=function(b){for(var c=b.length,g=0,j=c-1,k=0;k<c;j=k++)g+=b[j].x*b[k].y-b[k].x*b[j].y;return g*0.5};b.Triangulate=function(b,f){var g=[],j=b.length;if(j<3)return null;var k=[],m=[],n;if(0<c(b))for(n=0;n<j;n++)k[n]=n;else for(n=0;n<j;n++)k[n]=j-1-n;var p=2*j,o;o=0;for(n=j-1;j>2;){if(0>=p--)return console.log("Warning, unable to triangulate polygon!"),null;var t=n;j<=t&&(t=0);n=t+1;j<=n&&(n=0);var u=n+1;j<=u&&(u=0);var v;a:{v=b;var w=t,E=n,H=u,B=j,K=k,A=void 0,I=void 0,G=void 0,C=
|
|
|
|
|
void 0,R=void 0,D=void 0,N=void 0,J=void 0,V=void 0,I=v[K[w]].x,G=v[K[w]].y,C=v[K[E]].x,R=v[K[E]].y,D=v[K[H]].x,N=v[K[H]].y;if(1.0E-10>(C-I)*(N-G)-(R-G)*(D-I))v=!1;else{for(A=0;A<B;A++)if(!(A==w||A==E||A==H)){var J=v[K[A]].x,V=v[K[A]].y,h=void 0,X=void 0,O=void 0,aa=void 0,M=void 0,da=void 0,U=void 0,S=void 0,ja=void 0,W=void 0,ga=void 0,Y=void 0,h=O=M=void 0,h=D-C,X=N-R,O=I-D,aa=G-N,M=C-I,da=R-G,U=J-I,S=V-G,ja=J-C,W=V-R,ga=J-D,Y=V-N,h=h*W-X*ja,M=M*S-da*U,O=O*Y-aa*ga;if(h>=0&&O>=0&&M>=0){v=!1;break a}}v=
|
|
|
|
|
!0}}if(v){p=k[t];v=k[n];w=k[u];g.push(b[p]);g.push(b[v]);g.push(b[w]);m.push([k[t],k[n],k[u]]);o++;t=n;for(u=n+1;u<j;t++,u++)k[t]=k[u];j--;p=2*j}}if(f)return m;return g};b.Triangulate.area=c;return b})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
|
|
|
|
|
THREE.Loader.prototype={addStatusElement:function(){var b=document.createElement("div");b.style.position="absolute";b.style.right="0px";b.style.top="0px";b.style.fontSize="0.8em";b.style.textAlign="left";b.style.background="rgba(0,0,0,0.25)";b.style.color="#fff";b.style.width="120px";b.style.padding="0.5em 0.5em 0.5em 0.5em";b.style.zIndex=1E3;b.innerHTML="Loading ...";return b},updateProgress:function(b){var c="Loaded ";c+=b.total?(100*b.loaded/b.total).toFixed(0)+"%":(b.loaded/1E3).toFixed(2)+" KB";
|
|
|
|
|
this.statusDomElement.innerHTML=c},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,c,d){b.materials=[];for(var e=0;e<c.length;++e)b.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],d)]},createMaterial:function(b,c){function d(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==b}function e(b,c){var e=new Image;e.onload=function(){if(!d(this.width)||!d(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),e=Math.pow(2,Math.round(Math.log(this.height)/
|
|
|
|
|
Math.LN2));b.image.width=c;b.image.height=e;b.image.getContext("2d").drawImage(this,0,0,c,e)}else b.image=this;b.needsUpdate=!0};e.src=c}var f,h,j;f="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?f="MeshPhongMaterial":b.shading=="Basic"&&(f="MeshBasicMaterial"));if(b.blending)if(b.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(b.blending==
|
|
|
|
|
"Multiply")h.blending=THREE.MultiplyBlending;if(b.transparent!==void 0||b.opacity<1)h.transparent=b.transparent;if(b.depthTest!==void 0)h.depthTest=b.depthTest;if(b.vertexColors!==void 0)if(b.vertexColors=="face")h.vertexColors=THREE.FaceColors;else if(b.vertexColors)h.vertexColors=THREE.VertexColors;if(b.mapDiffuse&&c)j=document.createElement("canvas"),h.map=new THREE.Texture(j),h.map.sourceFile=b.mapDiffuse,e(h.map,c+"/"+b.mapDiffuse);else if(b.colorDiffuse)j=(b.colorDiffuse[0]*255<<16)+(b.colorDiffuse[1]*
|
|
|
|
|
255<<8)+b.colorDiffuse[2]*255,h.color=j,h.opacity=b.transparency;else if(b.DbgColor)h.color=b.DbgColor;if(b.mapLightmap&&c)j=document.createElement("canvas"),h.lightMap=new THREE.Texture(j),h.lightMap.sourceFile=b.mapLightmap,e(h.lightMap,c+"/"+b.mapLightmap);return new THREE[f](h)}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
|
|
|
|
|
THREE.JSONLoader.prototype.load=function(b){var c=this,d=b.model,e=b.callback,f=b.texture_path?b.texture_path:this.extractUrlbase(d),b=new Worker(d);b.onmessage=function(b){c.createModel(b.data,e,f);c.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
|
|
|
|
|
THREE.JSONLoader.prototype.createModel=function(b,c,d){var e=new THREE.Geometry,f=b.scale!==void 0?1/b.scale:1;this.init_materials(e,b.materials,d);(function(c){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var d,f,m,o,n,p,t,u,v,C,E,y,D,x,I=b.faces;p=b.vertices;var A=b.normals,z=b.colors,S=0;for(d=0;d<b.uvs.length;d++)b.uvs[d].length&&S++;for(d=0;d<S;d++)e.faceUvs[d]=[],e.faceVertexUvs[d]=[];o=0;for(n=p.length;o<n;)t=new THREE.Vertex,t.position.x=p[o++]*c,t.position.y=
|
|
|
|
|
p[o++]*c,t.position.z=p[o++]*c,e.vertices.push(t);o=0;for(n=I.length;o<n;){c=I[o++];p=c&1;m=c&2;d=c&4;f=c&8;u=c&16;t=c&32;C=c&64;c&=128;p?(E=new THREE.Face4,E.a=I[o++],E.b=I[o++],E.c=I[o++],E.d=I[o++],p=4):(E=new THREE.Face3,E.a=I[o++],E.b=I[o++],E.c=I[o++],p=3);if(m)m=I[o++],E.materials=e.materials[m];m=e.faces.length;if(d)for(d=0;d<S;d++)y=b.uvs[d],v=I[o++],x=y[v*2],v=y[v*2+1],e.faceUvs[d][m]=new THREE.UV(x,v);if(f)for(d=0;d<S;d++){y=b.uvs[d];D=[];for(f=0;f<p;f++)v=I[o++],x=y[v*2],v=y[v*2+1],D[f]=
|
|
|
|
|
new THREE.UV(x,v);e.faceVertexUvs[d][m]=D}if(u)u=I[o++]*3,f=new THREE.Vector3,f.x=A[u++],f.y=A[u++],f.z=A[u],E.normal=f;if(t)for(d=0;d<p;d++)u=I[o++]*3,f=new THREE.Vector3,f.x=A[u++],f.y=A[u++],f.z=A[u],E.vertexNormals.push(f);if(C)t=I[o++],t=new THREE.Color(z[t]),E.color=t;if(c)for(d=0;d<p;d++)t=I[o++],t=new THREE.Color(z[t]),E.vertexColors.push(t);e.faces.push(E)}}})(f);(function(){var c,d,f,m;if(b.skinWeights){c=0;for(d=b.skinWeights.length;c<d;c+=2)f=b.skinWeights[c],m=b.skinWeights[c+1],e.skinWeights.push(new THREE.Vector4(f,
|
|
|
|
|
m,0,0))}if(b.skinIndices){c=0;for(d=b.skinIndices.length;c<d;c+=2)f=b.skinIndices[c],m=b.skinIndices[c+1],e.skinIndices.push(new THREE.Vector4(f,m,0,0))}e.bones=b.bones;e.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var d,f,m,o,n,p,t,u,v;d=0;for(f=b.morphTargets.length;d<f;d++){e.morphTargets[d]={};e.morphTargets[d].name=b.morphTargets[d].name;e.morphTargets[d].vertices=[];u=e.morphTargets[d].vertices;v=b.morphTargets[d].vertices;m=0;for(o=v.length;m<o;m+=3)n=v[m]*c,p=v[m+1]*
|
|
|
|
|
c,t=v[m+2]*c,u.push(new THREE.Vertex(new THREE.Vector3(n,p,t)))}}if(b.morphColors!==void 0){d=0;for(f=b.morphColors.length;d<f;d++){e.morphColors[d]={};e.morphColors[d].name=b.morphColors[d].name;e.morphColors[d].colors=[];o=e.morphColors[d].colors;n=b.morphColors[d].colors;c=0;for(m=n.length;c<m;c+=3)p=new THREE.Color(16755200),p.setRGB(n[c],n[c+1],n[c+2]),o.push(p)}}})(f);(function(){if(b.edges!==void 0){var c,d,f;for(c=0;c<b.edges.length;c+=2)d=b.edges[c],f=b.edges[c+1],e.edges.push(new THREE.Edge(e.vertices[d],
|
|
|
|
|
e.vertices[f],d,f))}})();e.computeCentroids();e.computeFaceNormals();c(e)};THREE.BinaryLoader=function(b){THREE.Loader.call(this,b)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
|
|
|
|
|
THREE.BinaryLoader.prototype={load:function(b){var c=b.model,d=b.callback,e=b.texture_path?b.texture_path:THREE.Loader.prototype.extractUrlbase(c),f=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(c),b=(new Date).getTime(),c=new Worker(c),h=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(b){THREE.BinaryLoader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,d,f,e,h)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};
|
|
|
|
|
c.postMessage(b)},loadAjaxBuffers:function(b,c,d,e,f,h){var j=new XMLHttpRequest,k=e+"/"+b,m=0;j.onreadystatechange=function(){j.readyState==4?j.status==200||j.status==0?THREE.BinaryLoader.prototype.createBinModel(j.responseText,d,f,c):alert("Couldn't load ["+k+"] ["+j.status+"]"):j.readyState==3?h&&(m==0&&(m=j.getResponseHeader("Content-Length")),h({total:m,loaded:j.responseText.length})):j.readyState==2&&(m=j.getResponseHeader("Content-Length"))};j.open("GET",k,!0);j.overrideMimeType("text/plain; charset=x-user-defined");
|
|
|
|
|
j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(b,c,d,e){var f=function(c){function d(b,c){var e=n(b,c),f=n(b,c+1),g=n(b,c+2),h=n(b,c+3),j=(h<<1&255|g>>7)-127;e|=(g&127)<<16|f<<8;if(e==0&&j==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function f(b,c){var d=n(b,c),e=n(b,c+1),g=n(b,c+2);return(n(b,c+3)<<24)+(g<<16)+(e<<8)+d}function m(b,c){var d=n(b,c);return(n(b,c+1)<<8)+d}function o(b,c){var d=n(b,c);return d>127?d-256:d}function n(b,
|
|
|
|
|
c){return b.charCodeAt(c)&255}function p(c){var d,e,g;d=f(b,c);e=f(b,c+z);g=f(b,c+S);c=m(b,c+G);THREE.BinaryLoader.prototype.f3(y,d,e,g,c)}function t(c){var d,e,g,h,j,n;d=f(b,c);e=f(b,c+z);g=f(b,c+S);h=m(b,c+G);j=f(b,c+M);n=f(b,c+F);c=f(b,c+N);THREE.BinaryLoader.prototype.f3n(y,I,d,e,g,h,j,n,c)}function u(c){var d,e,h,j;d=f(b,c);e=f(b,c+g);h=f(b,c+Y);j=f(b,c+O);c=m(b,c+V);THREE.BinaryLoader.prototype.f4(y,d,e,h,j,c)}function v(c){var d,e,h,j,n,o,p,t;d=f(b,c);e=f(b,c+g);h=f(b,c+Y);j=f(b,c+O);n=m(b,
|
|
|
|
|
c+V);o=f(b,c+L);p=f(b,c+$);t=f(b,c+T);c=f(b,c+Q);THREE.BinaryLoader.prototype.f4n(y,I,d,e,h,j,n,o,p,t,c)}function C(c){var d,e;d=f(b,c);e=f(b,c+fa);c=f(b,c+U);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],A[d*2],A[d*2+1],A[e*2],A[e*2+1],A[c*2],A[c*2+1])}function E(c){var d,e,g;d=f(b,c);e=f(b,c+ka);g=f(b,c+ga);c=f(b,c+ca);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],A[d*2],A[d*2+1],A[e*2],A[e*2+1],A[g*2],A[g*2+1],A[c*2],A[c*2+1])}var y=this,D=0,x,I=[],A=[],z,S,G,M,F,N,g,Y,O,V,L,$,T,Q,
|
|
|
|
|
fa,U,ka,ga,ca,aa,R,P,W,X,ea;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,e,c);x={signature:b.substr(D,8),header_bytes:n(b,D+8),vertex_coordinate_bytes:n(b,D+9),normal_coordinate_bytes:n(b,D+10),uv_coordinate_bytes:n(b,D+11),vertex_index_bytes:n(b,D+12),normal_index_bytes:n(b,D+13),uv_index_bytes:n(b,D+14),material_index_bytes:n(b,D+15),nvertices:f(b,D+16),nnormals:f(b,D+16+4),nuvs:f(b,D+16+8),ntri_flat:f(b,D+16+12),ntri_smooth:f(b,D+16+16),ntri_flat_uv:f(b,D+16+20),ntri_smooth_uv:f(b,
|
|
|
|
|
D+16+24),nquad_flat:f(b,D+16+28),nquad_smooth:f(b,D+16+32),nquad_flat_uv:f(b,D+16+36),nquad_smooth_uv:f(b,D+16+40)};D+=x.header_bytes;z=x.vertex_index_bytes;S=x.vertex_index_bytes*2;G=x.vertex_index_bytes*3;M=x.vertex_index_bytes*3+x.material_index_bytes;F=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes;N=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2;g=x.vertex_index_bytes;Y=x.vertex_index_bytes*2;O=x.vertex_index_bytes*3;V=x.vertex_index_bytes*4;L=x.vertex_index_bytes*
|
|
|
|
|
4+x.material_index_bytes;$=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes;T=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2;Q=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3;fa=x.uv_index_bytes;U=x.uv_index_bytes*2;ka=x.uv_index_bytes;ga=x.uv_index_bytes*2;ca=x.uv_index_bytes*3;c=x.vertex_index_bytes*3+x.material_index_bytes;ea=x.vertex_index_bytes*4+x.material_index_bytes;aa=x.ntri_flat*c;R=x.ntri_smooth*(c+x.normal_index_bytes*3);P=x.ntri_flat_uv*
|
|
|
|
|
(c+x.uv_index_bytes*3);W=x.ntri_smooth_uv*(c+x.normal_index_bytes*3+x.uv_index_bytes*3);X=x.nquad_flat*ea;c=x.nquad_smooth*(ea+x.normal_index_bytes*4);ea=x.nquad_flat_uv*(ea+x.uv_index_bytes*4);D+=function(c){for(var e,f,g,h=x.vertex_coordinate_bytes*3,k=c+x.nvertices*h;c<k;c+=h)e=d(b,c),f=d(b,c+x.vertex_coordinate_bytes),g=d(b,c+x.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(y,e,f,g);return x.nvertices*h}(D);D+=function(c){for(var d,e,f,g=x.normal_coordinate_bytes*3,h=c+x.nnormals*g;c<
|
|
|
|
|
h;c+=g)d=o(b,c),e=o(b,c+x.normal_coordinate_bytes),f=o(b,c+x.normal_coordinate_bytes*2),I.push(d/127,e/127,f/127);return x.nnormals*g}(D);D+=function(c){for(var e,f,g=x.uv_coordinate_bytes*2,h=c+x.nuvs*g;c<h;c+=g)e=d(b,c),f=d(b,c+x.uv_coordinate_bytes),A.push(e,f);return x.nuvs*g}(D);aa=D+aa;R=aa+R;P=R+P;W=P+W;X=W+X;c=X+c;ea=c+ea;(function(b){var c,d=x.vertex_index_bytes*3+x.material_index_bytes,e=d+x.uv_index_bytes*3,f=b+x.ntri_flat_uv*e;for(c=b;c<f;c+=e)p(c),C(c+d);return f-b})(R);(function(b){var c,
|
|
|
|
|
d=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,e=d+x.uv_index_bytes*3,f=b+x.ntri_smooth_uv*e;for(c=b;c<f;c+=e)t(c),C(c+d);return f-b})(P);(function(b){var c,d=x.vertex_index_bytes*4+x.material_index_bytes,e=d+x.uv_index_bytes*4,f=b+x.nquad_flat_uv*e;for(c=b;c<f;c+=e)u(c),E(c+d);return f-b})(c);(function(b){var c,d=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,e=d+x.uv_index_bytes*4,f=b+x.nquad_smooth_uv*e;for(c=b;c<f;c+=e)v(c),E(c+d);return f-b})(ea);
|
|
|
|
|
(function(b){var c,d=x.vertex_index_bytes*3+x.material_index_bytes,e=b+x.ntri_flat*d;for(c=b;c<e;c+=d)p(c);return e-b})(D);(function(b){var c,d=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*3,e=b+x.ntri_smooth*d;for(c=b;c<e;c+=d)t(c);return e-b})(aa);(function(b){var c,d=x.vertex_index_bytes*4+x.material_index_bytes,e=b+x.nquad_flat*d;for(c=b;c<e;c+=d)u(c);return e-b})(W);(function(b){var c,d=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*4,e=b+x.nquad_smooth*
|
|
|
|
|
d;for(c=b;c<e;c+=d)v(c);return e-b})(X);this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},v:function(b,c,d,e){b.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(b,c,d,e,f){b.faces.push(new THREE.Face3(c,d,e,null,null,b.materials[f]))},f4:function(b,c,d,e,f,h){b.faces.push(new THREE.Face4(c,d,e,f,null,null,b.materials[h]))},f3n:function(b,c,d,e,f,h,j,k,m){var h=b.materials[h],o=c[k*3],n=c[k*3+1],k=c[k*3+2],
|
|
|
|
|
p=c[m*3],t=c[m*3+1],m=c[m*3+2];b.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(o,n,k),new THREE.Vector3(p,t,m)],null,h))},f4n:function(b,c,d,e,f,h,j,k,m,o,n){var j=b.materials[j],p=c[m*3],t=c[m*3+1],m=c[m*3+2],u=c[o*3],v=c[o*3+1],o=c[o*3+2],C=c[n*3],E=c[n*3+1],n=c[n*3+2];b.faces.push(new THREE.Face4(d,e,f,h,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(p,t,m),new THREE.Vector3(u,v,o),new THREE.Vector3(C,E,n)],null,j))},uv3:function(b,
|
|
|
|
|
c,d,e,f,h,j){var k=[];k.push(new THREE.UV(c,d));k.push(new THREE.UV(e,f));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,c,d,e,f,h,j,k,m){var o=[];o.push(new THREE.UV(c,d));o.push(new THREE.UV(e,f));o.push(new THREE.UV(h,j));o.push(new THREE.UV(k,m));b.push(o)}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
|
|
|
|
|
THREE.SceneLoader.prototype={load:function(b,c){var d=this,e=new Worker(b);e.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(b);e.onmessage=function(b){function e(b,c){return c=="relativeToHTML"?b:f+"/"+b}function k(){for(u in F.objects)if(!L.objects[u])if(D=F.objects[u],D.geometry!==void 0){if(z=L.geometries[D.geometry]){M=[];for(Q=0;Q<D.materials.length;Q++)M[Q]=L.materials[D.materials[Q]];x=D.position;r=D.rotation;q=D.quaternion;s=D.scale;q=0;M.length==0&&(M[0]=new THREE.MeshFaceMaterial);
|
|
|
|
|
M.length>1&&(M=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(z,M);object.name=u;object.position.set(x[0],x[1],x[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=D.visible;L.scene.addObject(object);L.objects[u]=object;if(D.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(object);L.scene.collisions.colliders.push(b)}if(D.castsShadow)b=new THREE.ShadowVolume(z),L.scene.addChild(b),
|
|
|
|
|
b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},L.triggers[object.name]=b)}}else x=D.position,r=D.rotation,q=D.quaternion,s=D.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(x[0],x[1],x[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible=D.visible!==void 0?D.visible:!1,L.scene.addObject(object),
|
|
|
|
|
L.objects[u]=object,L.empties[u]=object,D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},L.triggers[object.name]=b)}function m(b){return function(c){L.geometries[b]=c;k();g-=1;d.onLoadComplete();n()}}function o(b){return function(c){L.geometries[b]=c}}function n(){d.callbackProgress({totalModels:O,totalTextures:V,loadedModels:O-g,loadedTextures:V-Y},L);d.onLoadProgress();g==0&&Y==0&&c(L)}var p,t,u,v,C,E,y,D,x,I,A,z,S,G,M,F,N,g,Y,O,V,L;F=b.data;b=new THREE.BinaryLoader;N=new THREE.JSONLoader;
|
|
|
|
|
Y=g=0;L={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var $=!1;for(u in F.objects)if(D=F.objects[u],D.meshCollider){$=!0;break}if($)L.scene.collisions=new THREE.CollisionSystem;if(F.transform){$=F.transform.position;I=F.transform.rotation;var T=F.transform.scale;$&&L.scene.position.set($[0],$[1],$[2]);I&&L.scene.rotation.set(I[0],I[1],I[2]);T&&L.scene.scale.set(T[0],T[1],T[2]);($||I||T)&&L.scene.updateMatrix()}$=function(){Y-=
|
|
|
|
|
1;n();d.onLoadComplete()};for(C in F.cameras){I=F.cameras[C];if(I.type=="perspective")S=new THREE.Camera(I.fov,I.aspect,I.near,I.far);else if(I.type=="ortho")S=new THREE.Camera,S.projectionMatrix=THREE.Matrix4.makeOrtho(I.left,I.right,I.top,I.bottom,I.near,I.far);x=I.position;I=I.target;S.position.set(x[0],x[1],x[2]);S.target.position.set(I[0],I[1],I[2]);L.cameras[C]=S}for(v in F.lights){C=F.lights[v];S=C.color!==void 0?C.color:16777215;I=C.intensity!==void 0?C.intensity:1;if(C.type=="directional")x=
|
|
|
|
|
C.direction,light=new THREE.DirectionalLight(S,I),light.position.set(x[0],x[1],x[2]),light.position.normalize();else if(C.type=="point")x=C.position,light=new THREE.PointLight(S,I),light.position.set(x[0],x[1],x[2]);L.scene.addLight(light);L.lights[v]=light}for(E in F.fogs)v=F.fogs[E],v.type=="linear"?G=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(G=new THREE.FogExp2(0,v.density)),I=v.color,G.color.setRGB(I[0],I[1],I[2]),L.fogs[E]=G;if(L.cameras&&F.defaults.camera)L.currentCamera=L.cameras[F.defaults.camera];
|
|
|
|
|
if(L.fogs&&F.defaults.fog)L.scene.fog=L.fogs[F.defaults.fog];I=F.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(I[0],I[1],I[2]);L.bgColorAlpha=F.defaults.bgalpha;for(p in F.geometries)if(E=F.geometries[p],E.type=="bin_mesh"||E.type=="ascii_mesh")g+=1,d.onLoadStart();O=g;for(p in F.geometries)E=F.geometries[p],E.type=="cube"?(z=new THREE.Cube(E.width,E.height,E.depth,E.segmentsWidth,E.segmentsHeight,E.segmentsDepth,null,E.flipped,E.sides),L.geometries[p]=z):E.type=="plane"?(z=new THREE.Plane(E.width,
|
|
|
|
|
E.height,E.segmentsWidth,E.segmentsHeight),L.geometries[p]=z):E.type=="sphere"?(z=new THREE.Sphere(E.radius,E.segmentsWidth,E.segmentsHeight),L.geometries[p]=z):E.type=="cylinder"?(z=new THREE.Cylinder(E.numSegs,E.topRad,E.botRad,E.height,E.topOffset,E.botOffset),L.geometries[p]=z):E.type=="torus"?(z=new THREE.Torus(E.radius,E.tube,E.segmentsR,E.segmentsT),L.geometries[p]=z):E.type=="icosahedron"?(z=new THREE.Icosahedron(E.subdivisions),L.geometries[p]=z):E.type=="bin_mesh"?b.load({model:e(E.url,
|
|
|
|
|
F.urlBaseType),callback:m(p)}):E.type=="ascii_mesh"?N.load({model:e(E.url,F.urlBaseType),callback:m(p)}):E.type=="embedded_mesh"&&(E=F.embeds[E.id])&&N.createModel(E,o(p),"");for(y in F.textures)if(p=F.textures[y],p.url instanceof Array){Y+=p.url.length;for(b=0;b<p.url.length;b++)d.onLoadStart()}else Y+=1,d.onLoadStart();V=Y;for(y in F.textures){p=F.textures[y];if(p.mapping!=void 0&&THREE[p.mapping]!=void 0)p.mapping=new THREE[p.mapping];if(p.url instanceof Array){for(var b=[],Q=0;Q<p.url.length;Q++)b[Q]=
|
|
|
|
|
e(p.url[Q],F.urlBaseType);b=THREE.ImageUtils.loadTextureCube(b,p.mapping,$)}else{b=THREE.ImageUtils.loadTexture(e(p.url,F.urlBaseType),p.mapping,$);if(THREE[p.minFilter]!=void 0)b.minFilter=THREE[p.minFilter];if(THREE[p.magFilter]!=void 0)b.magFilter=THREE[p.magFilter]}L.textures[y]=b}for(t in F.materials){y=F.materials[t];for(A in y.parameters)if(A=="envMap"||A=="map"||A=="lightMap")y.parameters[A]=L.textures[y.parameters[A]];else if(A=="shading")y.parameters[A]=y.parameters[A]=="flat"?THREE.FlatShading:
|
|
|
|
|
THREE.SmoothShading;else if(A=="blending")y.parameters[A]=THREE[y.parameters[A]]?THREE[y.parameters[A]]:THREE.NormalBlending;else if(A=="combine")y.parameters[A]=y.parameters[A]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(A=="vertexColors")if(y.parameters[A]=="face")y.parameters[A]=THREE.FaceColors;else if(y.parameters[A])y.parameters[A]=THREE.VertexColors;if(y.parameters.opacity!==void 0&&y.parameters.opacity<1)y.parameters.transparent=!0;y=new THREE[y.type](y.parameters);
|
|
|
|
|
L.materials[t]=y}k();d.callbackSync(L)}}};
|
|
|
|
|
this.statusDomElement.innerHTML=c},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,c,e){b.materials=[];for(var f=0;f<c.length;++f)b.materials[f]=[THREE.Loader.prototype.createMaterial(c[f],e)]},createMaterial:function(b,c){function e(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==b}function f(b,c){var f=new Image;f.onload=function(){if(!e(this.width)||!e(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),f=Math.pow(2,Math.round(Math.log(this.height)/
|
|
|
|
|
Math.LN2));b.image.width=c;b.image.height=f;b.image.getContext("2d").drawImage(this,0,0,c,f)}else b.image=this;b.needsUpdate=!0};f.src=c}var g,j,k;g="MeshLambertMaterial";j={color:15658734,opacity:1,map:null,lightMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?g="MeshPhongMaterial":b.shading=="Basic"&&(g="MeshBasicMaterial"));if(b.blending)if(b.blending=="Additive")j.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")j.blending=THREE.SubtractiveBlending;else if(b.blending==
|
|
|
|
|
"Multiply")j.blending=THREE.MultiplyBlending;if(b.transparent!==void 0||b.opacity<1)j.transparent=b.transparent;if(b.depthTest!==void 0)j.depthTest=b.depthTest;if(b.vertexColors!==void 0)if(b.vertexColors=="face")j.vertexColors=THREE.FaceColors;else if(b.vertexColors)j.vertexColors=THREE.VertexColors;if(b.mapDiffuse&&c)k=document.createElement("canvas"),j.map=new THREE.Texture(k),j.map.sourceFile=b.mapDiffuse,f(j.map,c+"/"+b.mapDiffuse);else if(b.colorDiffuse)k=(b.colorDiffuse[0]*255<<16)+(b.colorDiffuse[1]*
|
|
|
|
|
255<<8)+b.colorDiffuse[2]*255,j.color=k,j.opacity=b.transparency;else if(b.DbgColor)j.color=b.DbgColor;if(b.mapLightmap&&c)k=document.createElement("canvas"),j.lightMap=new THREE.Texture(k),j.lightMap.sourceFile=b.mapLightmap,f(j.lightMap,c+"/"+b.mapLightmap);return new THREE[g](j)}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
|
|
|
|
|
THREE.JSONLoader.prototype.load=function(b){var c=this,e=b.model,f=b.callback,g=b.texture_path?b.texture_path:this.extractUrlbase(e),b=new Worker(e);b.onmessage=function(b){c.createModel(b.data,f,g);c.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
|
|
|
|
|
THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,g=b.scale!==void 0?1/b.scale:1;this.init_materials(f,b.materials,e);(function(c){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var e,g,n,p,o,t,u,v,w,E,H,B,K,A,I=b.faces;t=b.vertices;var G=b.normals,C=b.colors,R=0;for(e=0;e<b.uvs.length;e++)b.uvs[e].length&&R++;for(e=0;e<R;e++)f.faceUvs[e]=[],f.faceVertexUvs[e]=[];p=0;for(o=t.length;p<o;)u=new THREE.Vertex,u.position.x=t[p++]*c,u.position.y=
|
|
|
|
|
t[p++]*c,u.position.z=t[p++]*c,f.vertices.push(u);p=0;for(o=I.length;p<o;){c=I[p++];t=c&1;n=c&2;e=c&4;g=c&8;v=c&16;u=c&32;E=c&64;c&=128;t?(H=new THREE.Face4,H.a=I[p++],H.b=I[p++],H.c=I[p++],H.d=I[p++],t=4):(H=new THREE.Face3,H.a=I[p++],H.b=I[p++],H.c=I[p++],t=3);if(n)n=I[p++],H.materials=f.materials[n];n=f.faces.length;if(e)for(e=0;e<R;e++)B=b.uvs[e],w=I[p++],A=B[w*2],w=B[w*2+1],f.faceUvs[e][n]=new THREE.UV(A,w);if(g)for(e=0;e<R;e++){B=b.uvs[e];K=[];for(g=0;g<t;g++)w=I[p++],A=B[w*2],w=B[w*2+1],K[g]=
|
|
|
|
|
new THREE.UV(A,w);f.faceVertexUvs[e][n]=K}if(v)v=I[p++]*3,g=new THREE.Vector3,g.x=G[v++],g.y=G[v++],g.z=G[v],H.normal=g;if(u)for(e=0;e<t;e++)v=I[p++]*3,g=new THREE.Vector3,g.x=G[v++],g.y=G[v++],g.z=G[v],H.vertexNormals.push(g);if(E)u=I[p++],u=new THREE.Color(C[u]),H.color=u;if(c)for(e=0;e<t;e++)u=I[p++],u=new THREE.Color(C[u]),H.vertexColors.push(u);f.faces.push(H)}}})(g);(function(){var c,e,g,n;if(b.skinWeights){c=0;for(e=b.skinWeights.length;c<e;c+=2)g=b.skinWeights[c],n=b.skinWeights[c+1],f.skinWeights.push(new THREE.Vector4(g,
|
|
|
|
|
n,0,0))}if(b.skinIndices){c=0;for(e=b.skinIndices.length;c<e;c+=2)g=b.skinIndices[c],n=b.skinIndices[c+1],f.skinIndices.push(new THREE.Vector4(g,n,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var e,g,n,p,o,t,u,v,w;e=0;for(g=b.morphTargets.length;e<g;e++){f.morphTargets[e]={};f.morphTargets[e].name=b.morphTargets[e].name;f.morphTargets[e].vertices=[];v=f.morphTargets[e].vertices;w=b.morphTargets[e].vertices;n=0;for(p=w.length;n<p;n+=3)o=w[n]*c,t=w[n+1]*
|
|
|
|
|
c,u=w[n+2]*c,v.push(new THREE.Vertex(new THREE.Vector3(o,t,u)))}}if(b.morphColors!==void 0){e=0;for(g=b.morphColors.length;e<g;e++){f.morphColors[e]={};f.morphColors[e].name=b.morphColors[e].name;f.morphColors[e].colors=[];p=f.morphColors[e].colors;o=b.morphColors[e].colors;c=0;for(n=o.length;c<n;c+=3)t=new THREE.Color(16755200),t.setRGB(o[c],o[c+1],o[c+2]),p.push(t)}}})(g);(function(){if(b.edges!==void 0){var c,e,g;for(c=0;c<b.edges.length;c+=2)e=b.edges[c],g=b.edges[c+1],f.edges.push(new THREE.Edge(f.vertices[e],
|
|
|
|
|
f.vertices[g],e,g))}})();f.computeCentroids();f.computeFaceNormals();c(f)};THREE.BinaryLoader=function(b){THREE.Loader.call(this,b)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
|
|
|
|
|
THREE.BinaryLoader.prototype={load:function(b){var c=b.model,e=b.callback,f=b.texture_path?b.texture_path:THREE.Loader.prototype.extractUrlbase(c),g=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(c),b=(new Date).getTime(),c=new Worker(c),j=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(b){THREE.BinaryLoader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,e,g,f,j)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};
|
|
|
|
|
c.postMessage(b)},loadAjaxBuffers:function(b,c,e,f,g,j){var k=new XMLHttpRequest,m=f+"/"+b,n=0;k.onreadystatechange=function(){k.readyState==4?k.status==200||k.status==0?THREE.BinaryLoader.prototype.createBinModel(k.responseText,e,g,c):alert("Couldn't load ["+m+"] ["+k.status+"]"):k.readyState==3?j&&(n==0&&(n=k.getResponseHeader("Content-Length")),j({total:n,loaded:k.responseText.length})):k.readyState==2&&(n=k.getResponseHeader("Content-Length"))};k.open("GET",m,!0);k.overrideMimeType("text/plain; charset=x-user-defined");
|
|
|
|
|
k.setRequestHeader("Content-Type","text/plain");k.send(null)},createBinModel:function(b,c,e,f){var g=function(c){function e(b,c){var f=o(b,c),g=o(b,c+1),h=o(b,c+2),j=o(b,c+3),k=(j<<1&255|h>>7)-127;f|=(h&127)<<16|g<<8;if(f==0&&k==-127)return 0;return(1-2*(j>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,k)}function g(b,c){var e=o(b,c),f=o(b,c+1),h=o(b,c+2);return(o(b,c+3)<<24)+(h<<16)+(f<<8)+e}function n(b,c){var e=o(b,c);return(o(b,c+1)<<8)+e}function p(b,c){var e=o(b,c);return e>127?e-256:e}function o(b,
|
|
|
|
|
c){return b.charCodeAt(c)&255}function t(c){var e,f,h;e=g(b,c);f=g(b,c+C);h=g(b,c+R);c=n(b,c+D);THREE.BinaryLoader.prototype.f3(B,e,f,h,c)}function u(c){var e,f,h,j,k,o;e=g(b,c);f=g(b,c+C);h=g(b,c+R);j=n(b,c+D);k=g(b,c+N);o=g(b,c+J);c=g(b,c+V);THREE.BinaryLoader.prototype.f3n(B,I,e,f,h,j,k,o,c)}function v(c){var e,f,j,k;e=g(b,c);f=g(b,c+h);j=g(b,c+X);k=g(b,c+O);c=n(b,c+aa);THREE.BinaryLoader.prototype.f4(B,e,f,j,k,c)}function w(c){var e,f,j,k,o,p,t,u;e=g(b,c);f=g(b,c+h);j=g(b,c+X);k=g(b,c+O);o=n(b,
|
|
|
|
|
c+aa);p=g(b,c+M);t=g(b,c+da);u=g(b,c+U);c=g(b,c+S);THREE.BinaryLoader.prototype.f4n(B,I,e,f,j,k,o,p,t,u,c)}function E(c){var e,f;e=g(b,c);f=g(b,c+ja);c=g(b,c+W);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],G[e*2],G[e*2+1],G[f*2],G[f*2+1],G[c*2],G[c*2+1])}function H(c){var e,f,h;e=g(b,c);f=g(b,c+ga);h=g(b,c+Y);c=g(b,c+ha);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],G[e*2],G[e*2+1],G[f*2],G[f*2+1],G[h*2],G[h*2+1],G[c*2],G[c*2+1])}var B=this,K=0,A,I=[],G=[],C,R,D,N,J,V,h,X,O,aa,M,da,U,
|
|
|
|
|
S,ja,W,ga,Y,ha,fa,Q,T,Z,ka,na;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,f,c);A={signature:b.substr(K,8),header_bytes:o(b,K+8),vertex_coordinate_bytes:o(b,K+9),normal_coordinate_bytes:o(b,K+10),uv_coordinate_bytes:o(b,K+11),vertex_index_bytes:o(b,K+12),normal_index_bytes:o(b,K+13),uv_index_bytes:o(b,K+14),material_index_bytes:o(b,K+15),nvertices:g(b,K+16),nnormals:g(b,K+16+4),nuvs:g(b,K+16+8),ntri_flat:g(b,K+16+12),ntri_smooth:g(b,K+16+16),ntri_flat_uv:g(b,K+16+20),ntri_smooth_uv:g(b,
|
|
|
|
|
K+16+24),nquad_flat:g(b,K+16+28),nquad_smooth:g(b,K+16+32),nquad_flat_uv:g(b,K+16+36),nquad_smooth_uv:g(b,K+16+40)};K+=A.header_bytes;C=A.vertex_index_bytes;R=A.vertex_index_bytes*2;D=A.vertex_index_bytes*3;N=A.vertex_index_bytes*3+A.material_index_bytes;J=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;V=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;h=A.vertex_index_bytes;X=A.vertex_index_bytes*2;O=A.vertex_index_bytes*3;aa=A.vertex_index_bytes*4;M=A.vertex_index_bytes*
|
|
|
|
|
4+A.material_index_bytes;da=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;U=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;S=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;ja=A.uv_index_bytes;W=A.uv_index_bytes*2;ga=A.uv_index_bytes;Y=A.uv_index_bytes*2;ha=A.uv_index_bytes*3;c=A.vertex_index_bytes*3+A.material_index_bytes;na=A.vertex_index_bytes*4+A.material_index_bytes;fa=A.ntri_flat*c;Q=A.ntri_smooth*(c+A.normal_index_bytes*3);T=A.ntri_flat_uv*
|
|
|
|
|
(c+A.uv_index_bytes*3);Z=A.ntri_smooth_uv*(c+A.normal_index_bytes*3+A.uv_index_bytes*3);ka=A.nquad_flat*na;c=A.nquad_smooth*(na+A.normal_index_bytes*4);na=A.nquad_flat_uv*(na+A.uv_index_bytes*4);K+=function(c){for(var f,g,h,j=A.vertex_coordinate_bytes*3,m=c+A.nvertices*j;c<m;c+=j)f=e(b,c),g=e(b,c+A.vertex_coordinate_bytes),h=e(b,c+A.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(B,f,g,h);return A.nvertices*j}(K);K+=function(c){for(var e,f,g,h=A.normal_coordinate_bytes*3,j=c+A.nnormals*
|
|
|
|
|
h;c<j;c+=h)e=p(b,c),f=p(b,c+A.normal_coordinate_bytes),g=p(b,c+A.normal_coordinate_bytes*2),I.push(e/127,f/127,g/127);return A.nnormals*h}(K);K+=function(c){for(var f,g,h=A.uv_coordinate_bytes*2,j=c+A.nuvs*h;c<j;c+=h)f=e(b,c),g=e(b,c+A.uv_coordinate_bytes),G.push(f,g);return A.nuvs*h}(K);fa=K+fa;Q=fa+Q;T=Q+T;Z=T+Z;ka=Z+ka;c=ka+c;na=c+na;(function(b){var c,e=A.vertex_index_bytes*3+A.material_index_bytes,f=e+A.uv_index_bytes*3,g=b+A.ntri_flat_uv*f;for(c=b;c<g;c+=f)t(c),E(c+e);return g-b})(Q);(function(b){var c,
|
|
|
|
|
e=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,f=e+A.uv_index_bytes*3,g=b+A.ntri_smooth_uv*f;for(c=b;c<g;c+=f)u(c),E(c+e);return g-b})(T);(function(b){var c,e=A.vertex_index_bytes*4+A.material_index_bytes,f=e+A.uv_index_bytes*4,g=b+A.nquad_flat_uv*f;for(c=b;c<g;c+=f)v(c),H(c+e);return g-b})(c);(function(b){var c,e=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*4,f=e+A.uv_index_bytes*4,g=b+A.nquad_smooth_uv*f;for(c=b;c<g;c+=f)w(c),H(c+e);return g-b})(na);
|
|
|
|
|
(function(b){var c,e=A.vertex_index_bytes*3+A.material_index_bytes,f=b+A.ntri_flat*e;for(c=b;c<f;c+=e)t(c);return f-b})(K);(function(b){var c,e=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*3,f=b+A.ntri_smooth*e;for(c=b;c<f;c+=e)u(c);return f-b})(fa);(function(b){var c,e=A.vertex_index_bytes*4+A.material_index_bytes,f=b+A.nquad_flat*e;for(c=b;c<f;c+=e)v(c);return f-b})(Z);(function(b){var c,e=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*4,f=b+A.nquad_smooth*
|
|
|
|
|
e;for(c=b;c<f;c+=e)w(c);return f-b})(ka);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(e))},v:function(b,c,e,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(c,e,f)))},f3:function(b,c,e,f,g){b.faces.push(new THREE.Face3(c,e,f,null,null,b.materials[g]))},f4:function(b,c,e,f,g,j){b.faces.push(new THREE.Face4(c,e,f,g,null,null,b.materials[j]))},f3n:function(b,c,e,f,g,j,k,m,n){var j=b.materials[j],p=c[m*3],o=c[m*3+1],m=c[m*3+2],
|
|
|
|
|
t=c[n*3],u=c[n*3+1],n=c[n*3+2];b.faces.push(new THREE.Face3(e,f,g,[new THREE.Vector3(c[k*3],c[k*3+1],c[k*3+2]),new THREE.Vector3(p,o,m),new THREE.Vector3(t,u,n)],null,j))},f4n:function(b,c,e,f,g,j,k,m,n,p,o){var k=b.materials[k],t=c[n*3],u=c[n*3+1],n=c[n*3+2],v=c[p*3],w=c[p*3+1],p=c[p*3+2],E=c[o*3],H=c[o*3+1],o=c[o*3+2];b.faces.push(new THREE.Face4(e,f,g,j,[new THREE.Vector3(c[m*3],c[m*3+1],c[m*3+2]),new THREE.Vector3(t,u,n),new THREE.Vector3(v,w,p),new THREE.Vector3(E,H,o)],null,k))},uv3:function(b,
|
|
|
|
|
c,e,f,g,j,k){var m=[];m.push(new THREE.UV(c,e));m.push(new THREE.UV(f,g));m.push(new THREE.UV(j,k));b.push(m)},uv4:function(b,c,e,f,g,j,k,m,n){var p=[];p.push(new THREE.UV(c,e));p.push(new THREE.UV(f,g));p.push(new THREE.UV(j,k));p.push(new THREE.UV(m,n));b.push(p)}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
|
|
|
|
|
THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var g=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,c){return c=="relativeToHTML"?b:g+"/"+b}function m(){for(v in J.objects)if(!M.objects[v])if(K=J.objects[v],K.geometry!==void 0){if(C=M.geometries[K.geometry]){N=[];for(S=0;S<K.materials.length;S++)N[S]=M.materials[K.materials[S]];A=K.position;r=K.rotation;q=K.quaternion;s=K.scale;q=0;N.length==0&&(N[0]=new THREE.MeshFaceMaterial);
|
|
|
|
|
N.length>1&&(N=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(C,N);object.name=v;object.position.set(A[0],A[1],A[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=K.visible;M.scene.addObject(object);M.objects[v]=object;if(K.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(object);M.scene.collisions.colliders.push(b)}if(K.castsShadow)b=new THREE.ShadowVolume(C),M.scene.addChild(b),
|
|
|
|
|
b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;K.trigger&&K.trigger.toLowerCase()!="none"&&(b={type:K.trigger,object:K},M.triggers[object.name]=b)}}else A=K.position,r=K.rotation,q=K.quaternion,s=K.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(A[0],A[1],A[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible=K.visible!==void 0?K.visible:!1,M.scene.addObject(object),
|
|
|
|
|
M.objects[v]=object,M.empties[v]=object,K.trigger&&K.trigger.toLowerCase()!="none"&&(b={type:K.trigger,object:K},M.triggers[object.name]=b)}function n(b){return function(c){M.geometries[b]=c;m();h-=1;e.onLoadComplete();o()}}function p(b){return function(c){M.geometries[b]=c}}function o(){e.callbackProgress({totalModels:O,totalTextures:aa,loadedModels:O-h,loadedTextures:aa-X},M);e.onLoadProgress();h==0&&X==0&&c(M)}var t,u,v,w,E,H,B,K,A,I,G,C,R,D,N,J,V,h,X,O,aa,M;J=b.data;b=new THREE.BinaryLoader;V=
|
|
|
|
|
new THREE.JSONLoader;X=h=0;M={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var da=!1;for(v in J.objects)if(K=J.objects[v],K.meshCollider){da=!0;break}if(da)M.scene.collisions=new THREE.CollisionSystem;if(J.transform){da=J.transform.position;I=J.transform.rotation;var U=J.transform.scale;da&&M.scene.position.set(da[0],da[1],da[2]);I&&M.scene.rotation.set(I[0],I[1],I[2]);U&&M.scene.scale.set(U[0],U[1],U[2]);(da||I||U)&&
|
|
|
|
|
M.scene.updateMatrix()}da=function(){X-=1;o();e.onLoadComplete()};for(E in J.cameras){I=J.cameras[E];if(I.type=="perspective")R=new THREE.Camera(I.fov,I.aspect,I.near,I.far);else if(I.type=="ortho")R=new THREE.Camera,R.projectionMatrix=THREE.Matrix4.makeOrtho(I.left,I.right,I.top,I.bottom,I.near,I.far);A=I.position;I=I.target;R.position.set(A[0],A[1],A[2]);R.target.position.set(I[0],I[1],I[2]);M.cameras[E]=R}for(w in J.lights){E=J.lights[w];R=E.color!==void 0?E.color:16777215;I=E.intensity!==void 0?
|
|
|
|
|
E.intensity:1;if(E.type=="directional")A=E.direction,light=new THREE.DirectionalLight(R,I),light.position.set(A[0],A[1],A[2]),light.position.normalize();else if(E.type=="point")A=E.position,light=new THREE.PointLight(R,I),light.position.set(A[0],A[1],A[2]);M.scene.addLight(light);M.lights[w]=light}for(H in J.fogs)w=J.fogs[H],w.type=="linear"?D=new THREE.Fog(0,w.near,w.far):w.type=="exp2"&&(D=new THREE.FogExp2(0,w.density)),I=w.color,D.color.setRGB(I[0],I[1],I[2]),M.fogs[H]=D;if(M.cameras&&J.defaults.camera)M.currentCamera=
|
|
|
|
|
M.cameras[J.defaults.camera];if(M.fogs&&J.defaults.fog)M.scene.fog=M.fogs[J.defaults.fog];I=J.defaults.bgcolor;M.bgColor=new THREE.Color;M.bgColor.setRGB(I[0],I[1],I[2]);M.bgColorAlpha=J.defaults.bgalpha;for(t in J.geometries)if(H=J.geometries[t],H.type=="bin_mesh"||H.type=="ascii_mesh")h+=1,e.onLoadStart();O=h;for(t in J.geometries)H=J.geometries[t],H.type=="cube"?(C=new THREE.Cube(H.width,H.height,H.depth,H.segmentsWidth,H.segmentsHeight,H.segmentsDepth,null,H.flipped,H.sides),M.geometries[t]=C):
|
|
|
|
|
H.type=="plane"?(C=new THREE.Plane(H.width,H.height,H.segmentsWidth,H.segmentsHeight),M.geometries[t]=C):H.type=="sphere"?(C=new THREE.Sphere(H.radius,H.segmentsWidth,H.segmentsHeight),M.geometries[t]=C):H.type=="cylinder"?(C=new THREE.Cylinder(H.numSegs,H.topRad,H.botRad,H.height,H.topOffset,H.botOffset),M.geometries[t]=C):H.type=="torus"?(C=new THREE.Torus(H.radius,H.tube,H.segmentsR,H.segmentsT),M.geometries[t]=C):H.type=="icosahedron"?(C=new THREE.Icosahedron(H.subdivisions),M.geometries[t]=C):
|
|
|
|
|
H.type=="bin_mesh"?b.load({model:f(H.url,J.urlBaseType),callback:n(t)}):H.type=="ascii_mesh"?V.load({model:f(H.url,J.urlBaseType),callback:n(t)}):H.type=="embedded_mesh"&&(H=J.embeds[H.id])&&V.createModel(H,p(t),"");for(B in J.textures)if(t=J.textures[B],t.url instanceof Array){X+=t.url.length;for(b=0;b<t.url.length;b++)e.onLoadStart()}else X+=1,e.onLoadStart();aa=X;for(B in J.textures){t=J.textures[B];if(t.mapping!=void 0&&THREE[t.mapping]!=void 0)t.mapping=new THREE[t.mapping];if(t.url instanceof
|
|
|
|
|
Array){for(var b=[],S=0;S<t.url.length;S++)b[S]=f(t.url[S],J.urlBaseType);b=THREE.ImageUtils.loadTextureCube(b,t.mapping,da)}else{b=THREE.ImageUtils.loadTexture(f(t.url,J.urlBaseType),t.mapping,da);if(THREE[t.minFilter]!=void 0)b.minFilter=THREE[t.minFilter];if(THREE[t.magFilter]!=void 0)b.magFilter=THREE[t.magFilter]}M.textures[B]=b}for(u in J.materials){B=J.materials[u];for(G in B.parameters)if(G=="envMap"||G=="map"||G=="lightMap")B.parameters[G]=M.textures[B.parameters[G]];else if(G=="shading")B.parameters[G]=
|
|
|
|
|
B.parameters[G]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(G=="blending")B.parameters[G]=THREE[B.parameters[G]]?THREE[B.parameters[G]]:THREE.NormalBlending;else if(G=="combine")B.parameters[G]=B.parameters[G]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(G=="vertexColors")if(B.parameters[G]=="face")B.parameters[G]=THREE.FaceColors;else if(B.parameters[G])B.parameters[G]=THREE.VertexColors;if(B.parameters.opacity!==void 0&&B.parameters.opacity<1)B.parameters.transparent=
|
|
|
|
|
!0;B=new THREE[B.type](B.parameters);M.materials[u]=B}m();e.callbackSync(M)}}};
|
|
|
|
|
THREE.MarchingCubes=function(b,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.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,f){return b+(c-b)*f};this.VIntX=function(b,c,f,h,j,k,m,o,n,p){j=(j-n)/(p-n);n=this.normal_cache;c[h]=k+j*this.delta;c[h+1]=m;c[h+2]=o;f[h]=this.lerp(n[b],n[b+3],j);f[h+1]=this.lerp(n[b+1],n[b+4],j);f[h+2]=this.lerp(n[b+2],n[b+5],j)};this.VIntY=function(b,c,f,h,j,k,m,o,n,p){j=(j-n)/(p-n);n=this.normal_cache;c[h]=k;c[h+1]=m+j*this.delta;c[h+
|
|
|
|
|
2]=o;c=b+this.yd*3;f[h]=this.lerp(n[b],n[c],j);f[h+1]=this.lerp(n[b+1],n[c+1],j);f[h+2]=this.lerp(n[b+2],n[c+2],j)};this.VIntZ=function(b,c,f,h,j,k,m,o,n,p){j=(j-n)/(p-n);n=this.normal_cache;c[h]=k;c[h+1]=m;c[h+2]=o+j*this.delta;c=b+this.zd*3;f[h]=this.lerp(n[b],n[c],j);f[h+1]=this.lerp(n[b+1],n[c+1],j);f[h+2]=this.lerp(n[b+2],n[c+2],j)};this.compNorm=function(b){var c=b*3;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,f,h,j,k){var m=h+1,o=h+this.yd,n=h+this.zd,p=m+this.yd,t=m+this.zd,u=h+this.yd+this.zd,v=m+this.yd+this.zd,C=0,E=this.field[h],y=this.field[m],D=this.field[o],x=this.field[p],I=this.field[n],A=this.field[t],z=this.field[u],S=this.field[v];E<j&&(C|=1);y<j&&(C|=2);D<j&&(C|=8);x<j&&(C|=4);I<j&&(C|=16);A<j&&(C|=32);z<j&&(C|=128);S<j&&(C|=64);var G=THREE.edgeTable[C];if(G==0)return 0;var M=this.delta,
|
|
|
|
|
F=b+M,N=c+M,M=f+M;G&1&&(this.compNorm(h),this.compNorm(m),this.VIntX(h*3,this.vlist,this.nlist,0,j,b,c,f,E,y));G&2&&(this.compNorm(m),this.compNorm(p),this.VIntY(m*3,this.vlist,this.nlist,3,j,F,c,f,y,x));G&4&&(this.compNorm(o),this.compNorm(p),this.VIntX(o*3,this.vlist,this.nlist,6,j,b,N,f,D,x));G&8&&(this.compNorm(h),this.compNorm(o),this.VIntY(h*3,this.vlist,this.nlist,9,j,b,c,f,E,D));G&16&&(this.compNorm(n),this.compNorm(t),this.VIntX(n*3,this.vlist,this.nlist,12,j,b,c,M,I,A));G&32&&(this.compNorm(t),
|
|
|
|
|
this.compNorm(v),this.VIntY(t*3,this.vlist,this.nlist,15,j,F,c,M,A,S));G&64&&(this.compNorm(u),this.compNorm(v),this.VIntX(u*3,this.vlist,this.nlist,18,j,b,N,M,z,S));G&128&&(this.compNorm(n),this.compNorm(u),this.VIntY(n*3,this.vlist,this.nlist,21,j,b,c,M,I,z));G&256&&(this.compNorm(h),this.compNorm(n),this.VIntZ(h*3,this.vlist,this.nlist,24,j,b,c,f,E,I));G&512&&(this.compNorm(m),this.compNorm(t),this.VIntZ(m*3,this.vlist,this.nlist,27,j,F,c,f,y,A));G&1024&&(this.compNorm(p),this.compNorm(v),this.VIntZ(p*
|
|
|
|
|
3,this.vlist,this.nlist,30,j,F,N,f,x,S));G&2048&&(this.compNorm(o),this.compNorm(u),this.VIntZ(o*3,this.vlist,this.nlist,33,j,b,N,f,D,z));C<<=4;for(j=h=0;THREE.triTable[C+j]!=-1;)b=C+j,c=b+1,f=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[f],k),j+=3,h++;return h};this.posnormtriv=function(b,c,f,h,j,k){var m=this.count*3;this.positionArray[m]=b[f];this.positionArray[m+1]=b[f+1];this.positionArray[m+2]=b[f+2];this.positionArray[m+3]=b[h];this.positionArray[m+
|
|
|
|
|
4]=b[h+1];this.positionArray[m+5]=b[h+2];this.positionArray[m+6]=b[j];this.positionArray[m+7]=b[j+1];this.positionArray[m+8]=b[j+2];this.normalArray[m]=c[f];this.normalArray[m+1]=c[f+1];this.normalArray[m+2]=c[f+2];this.normalArray[m+3]=c[h];this.normalArray[m+4]=c[h+1];this.normalArray[m+5]=c[h+2];this.normalArray[m+6]=c[j];this.normalArray[m+7]=c[j+1];this.normalArray[m+8]=c[j+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;
|
|
|
|
|
this.hasNormal=this.hasPos=!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,f,h,j){var k=this.size*Math.sqrt(h/j),m=f*this.size,o=c*this.size,n=b*this.size,p=Math.floor(m-k);p<1&&(p=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var t=Math.floor(o-k);t<1&&(t=1);o=Math.floor(o+k);o>this.size-1&&(o=this.size-1);var u=Math.floor(n-k);u<1&&(u=1);k=Math.floor(n+k);k>this.size-1&&(k=this.size-
|
|
|
|
|
1);for(var v,C,E,y,D,x;p<m;p++){n=this.size2*p;C=p/this.size-f;D=C*C;for(C=t;C<o;C++){E=n+this.size*C;v=C/this.size-c;x=v*v;for(v=u;v<k;v++)y=v/this.size-b,y=h/(1.0E-6+y*y+x+D)-j,y>0&&(this.field[E+v]+=y)}}};this.addPlaneX=function(b,c){var f,h,j,k,m,o=this.size,n=this.yd,p=this.zd,t=this.field,u=o*Math.sqrt(b/c);u>o&&(u=o);for(f=0;f<u;f++)if(h=f/o,h*=h,k=b/(1.0E-4+h)-c,k>0)for(h=0;h<o;h++){m=f+h*n;for(j=0;j<o;j++)t[p*j+m]+=k}};this.addPlaneY=function(b,c){var f,h,j,k,m,o,n=this.size,p=this.yd,t=
|
|
|
|
|
this.zd,u=this.field,v=n*Math.sqrt(b/c);v>n&&(v=n);for(h=0;h<v;h++)if(f=h/n,f*=f,k=b/(1.0E-4+f)-c,k>0){m=h*p;for(f=0;f<n;f++){o=m+f;for(j=0;j<n;j++)u[t*j+o]+=k}}};this.addPlaneZ=function(b,c){var f,h,j,k,m,o;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(j=0;j<dist;j++)if(f=j/size,f*=f,k=b/(1.0E-4+f)-c,k>0){m=zd*j;for(h=0;h<size;h++){o=m+h*yd;for(f=0;f<size;f++)field[o+f]+=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 c,f,h,j,k,m,o,n,p,t=this.size-2;for(j=1;j<t;j++){p=this.size2*j;o=(j-this.halfsize)/this.halfsize;for(h=1;h<t;h++){n=p+this.size*h;m=(h-this.halfsize)/this.halfsize;for(f=1;f<t;f++)k=(f-this.halfsize)/this.halfsize,c=n+f,this.polygonize(k,m,o,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,f=[];this.render(function(h){var j,k,m,o,n,p,t,u;for(j=0;j<h.count;j++)t=j*3,n=t+1,u=t+2,k=h.positionArray[t],
|
|
|
|
|
m=h.positionArray[n],o=h.positionArray[u],p=new THREE.Vector3(k,m,o),k=h.normalArray[t],m=h.normalArray[n],o=h.normalArray[u],t=new THREE.Vector3(k,m,o),t.normalize(),n=new THREE.Vertex(p),c.vertices.push(n),f.push(t);nfaces=h.count/3;for(j=0;j<nfaces;j++)t=(b+j)*3,n=t+1,u=t+2,p=f[t],k=f[n],m=f[u],t=new THREE.Face3(t,n,u,[p,k,m]),c.faces.push(t);b+=nfaces;h.count=0});return c};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
|
|
|
|
|
0;this.hasNormal=this.hasPos=!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,j,k,m,n,p,o,t){k=(k-o)/(t-o);o=this.normal_cache;c[j]=m+k*this.delta;c[j+1]=n;c[j+2]=p;g[j]=this.lerp(o[b],o[b+3],k);g[j+1]=this.lerp(o[b+1],o[b+4],k);g[j+2]=this.lerp(o[b+2],o[b+5],k)};this.VIntY=function(b,c,g,j,k,m,n,p,o,t){k=(k-o)/(t-o);o=this.normal_cache;c[j]=m;c[j+1]=n+k*this.delta;c[j+
|
|
|
|
|
2]=p;c=b+this.yd*3;g[j]=this.lerp(o[b],o[c],k);g[j+1]=this.lerp(o[b+1],o[c+1],k);g[j+2]=this.lerp(o[b+2],o[c+2],k)};this.VIntZ=function(b,c,g,j,k,m,n,p,o,t){k=(k-o)/(t-o);o=this.normal_cache;c[j]=m;c[j+1]=n;c[j+2]=p+k*this.delta;c=b+this.zd*3;g[j]=this.lerp(o[b],o[c],k);g[j+1]=this.lerp(o[b+1],o[c+1],k);g[j+2]=this.lerp(o[b+2],o[c+2],k)};this.compNorm=function(b){var c=b*3;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,j,k,m){var n=j+1,p=j+this.yd,o=j+this.zd,t=n+this.yd,u=n+this.zd,v=j+this.yd+this.zd,w=n+this.yd+this.zd,E=0,H=this.field[j],B=this.field[n],K=this.field[p],A=this.field[t],I=this.field[o],G=this.field[u],C=this.field[v],R=this.field[w];H<k&&(E|=1);B<k&&(E|=2);K<k&&(E|=8);A<k&&(E|=4);I<k&&(E|=16);G<k&&(E|=32);C<k&&(E|=128);R<k&&(E|=64);var D=THREE.edgeTable[E];if(D==0)return 0;var N=this.delta,
|
|
|
|
|
J=b+N,V=c+N,N=g+N;D&1&&(this.compNorm(j),this.compNorm(n),this.VIntX(j*3,this.vlist,this.nlist,0,k,b,c,g,H,B));D&2&&(this.compNorm(n),this.compNorm(t),this.VIntY(n*3,this.vlist,this.nlist,3,k,J,c,g,B,A));D&4&&(this.compNorm(p),this.compNorm(t),this.VIntX(p*3,this.vlist,this.nlist,6,k,b,V,g,K,A));D&8&&(this.compNorm(j),this.compNorm(p),this.VIntY(j*3,this.vlist,this.nlist,9,k,b,c,g,H,K));D&16&&(this.compNorm(o),this.compNorm(u),this.VIntX(o*3,this.vlist,this.nlist,12,k,b,c,N,I,G));D&32&&(this.compNorm(u),
|
|
|
|
|
this.compNorm(w),this.VIntY(u*3,this.vlist,this.nlist,15,k,J,c,N,G,R));D&64&&(this.compNorm(v),this.compNorm(w),this.VIntX(v*3,this.vlist,this.nlist,18,k,b,V,N,C,R));D&128&&(this.compNorm(o),this.compNorm(v),this.VIntY(o*3,this.vlist,this.nlist,21,k,b,c,N,I,C));D&256&&(this.compNorm(j),this.compNorm(o),this.VIntZ(j*3,this.vlist,this.nlist,24,k,b,c,g,H,I));D&512&&(this.compNorm(n),this.compNorm(u),this.VIntZ(n*3,this.vlist,this.nlist,27,k,J,c,g,B,G));D&1024&&(this.compNorm(t),this.compNorm(w),this.VIntZ(t*
|
|
|
|
|
3,this.vlist,this.nlist,30,k,J,V,g,A,R));D&2048&&(this.compNorm(p),this.compNorm(v),this.VIntZ(p*3,this.vlist,this.nlist,33,k,b,V,g,K,C));E<<=4;for(k=j=0;THREE.triTable[E+k]!=-1;)b=E+k,c=b+1,g=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[g],m),k+=3,j++;return j};this.posnormtriv=function(b,c,g,j,k,m){var n=this.count*3;this.positionArray[n]=b[g];this.positionArray[n+1]=b[g+1];this.positionArray[n+2]=b[g+2];this.positionArray[n+3]=b[j];this.positionArray[n+
|
|
|
|
|
4]=b[j+1];this.positionArray[n+5]=b[j+2];this.positionArray[n+6]=b[k];this.positionArray[n+7]=b[k+1];this.positionArray[n+8]=b[k+2];this.normalArray[n]=c[g];this.normalArray[n+1]=c[g+1];this.normalArray[n+2]=c[g+2];this.normalArray[n+3]=c[j];this.normalArray[n+4]=c[j+1];this.normalArray[n+5]=c[j+2];this.normalArray[n+6]=c[k];this.normalArray[n+7]=c[k+1];this.normalArray[n+8]=c[k+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&m(this)};this.begin=function(){this.count=0;
|
|
|
|
|
this.hasNormal=this.hasPos=!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,j,k){var m=this.size*Math.sqrt(j/k),n=g*this.size,p=c*this.size,o=b*this.size,t=Math.floor(n-m);t<1&&(t=1);n=Math.floor(n+m);n>this.size-1&&(n=this.size-1);var u=Math.floor(p-m);u<1&&(u=1);p=Math.floor(p+m);p>this.size-1&&(p=this.size-1);var v=Math.floor(o-m);v<1&&(v=1);m=Math.floor(o+m);m>this.size-1&&(m=this.size-
|
|
|
|
|
1);for(var w,E,H,B,K,A;t<n;t++){o=this.size2*t;E=t/this.size-g;K=E*E;for(E=u;E<p;E++){H=o+this.size*E;w=E/this.size-c;A=w*w;for(w=v;w<m;w++)B=w/this.size-b,B=j/(1.0E-6+B*B+A+K)-k,B>0&&(this.field[H+w]+=B)}}};this.addPlaneX=function(b,c){var g,j,k,m,n,p=this.size,o=this.yd,t=this.zd,u=this.field,v=p*Math.sqrt(b/c);v>p&&(v=p);for(g=0;g<v;g++)if(j=g/p,j*=j,m=b/(1.0E-4+j)-c,m>0)for(j=0;j<p;j++){n=g+j*o;for(k=0;k<p;k++)u[t*k+n]+=m}};this.addPlaneY=function(b,c){var g,j,k,m,n,p,o=this.size,t=this.yd,u=
|
|
|
|
|
this.zd,v=this.field,w=o*Math.sqrt(b/c);w>o&&(w=o);for(j=0;j<w;j++)if(g=j/o,g*=g,m=b/(1.0E-4+g)-c,m>0){n=j*t;for(g=0;g<o;g++){p=n+g;for(k=0;k<o;k++)v[u*k+p]+=m}}};this.addPlaneZ=function(b,c){var g,j,k,m,n,p;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(k=0;k<dist;k++)if(g=k/size,g*=g,m=b/(1.0E-4+g)-c,m>0){n=zd*k;for(j=0;j<size;j++){p=n+j*yd;for(g=0;g<size;g++)field[p+g]+=m}}};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,j,k,m,n,p,o,t,u=this.size-2;for(k=1;k<u;k++){t=this.size2*k;p=(k-this.halfsize)/this.halfsize;for(j=1;j<u;j++){o=t+this.size*j;n=(j-this.halfsize)/this.halfsize;for(g=1;g<u;g++)m=(g-this.halfsize)/this.halfsize,c=o+g,this.polygonize(m,n,p,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,g=[];this.render(function(j){var k,m,n,p,o,t,u,v;for(k=0;k<j.count;k++)u=k*3,o=u+1,v=u+2,m=j.positionArray[u],
|
|
|
|
|
n=j.positionArray[o],p=j.positionArray[v],t=new THREE.Vector3(m,n,p),m=j.normalArray[u],n=j.normalArray[o],p=j.normalArray[v],u=new THREE.Vector3(m,n,p),u.normalize(),o=new THREE.Vertex(t),c.vertices.push(o),g.push(u);nfaces=j.count/3;for(k=0;k<nfaces;k++)u=(b+k)*3,o=u+1,v=u+2,t=g[u],m=g[o],n=g[v],u=new THREE.Face3(u,o,v,[t,m,n]),c.faces.push(u);b+=nfaces;j.count=0});return c};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
|
|
|
|
|
THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
|
|
|
|
|
1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
|
|
|
|
|
419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
|
|
|
|
@@ -522,26 +536,26 @@ THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
|
|
|
|
|
4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
|
|
|
|
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
|
|
|
|
|
2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);
|
|
|
|
|
THREE.Trident=function(b){function c(c){return new THREE.Mesh(new THREE.Cylinder(30,0.1,b.length/20,b.length/5),new THREE.MeshBasicMaterial({color:c}))}function d(b,c){var d=new THREE.Geometry;d.vertices=[new THREE.Vertex,new THREE.Vertex(b)];return new THREE.Line(d,new THREE.LineBasicMaterial({color:c}))}THREE.Object3D.call(this);var e=Math.PI/2,f,b=b||THREE.Trident.defaultParams;if(b!==THREE.Trident.defaultParams)for(f in THREE.Trident.defaultParams)b.hasOwnProperty(f)||(b[f]=THREE.Trident.defaultParams[f]);
|
|
|
|
|
this.scale=new THREE.Vector3(b.scale,b.scale,b.scale);this.addChild(d(new THREE.Vector3(b.length,0,0),b.xAxisColor));this.addChild(d(new THREE.Vector3(0,b.length,0),b.yAxisColor));this.addChild(d(new THREE.Vector3(0,0,b.length),b.zAxisColor));if(b.showArrows)f=c(b.xAxisColor),f.rotation.y=-e,f.position.x=b.length,this.addChild(f),f=c(b.yAxisColor),f.rotation.x=e,f.position.y=b.length,this.addChild(f),f=c(b.zAxisColor),f.rotation.y=Math.PI,f.position.z=b.length,this.addChild(f)};
|
|
|
|
|
THREE.Trident=function(b){function c(c){return new THREE.Mesh(new THREE.Cylinder(30,0.1,b.length/20,b.length/5),new THREE.MeshBasicMaterial({color:c}))}function e(b,c){var e=new THREE.Geometry;e.vertices=[new THREE.Vertex,new THREE.Vertex(b)];return new THREE.Line(e,new THREE.LineBasicMaterial({color:c}))}THREE.Object3D.call(this);var f=Math.PI/2,g,b=b||THREE.Trident.defaultParams;if(b!==THREE.Trident.defaultParams)for(g in THREE.Trident.defaultParams)b.hasOwnProperty(g)||(b[g]=THREE.Trident.defaultParams[g]);
|
|
|
|
|
this.scale=new THREE.Vector3(b.scale,b.scale,b.scale);this.addChild(e(new THREE.Vector3(b.length,0,0),b.xAxisColor));this.addChild(e(new THREE.Vector3(0,b.length,0),b.yAxisColor));this.addChild(e(new THREE.Vector3(0,0,b.length),b.zAxisColor));if(b.showArrows)g=c(b.xAxisColor),g.rotation.y=-f,g.position.x=b.length,this.addChild(g),g=c(b.yAxisColor),g.rotation.x=f,g.position.y=b.length,this.addChild(g),g=c(b.zAxisColor),g.rotation.y=Math.PI,g.position.z=b.length,this.addChild(g)};
|
|
|
|
|
THREE.Trident.prototype=new THREE.Object3D;THREE.Trident.prototype.constructor=THREE.Trident;THREE.Trident.defaultParams={xAxisColor:16711680,yAxisColor:65280,zAxisColor:255,showArrows:!0,length:100,scale:1};THREE.PlaneCollider=function(b,c){this.point=b;this.normal=c};THREE.SphereCollider=function(b,c){this.center=b;this.radius=c;this.radiusSq=c*c};THREE.BoxCollider=function(b,c){this.min=b;this.max=c;this.dynamic=!0;this.normal=new THREE.Vector3};
|
|
|
|
|
THREE.MeshCollider=function(b,c){this.mesh=b;this.box=c;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(b){this.colliders=this.colliders.concat(b.colliders);this.hits=this.hits.concat(b.hits)};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,d,e,f,h=0;c=0;for(d=this.colliders.length;c<d;c++)if(f=this.colliders[c],e=this.rayCast(b,f),e<Number.MAX_VALUE)f.distance=e,e>h?this.hits.push(f):this.hits.unshift(f),h=e;return this.hits};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var d=0;c[d]instanceof THREE.MeshCollider;){var e=this.rayMesh(b,c[d]);if(e.dist<Number.MAX_VALUE){c[d].distance=e.dist;c[d].faceIndex=e.faceIndex;break}d++}if(d>c.length)return null;return c[d]};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,e,f,g,j=0;c=0;for(e=this.colliders.length;c<e;c++)if(g=this.colliders[c],f=this.rayCast(b,g),f<Number.MAX_VALUE)g.distance=f,f>j?this.hits.push(g):this.hits.unshift(g),j=f;return this.hits};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.dist<Number.MAX_VALUE){c[e].distance=f.dist;c[e].faceIndex=f.faceIndex;break}e++}if(e>c.length)return null;return c[e]};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var d=this.makeRayLocal(b,c.mesh),e=Number.MAX_VALUE,f,h=0;h<c.numFaces;h++){var j=c.mesh.geometry.faces[h],k=c.mesh.geometry.vertices[j.a].position,m=c.mesh.geometry.vertices[j.b].position,o=c.mesh.geometry.vertices[j.c].position,n=j instanceof THREE.Face4?c.mesh.geometry.vertices[j.d].position:null;j instanceof THREE.Face3?(j=this.rayTriangle(d,k,m,o,e,this.collisionNormal),j<e&&(e=j,f=h,c.normal.copy(this.collisionNormal),c.normal.normalize())):
|
|
|
|
|
j instanceof THREE.Face4&&(j=this.rayTriangle(d,k,m,n,e,this.collisionNormal),j<e&&(e=j,f=h,c.normal.copy(this.collisionNormal),c.normal.normalize()),j=this.rayTriangle(d,m,o,n,e,this.collisionNormal),j<e&&(e=j,f=h,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:e,faceIndex:f}};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayTriangle=function(b,c,d,e,f,h){var j=THREE.CollisionSystem.__v1,k=THREE.CollisionSystem.__v2;h.set(0,0,0);j.sub(d,c);k.sub(e,d);h.cross(j,k);k=h.dot(b.direction);if(!(k<0))return Number.MAX_VALUE;j=h.dot(c)-h.dot(b.origin);if(!(j<=0))return Number.MAX_VALUE;if(!(j>=k*f))return Number.MAX_VALUE;j/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(j);k.addSelf(b.origin);Math.abs(h.x)>Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(b=k.y-c.y,h=d.y-c.y,
|
|
|
|
|
f=e.y-c.y,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,h=d.x-c.x,f=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(b=k.x-c.x,h=d.x-c.x,f=e.x-c.x,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,h=d.x-c.x,f=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y);c=h*e-d*f;if(c==0)return Number.MAX_VALUE;c=1/c;e=(b*e-k*f)*c;if(!(e>=0))return Number.MAX_VALUE;c*=h*k-d*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return j};
|
|
|
|
|
THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var d=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,d);var e=THREE.CollisionSystem.__r;e.origin.copy(b.origin);e.direction.copy(b.direction);d.multiplyVector3(e.origin);d.rotateAxis(e.direction);e.direction.normalize();return e};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayBox=function(b,c){var d;c.dynamic&&c.mesh&&c.mesh.matrixWorld?d=this.makeRayLocal(b,c.mesh):(d=THREE.CollisionSystem.__r,d.origin.copy(b.origin),d.direction.copy(b.direction));var e=0,f=0,h=0,j=0,k=0,m=0,o=!0;d.origin.x<c.min.x?(e=c.min.x-d.origin.x,e/=d.direction.x,o=!1,j=-1):d.origin.x>c.max.x&&(e=c.max.x-d.origin.x,e/=d.direction.x,o=!1,j=1);d.origin.y<c.min.y?(f=c.min.y-d.origin.y,f/=d.direction.y,o=!1,k=-1):d.origin.y>c.max.y&&(f=c.max.y-d.origin.y,f/=d.direction.y,
|
|
|
|
|
o=!1,k=1);d.origin.z<c.min.z?(h=c.min.z-d.origin.z,h/=d.direction.z,o=!1,m=-1):d.origin.z>c.max.z&&(h=c.max.z-d.origin.z,h/=d.direction.z,o=!1,m=1);if(o)return-1;o=0;f>e&&(o=1,e=f);h>e&&(o=2,e=h);switch(o){case 0:k=d.origin.y+d.direction.y*e;if(k<c.min.y||k>c.max.y)return Number.MAX_VALUE;d=d.origin.z+d.direction.z*e;if(d<c.min.z||d>c.max.z)return Number.MAX_VALUE;c.normal.set(j,0,0);break;case 1:j=d.origin.x+d.direction.x*e;if(j<c.min.x||j>c.max.x)return Number.MAX_VALUE;d=d.origin.z+d.direction.z*
|
|
|
|
|
e;if(d<c.min.z||d>c.max.z)return Number.MAX_VALUE;c.normal.set(0,k,0);break;case 2:j=d.origin.x+d.direction.x*e;if(j<c.min.x||j>c.max.x)return Number.MAX_VALUE;k=d.origin.y+d.direction.y*e;if(k<c.min.y||k>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,m)}return e};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var d=b.direction.dot(c.normal),e=c.point.dot(c.normal);if(d<0)d=(e-b.origin.dot(c.normal))/d;else return Number.MAX_VALUE;return d>0?d:Number.MAX_VALUE};
|
|
|
|
|
THREE.CollisionSystem.prototype.raySphere=function(b,c){var d=c.center.clone().subSelf(b.origin);if(d.lengthSq<c.radiusSq)return-1;var e=d.dot(b.direction.clone());if(e<=0)return Number.MAX_VALUE;d=c.radiusSq-(d.lengthSq()-e*e);if(d>=0)return Math.abs(e)-Math.sqrt(d);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
|
|
|
|
|
THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var c=b.geometry.boundingBox,d=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),d=new THREE.BoxCollider(d,c);d.mesh=b;return d};THREE.CollisionUtils.MeshAABB=function(b){var c=THREE.CollisionUtils.MeshOBB(b);c.min.addSelf(b.position);c.max.addSelf(b.position);c.dynamic=!1;return c};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,j=0;j<c.numFaces;j++){var k=c.mesh.geometry.faces[j],m=c.mesh.geometry.vertices[k.a].position,n=c.mesh.geometry.vertices[k.b].position,p=c.mesh.geometry.vertices[k.c].position,o=k instanceof THREE.Face4?c.mesh.geometry.vertices[k.d].position:null;k instanceof THREE.Face3?(k=this.rayTriangle(e,m,n,p,f,this.collisionNormal),k<f&&(f=k,g=j,c.normal.copy(this.collisionNormal),c.normal.normalize())):
|
|
|
|
|
k instanceof THREE.Face4&&(k=this.rayTriangle(e,m,n,o,f,this.collisionNormal),k<f&&(f=k,g=j,c.normal.copy(this.collisionNormal),c.normal.normalize()),k=this.rayTriangle(e,n,p,o,f,this.collisionNormal),k<f&&(f=k,g=j,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:f,faceIndex:g}};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayTriangle=function(b,c,e,f,g,j){var k=THREE.CollisionSystem.__v1,m=THREE.CollisionSystem.__v2;j.set(0,0,0);k.sub(e,c);m.sub(f,e);j.cross(k,m);m=j.dot(b.direction);if(!(m<0))return Number.MAX_VALUE;k=j.dot(c)-j.dot(b.origin);if(!(k<=0))return Number.MAX_VALUE;if(!(k>=m*g))return Number.MAX_VALUE;k/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(k);m.addSelf(b.origin);Math.abs(j.x)>Math.abs(j.y)?Math.abs(j.x)>Math.abs(j.z)?(b=m.y-c.y,j=e.y-c.y,
|
|
|
|
|
g=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,j=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(j.y)>Math.abs(j.z)?(b=m.x-c.x,j=e.x-c.x,g=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,j=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=j*f-e*g;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*g)*c;if(!(f>=0))return Number.MAX_VALUE;c*=j*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return k};
|
|
|
|
|
THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var e=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,e);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);e.multiplyVector3(f.origin);e.rotateAxis(f.direction);f.direction.normalize();return f};
|
|
|
|
|
THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,g=0,j=0,k=0,m=0,n=0,p=!0;e.origin.x<c.min.x?(f=c.min.x-e.origin.x,f/=e.direction.x,p=!1,k=-1):e.origin.x>c.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,p=!1,k=1);e.origin.y<c.min.y?(g=c.min.y-e.origin.y,g/=e.direction.y,p=!1,m=-1):e.origin.y>c.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y,
|
|
|
|
|
p=!1,m=1);e.origin.z<c.min.z?(j=c.min.z-e.origin.z,j/=e.direction.z,p=!1,n=-1):e.origin.z>c.max.z&&(j=c.max.z-e.origin.z,j/=e.direction.z,p=!1,n=1);if(p)return-1;p=0;g>f&&(p=1,f=g);j>f&&(p=2,f=j);switch(p){case 0:m=e.origin.y+e.direction.y*f;if(m<c.min.y||m>c.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(e<c.min.z||e>c.max.z)return Number.MAX_VALUE;c.normal.set(k,0,0);break;case 1:k=e.origin.x+e.direction.x*f;if(k<c.min.x||k>c.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*
|
|
|
|
|
f;if(e<c.min.z||e>c.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:k=e.origin.x+e.direction.x*f;if(k<c.min.x||k>c.max.x)return Number.MAX_VALUE;m=e.origin.y+e.direction.y*f;if(m<c.min.y||m>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,n)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE};
|
|
|
|
|
THREE.CollisionSystem.prototype.raySphere=function(b,c){var e=c.center.clone().subSelf(b.origin);if(e.lengthSq<c.radiusSq)return-1;var f=e.dot(b.direction.clone());if(f<=0)return Number.MAX_VALUE;e=c.radiusSq-(e.lengthSq()-f*f);if(e>=0)return Math.abs(f)-Math.sqrt(e);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
|
|
|
|
|
THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var c=b.geometry.boundingBox,e=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),e=new THREE.BoxCollider(e,c);e.mesh=b;return e};THREE.CollisionUtils.MeshAABB=function(b){var c=THREE.CollisionUtils.MeshOBB(b);c.min.addSelf(b.position);c.max.addSelf(b.position);c.dynamic=!1;return c};
|
|
|
|
|
THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))};
|
|
|
|
|
THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,d=this.setSize,e=this.render,f=new THREE.Camera,h=new THREE.Camera,b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},j=new THREE.WebGLRenderTarget(512,512,b),k=new THREE.WebGLRenderTarget(512,512,b),m=new THREE.Camera(53,1,1,1E4);m.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:j},mapRight:{type:"t",value:1,texture:k}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
|
|
|
|
|
fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});var o=new THREE.Scene;o.addObject(new THREE.Mesh(new THREE.Plane(2,2),_material));this.setSize=function(b,e){d.call(c,b,e);j.width=b;j.height=e;k.width=b;k.height=e};this.render=
|
|
|
|
|
function(b,d){f.projectionMatrix=d.projectionMatrix;f.position.copy(d.position);f.target.position.copy(d.target.position);f.translateX(-10);h.projectionMatrix=d.projectionMatrix;h.position.copy(d.position);h.target.position.copy(d.target.position);h.translateX(10);e.call(c,b,f,j,!0);e.call(c,b,h,k,!0);e.call(c,o,m)}};THREE.AnaglyphWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.AnaglyphWebGLRenderer.prototype.constructor=THREE.AnaglyphWebGLRenderer;
|
|
|
|
|
THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,d=this.setSize,e=this.render,f,h,j=new THREE.Camera,k=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,e){d.call(c,b,e);f=b/2;h=e};this.render=function(b,d){this.clear();j.fov=d.fov;j.aspect=0.5*d.aspect;j.near=d.near;j.far=d.far;j.updateProjectionMatrix();
|
|
|
|
|
j.position.copy(d.position);j.target.position.copy(d.target.position);j.translateX(c.separation);k.projectionMatrix=j.projectionMatrix;k.position.copy(d.position);k.target.position.copy(d.target.position);k.translateX(-c.separation);this.setViewport(0,0,f,h);e.call(c,b,j);this.setViewport(f,0,f,h);e.call(c,b,k,!1)}};THREE.CrosseyedWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.CrosseyedWebGLRenderer.prototype.constructor=THREE.CrosseyedWebGLRenderer;
|
|
|
|
|
THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,g=new THREE.Camera,j=new THREE.Camera,b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},k=new THREE.WebGLRenderTarget(512,512,b),m=new THREE.WebGLRenderTarget(512,512,b),n=new THREE.Camera(53,1,1,1E4);n.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:k},mapRight:{type:"t",value:1,texture:m}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
|
|
|
|
|
fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});var p=new THREE.Scene;p.addObject(new THREE.Mesh(new THREE.Plane(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);k.width=b;k.height=f;m.width=b;m.height=f};this.render=
|
|
|
|
|
function(b,e){g.projectionMatrix=e.projectionMatrix;g.position.copy(e.position);g.target.position.copy(e.target.position);g.translateX(-10);j.projectionMatrix=e.projectionMatrix;j.position.copy(e.position);j.target.position.copy(e.target.position);j.translateX(10);f.call(c,b,g,k,!0);f.call(c,b,j,m,!0);f.call(c,p,n)}};THREE.AnaglyphWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.AnaglyphWebGLRenderer.prototype.constructor=THREE.AnaglyphWebGLRenderer;
|
|
|
|
|
THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,g,j,k=new THREE.Camera,m=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,f){e.call(c,b,f);g=b/2;j=f};this.render=function(b,e){this.clear();k.fov=e.fov;k.aspect=0.5*e.aspect;k.near=e.near;k.far=e.far;k.updateProjectionMatrix();
|
|
|
|
|
k.position.copy(e.position);k.target.position.copy(e.target.position);k.translateX(c.separation);m.projectionMatrix=k.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,g,j);f.call(c,b,k);this.setViewport(g,0,g,j);f.call(c,b,m,!1)}};THREE.CrosseyedWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.CrosseyedWebGLRenderer.prototype.constructor=THREE.CrosseyedWebGLRenderer;
|
|
|
|
|