mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-09 04:56:01 +10:00
Fixed class hierarchy for BinaryLoader and UTF8Loader.
Also tried to clean whitespace for ColladaLoader. This thing is so massive.
This commit is contained in:
+339
-339
@@ -14,38 +14,38 @@ b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function
|
||||
THREE.Vector4.prototype={constructor:THREE.Vector4,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||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.z=this.y=this.x=0,this.w=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={constructor:THREE.Ray,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,c){return b.distance-c.distance});return f},intersectObject:function(b){function c(b,c,e){var f;f=e.clone().subSelf(b).dot(c);if(f<=0)return null;b=b.clone().addSelf(c.clone().multiplyScalar(f));return e.distanceTo(b)}function e(b,c,e,f){var f=f.clone().subSelf(c),
|
||||
e=e.clone().subSelf(c),h=b.clone().subSelf(c),b=f.dot(f),c=f.dot(e),f=f.dot(h),j=e.dot(e),e=e.dot(h),h=1/(b*j-c*c),j=(j*f-c*e)*h,b=(b*e-c*f)*h;return j>0&&b>0&&j+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||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.matrixWorld.getPosition());if(f==null||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,
|
||||
Math.max(b.scale.y,b.scale.z)))return[];var h,k,j,m,o,t,p,v,w,u,y=b.geometry,x=y.vertices,B=[],f=0;for(h=y.faces.length;f<h;f++)if(k=y.faces[f],w=this.origin.clone(),u=this.direction.clone(),t=b.matrixWorld,j=t.multiplyVector3(k.centroid.clone()).subSelf(w),v=j.dot(u),!(v<=0)&&(j=t.multiplyVector3(x[k.a].position.clone()),m=t.multiplyVector3(x[k.b].position.clone()),o=t.multiplyVector3(x[k.c].position.clone()),t=k instanceof THREE.Face4?t.multiplyVector3(x[k.d].position.clone()):null,p=b.matrixRotationWorld.multiplyVector3(k.normal.clone()),
|
||||
v=u.dot(p),b.doubleSided||(b.flipSided?v>0:v<0)))if(v=p.dot((new THREE.Vector3).sub(j,w))/v,w=w.addSelf(u.multiplyScalar(v)),k instanceof THREE.Face3)e(w,j,m,o)&&(k={distance:this.origin.distanceTo(w),point:w,face:k,object:b},B.push(k));else if(k instanceof THREE.Face4&&(e(w,j,m,t)||e(w,m,o,t)))k={distance:this.origin.distanceTo(w),point:w,face:k,object:b},B.push(k);B.sort(function(b,c){return b.distance-c.distance});return B}else return[]}};
|
||||
THREE.Rectangle=function(){function b(){k=f-c;j=h-e}var c,e,f,h,k,j,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(j,k,p,v){m=!1;c=j;e=k;f=p;h=v;b()};this.addPoint=function(j,k){m?(m=!1,c=j,e=k,f=j,h=k):(c=c<j?c:j,e=e<k?e:k,f=f>j?f:j,h=h>k?h:k);b()};this.add3Points=
|
||||
function(j,k,p,v,w,u){m?(m=!1,c=j<p?j<w?j:w:p<w?p:w,e=k<v?k<u?k:u:v<u?v:u,f=j>p?j>w?j:w:p>w?p:w,h=k>v?k>u?k:u:v>u?v:u):(c=j<p?j<w?j<c?j:c:w<c?w:c:p<w?p<c?p:c:w<c?w:c,e=k<v?k<u?k<e?k:e:u<e?u:e:v<u?v<e?v:e:u<e?u:e,f=j>p?j>w?j>f?j:f:w>f?w:f:p>w?p>f?p:f:w>f?w:f,h=k>v?k>u?k>h?k:h:u>h?u:h:v>u?v>h?v:h:u>h?u:h);b()};this.addRectangle=function(j){m?(m=!1,c=j.getLeft(),e=j.getTop(),f=j.getRight(),h=j.getBottom()):(c=c<j.getLeft()?c:j.getLeft(),e=e<j.getTop()?e:j.getTop(),f=f>j.getRight()?f:j.getRight(),h=h>
|
||||
THREE.Ray.prototype={constructor:THREE.Ray,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.clone().subSelf(b).dot(e);if(f<=0)return null;b=b.clone().addSelf(e.clone().multiplyScalar(f));return c.distanceTo(b)}function e(b,e,c,f){var f=f.clone().subSelf(e),
|
||||
c=c.clone().subSelf(e),h=b.clone().subSelf(e),b=f.dot(f),e=f.dot(c),f=f.dot(h),j=c.dot(c),c=c.dot(h),h=1/(b*j-e*e),j=(j*f-e*c)*h,b=(b*c-e*f)*h;return j>0&&b>0&&j+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||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.matrixWorld.getPosition());if(f==null||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,
|
||||
Math.max(b.scale.y,b.scale.z)))return[];var h,k,j,m,p,o,t,v,w,u,y=b.geometry,x=y.vertices,B=[],f=0;for(h=y.faces.length;f<h;f++)if(k=y.faces[f],w=this.origin.clone(),u=this.direction.clone(),o=b.matrixWorld,j=o.multiplyVector3(k.centroid.clone()).subSelf(w),v=j.dot(u),!(v<=0)&&(j=o.multiplyVector3(x[k.a].position.clone()),m=o.multiplyVector3(x[k.b].position.clone()),p=o.multiplyVector3(x[k.c].position.clone()),o=k instanceof THREE.Face4?o.multiplyVector3(x[k.d].position.clone()):null,t=b.matrixRotationWorld.multiplyVector3(k.normal.clone()),
|
||||
v=u.dot(t),b.doubleSided||(b.flipSided?v>0:v<0)))if(v=t.dot((new THREE.Vector3).sub(j,w))/v,w=w.addSelf(u.multiplyScalar(v)),k instanceof THREE.Face3)e(w,j,m,p)&&(k={distance:this.origin.distanceTo(w),point:w,face:k,object:b},B.push(k));else if(k instanceof THREE.Face4&&(e(w,j,m,o)||e(w,m,p,o)))k={distance:this.origin.distanceTo(w),point:w,face:k,object:b},B.push(k);B.sort(function(b,e){return b.distance-e.distance});return B}else return[]}};
|
||||
THREE.Rectangle=function(){function b(){k=f-c;j=h-e}var c,e,f,h,k,j,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(j,k,t,v){m=!1;c=j;e=k;f=t;h=v;b()};this.addPoint=function(j,k){m?(m=!1,c=j,e=k,f=j,h=k):(c=c<j?c:j,e=e<k?e:k,f=f>j?f:j,h=h>k?h:k);b()};this.add3Points=
|
||||
function(j,k,t,v,w,u){m?(m=!1,c=j<t?j<w?j:w:t<w?t:w,e=k<v?k<u?k:u:v<u?v:u,f=j>t?j>w?j:w:t>w?t:w,h=k>v?k>u?k:u:v>u?v:u):(c=j<t?j<w?j<c?j:c:w<c?w:c:t<w?t<c?t:c:w<c?w:c,e=k<v?k<u?k<e?k:e:u<e?u:e:v<u?v<e?v:e:u<e?u:e,f=j>t?j>w?j>f?j:f:w>f?w:f:t>w?t>f?t:f:w>f?w:f,h=k>v?k>u?k>h?k:h:u>h?u:h:v>u?v>h?v:h:u>h?u:h);b()};this.addRectangle=function(j){m?(m=!1,c=j.getLeft(),e=j.getTop(),f=j.getRight(),h=j.getBottom()):(c=c<j.getLeft()?c:j.getLeft(),e=e<j.getTop()?e:j.getTop(),f=f>j.getRight()?f:j.getRight(),h=h>
|
||||
j.getBottom()?h:j.getBottom());b()};this.inflate=function(j){c-=j;e-=j;f+=j;h+=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();h=h<j.getBottom()?h:j.getBottom();b()};this.instersects=function(b){return Math.min(f,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){m=!0;h=f=e=c=0;b()};this.isEmpty=function(){return m}};THREE.Matrix3=function(){this.m=[]};
|
||||
THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,h,k,j,m,o,t,p,v,w,u,y,x){this.set(b||1,c||0,e||0,f||0,h||0,k||1,j||0,m||0,o||0,t||0,p||1,v||0,w||0,u||0,y||0,x||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
|
||||
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,k,j,m,o,t,p,v,w,u,y,x){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=k;this.n23=j;this.n24=m;this.n31=o;this.n32=t;this.n33=p;this.n34=v;this.n41=w;this.n42=u;this.n43=y;this.n44=x;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,
|
||||
THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,h,k,j,m,p,o,t,v,w,u,y,x){this.set(b||1,c||0,e||0,f||0,h||0,k||1,j||0,m||0,p||0,o||0,t||1,v||0,w||0,u||0,y||0,x||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
|
||||
THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,k,j,m,p,o,t,v,w,u,y,x){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=k;this.n23=j;this.n24=m;this.n31=p;this.n32=o;this.n33=t;this.n34=v;this.n41=w;this.n42=u;this.n43=y;this.n44=x;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,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,c).normalize();if(k.length()===0)k.z=1;f.cross(e,k).normalize();f.length()===0&&(k.x+=1.0E-4,f.cross(e,k).normalize());h.cross(k,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=k.x;this.n21=f.y;this.n22=h.y;this.n23=k.y;this.n31=f.z;this.n32=h.z;this.n33=k.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,h=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)*h;
|
||||
b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*h;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,h=b.n13,k=b.n14,j=b.n21,m=b.n22,o=b.n23,t=b.n24,p=b.n31,v=b.n32,w=b.n33,u=b.n34,y=b.n41,x=b.n42,B=b.n43,z=b.n44,H=c.n11,D=c.n12,
|
||||
I=c.n13,K=c.n14,M=c.n21,C=c.n22,J=c.n23,E=c.n24,Y=c.n31,F=c.n32,L=c.n33,N=c.n34,P=c.n41,n=c.n42,V=c.n43,ha=c.n44;this.n11=e*H+f*M+h*Y+k*P;this.n12=e*D+f*C+h*F+k*n;this.n13=e*I+f*J+h*L+k*V;this.n14=e*K+f*E+h*N+k*ha;this.n21=j*H+m*M+o*Y+t*P;this.n22=j*D+m*C+o*F+t*n;this.n23=j*I+m*J+o*L+t*V;this.n24=j*K+m*E+o*N+t*ha;this.n31=p*H+v*M+w*Y+u*P;this.n32=p*D+v*C+w*F+u*n;this.n33=p*I+v*J+w*L+u*V;this.n34=p*K+v*E+w*N+u*ha;this.n41=y*H+x*M+B*Y+z*P;this.n42=y*D+x*C+B*F+z*n;this.n43=y*I+x*J+B*L+z*V;this.n44=y*
|
||||
K+x*E+B*N+z*ha;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,h=this.n21,k=this.n22,j=this.n23,m=this.n24,o=this.n31,t=this.n32,p=this.n33,v=this.n34,w=this.n41,u=this.n42,y=this.n43,x=this.n44;return f*j*t*w-e*m*t*w-f*k*p*w+c*m*p*w+e*k*v*w-c*j*v*w-f*j*o*u+e*m*o*u+f*h*p*u-b*m*p*u-e*h*v*u+b*j*v*u+f*k*o*y-c*m*o*y-f*h*t*y+b*m*t*y+c*h*v*y-b*k*v*y-e*k*o*x+c*j*o*x+e*h*t*x-b*j*t*x-c*h*
|
||||
p*x+b*k*p*x},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=
|
||||
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,h=b.n13,k=b.n14,j=b.n21,m=b.n22,p=b.n23,o=b.n24,t=b.n31,v=b.n32,w=b.n33,u=b.n34,y=b.n41,x=b.n42,B=b.n43,z=b.n44,D=c.n11,C=c.n12,
|
||||
E=c.n13,J=c.n14,O=c.n21,K=c.n22,I=c.n23,F=c.n24,Y=c.n31,G=c.n32,M=c.n33,L=c.n34,S=c.n41,n=c.n42,V=c.n43,fa=c.n44;this.n11=e*D+f*O+h*Y+k*S;this.n12=e*C+f*K+h*G+k*n;this.n13=e*E+f*I+h*M+k*V;this.n14=e*J+f*F+h*L+k*fa;this.n21=j*D+m*O+p*Y+o*S;this.n22=j*C+m*K+p*G+o*n;this.n23=j*E+m*I+p*M+o*V;this.n24=j*J+m*F+p*L+o*fa;this.n31=t*D+v*O+w*Y+u*S;this.n32=t*C+v*K+w*G+u*n;this.n33=t*E+v*I+w*M+u*V;this.n34=t*J+v*F+w*L+u*fa;this.n41=y*D+x*O+B*Y+z*S;this.n42=y*C+x*K+B*G+z*n;this.n43=y*E+x*I+B*M+z*V;this.n44=y*
|
||||
J+x*F+B*L+z*fa;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,h=this.n21,k=this.n22,j=this.n23,m=this.n24,p=this.n31,o=this.n32,t=this.n33,v=this.n34,w=this.n41,u=this.n42,y=this.n43,x=this.n44;return f*j*o*w-e*m*o*w-f*k*t*w+c*m*t*w+e*k*v*w-c*j*v*w-f*j*p*u+e*m*p*u+f*h*t*u-b*m*t*u-e*h*v*u+b*j*v*u+f*k*p*y-c*m*p*y-f*h*o*y+b*m*o*y+c*h*v*y-b*k*v*y-e*k*p*x+c*j*p*x+e*h*o*x-b*j*o*x-c*h*
|
||||
t*x+b*k*t*x},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,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),h=1-e,k=b.x,j=b.y,m=b.z,o=h*k,t=h*j;this.set(o*k+e,o*j-f*m,o*m+f*j,0,o*j+f*m,t*j+e,t*m-f*k,0,o*m-f*j,t*m+f*k,h*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,c){var e=b.x,f=b.y,h=b.z,k=Math.cos(e),e=Math.sin(e),j=Math.cos(f),f=Math.sin(f),m=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var o=
|
||||
j*m,t=j*h,p=f*m,v=f*h;this.n11=o+v*e;this.n12=p*e-t;this.n13=k*f;this.n21=k*h;this.n22=k*m;this.n23=-e;this.n31=t*e-p;this.n32=v+o*e;this.n33=k*j;break;case "ZXY":o=j*m;t=j*h;p=f*m;v=f*h;this.n11=o-v*e;this.n12=-k*h;this.n13=p+t*e;this.n21=t+p*e;this.n22=k*m;this.n23=v-o*e;this.n31=-k*f;this.n32=e;this.n33=k*j;break;case "ZYX":o=k*m;t=k*h;p=e*m;v=e*h;this.n11=j*m;this.n12=p*f-t;this.n13=o*f+v;this.n21=j*h;this.n22=v*f+o;this.n23=t*f-p;this.n31=-f;this.n32=e*j;this.n33=k*j;break;case "YZX":o=k*j;t=
|
||||
k*f;p=e*j;v=e*f;this.n11=j*m;this.n12=v-o*h;this.n13=p*h+t;this.n21=h;this.n22=k*m;this.n23=-e*m;this.n31=-f*m;this.n32=t*h+p;this.n33=o-v*h;break;case "XZY":o=k*j;t=k*f;p=e*j;v=e*f;this.n11=j*m;this.n12=-h;this.n13=f*m;this.n21=o*h+v;this.n22=k*m;this.n23=t*h-p;this.n31=p*h-t;this.n32=e*m;this.n33=v*h+o;break;default:o=k*m,t=k*h,p=e*m,v=e*h,this.n11=j*m,this.n12=-j*h,this.n13=f,this.n21=t+p*f,this.n22=o-v*f,this.n23=-e*j,this.n31=v-o*f,this.n32=p+t*f,this.n33=k*j}return this},setRotationFromQuaternion:function(b){var c=
|
||||
b.x,e=b.y,f=b.z,h=b.w,k=c+c,j=e+e,m=f+f,b=c*k,o=c*j;c*=m;var t=e*j;e*=m;f*=m;k*=h;j*=h;h*=m;this.n11=1-(t+f);this.n12=o-h;this.n13=c+j;this.n21=o+h;this.n22=1-(b+f);this.n23=e-k;this.n31=c-j;this.n32=e+k;this.n33=1-(b+t);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},compose:function(b,c,e){var f=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2;
|
||||
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),h=1-e,k=b.x,j=b.y,m=b.z,p=h*k,o=h*j;this.set(p*k+e,p*j-f*m,p*m+f*j,0,p*j+f*m,o*j+e,o*m-f*k,0,p*m-f*j,o*m+f*k,h*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,c){var e=b.x,f=b.y,h=b.z,k=Math.cos(e),e=Math.sin(e),j=Math.cos(f),f=Math.sin(f),m=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var p=
|
||||
j*m,o=j*h,t=f*m,v=f*h;this.n11=p+v*e;this.n12=t*e-o;this.n13=k*f;this.n21=k*h;this.n22=k*m;this.n23=-e;this.n31=o*e-t;this.n32=v+p*e;this.n33=k*j;break;case "ZXY":p=j*m;o=j*h;t=f*m;v=f*h;this.n11=p-v*e;this.n12=-k*h;this.n13=t+o*e;this.n21=o+t*e;this.n22=k*m;this.n23=v-p*e;this.n31=-k*f;this.n32=e;this.n33=k*j;break;case "ZYX":p=k*m;o=k*h;t=e*m;v=e*h;this.n11=j*m;this.n12=t*f-o;this.n13=p*f+v;this.n21=j*h;this.n22=v*f+p;this.n23=o*f-t;this.n31=-f;this.n32=e*j;this.n33=k*j;break;case "YZX":p=k*j;o=
|
||||
k*f;t=e*j;v=e*f;this.n11=j*m;this.n12=v-p*h;this.n13=t*h+o;this.n21=h;this.n22=k*m;this.n23=-e*m;this.n31=-f*m;this.n32=o*h+t;this.n33=p-v*h;break;case "XZY":p=k*j;o=k*f;t=e*j;v=e*f;this.n11=j*m;this.n12=-h;this.n13=f*m;this.n21=p*h+v;this.n22=k*m;this.n23=o*h-t;this.n31=t*h-o;this.n32=e*m;this.n33=v*h+p;break;default:p=k*m,o=k*h,t=e*m,v=e*h,this.n11=j*m,this.n12=-j*h,this.n13=f,this.n21=o+t*f,this.n22=p-v*f,this.n23=-e*j,this.n31=v-p*f,this.n32=t+o*f,this.n33=k*j}return this},setRotationFromQuaternion:function(b){var c=
|
||||
b.x,e=b.y,f=b.z,h=b.w,k=c+c,j=e+e,m=f+f,b=c*k,p=c*j;c*=m;var o=e*j;e*=m;f*=m;k*=h;j*=h;h*=m;this.n11=1-(o+f);this.n12=p-h;this.n13=c+j;this.n21=p+h;this.n22=1-(b+f);this.n23=e-k;this.n31=c-j;this.n32=e+k;this.n33=1-(b+o);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},compose:function(b,c,e){var f=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2;
|
||||
f.identity();f.setRotationFromQuaternion(c);h.setScale(e.x,e.y,e.z);this.multiply(f,h);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);k.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;e=e instanceof THREE.Vector3?e:new THREE.Vector3;e.x=f.length();
|
||||
e.y=h.length();e.z=k.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=e.x;f.n21/=e.x;f.n31/=e.x;f.n12/=e.y;f.n22/=e.y;f.n32/=e.y;f.n13/=e.z;f.n23/=e.z;f.n33/=e.z;c.setFromRotationMatrix(f);return[b,c,e]},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,h=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*h;this.n23=
|
||||
b.n23*h;this.n33=b.n33*h}};
|
||||
THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,j=b.n21,m=b.n22,o=b.n23,t=b.n24,p=b.n31,v=b.n32,w=b.n33,u=b.n34,y=b.n41,x=b.n42,B=b.n43,z=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=o*u*x-t*w*x+t*v*B-m*u*B-o*v*z+m*w*z;c.n12=k*w*x-h*u*x-k*v*B+f*u*B+h*v*z-f*w*z;c.n13=h*t*x-k*o*x+k*m*B-f*t*B-h*m*z+f*o*z;c.n14=k*o*v-h*t*v-k*m*w+f*t*w+h*m*u-f*o*u;c.n21=t*w*y-o*u*y-t*p*B+j*u*B+o*p*z-j*w*z;c.n22=h*u*y-k*w*y+k*p*B-e*u*B-h*p*z+e*w*z;c.n23=k*o*y-h*t*y-k*j*B+e*t*B+h*j*z-e*o*z;c.n24=
|
||||
h*t*p-k*o*p+k*j*w-e*t*w-h*j*u+e*o*u;c.n31=m*u*y-t*v*y+t*p*x-j*u*x-m*p*z+j*v*z;c.n32=k*v*y-f*u*y-k*p*x+e*u*x+f*p*z-e*v*z;c.n33=h*t*y-k*m*y+k*j*x-e*t*x-f*j*z+e*m*z;c.n34=k*m*p-f*t*p-k*j*v+e*t*v+f*j*u-e*m*u;c.n41=o*v*y-m*w*y-o*p*x+j*w*x+m*p*B-j*v*B;c.n42=f*w*y-h*v*y+h*p*x-e*w*x-f*p*B+e*v*B;c.n43=h*m*y-f*o*y-h*j*x+e*o*x+f*j*B-e*m*B;c.n44=f*o*p-h*m*p+h*j*v-e*o*v-f*j*w+e*m*w;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,h=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,o=-b.n32*b.n11+b.n31*b.n12,t=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,v=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*j+b.n31*t;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*k;e[3]=b*j;e[4]=b*m;e[5]=b*o;e[6]=b*t;e[7]=b*p;e[8]=b*v;return c};
|
||||
THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,j=b.n21,m=b.n22,p=b.n23,o=b.n24,t=b.n31,v=b.n32,w=b.n33,u=b.n34,y=b.n41,x=b.n42,B=b.n43,z=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=p*u*x-o*w*x+o*v*B-m*u*B-p*v*z+m*w*z;c.n12=k*w*x-h*u*x-k*v*B+f*u*B+h*v*z-f*w*z;c.n13=h*o*x-k*p*x+k*m*B-f*o*B-h*m*z+f*p*z;c.n14=k*p*v-h*o*v-k*m*w+f*o*w+h*m*u-f*p*u;c.n21=o*w*y-p*u*y-o*t*B+j*u*B+p*t*z-j*w*z;c.n22=h*u*y-k*w*y+k*t*B-e*u*B-h*t*z+e*w*z;c.n23=k*p*y-h*o*y-k*j*B+e*o*B+h*j*z-e*p*z;c.n24=
|
||||
h*o*t-k*p*t+k*j*w-e*o*w-h*j*u+e*p*u;c.n31=m*u*y-o*v*y+o*t*x-j*u*x-m*t*z+j*v*z;c.n32=k*v*y-f*u*y-k*t*x+e*u*x+f*t*z-e*v*z;c.n33=h*o*y-k*m*y+k*j*x-e*o*x-f*j*z+e*m*z;c.n34=k*m*t-f*o*t-k*j*v+e*o*v+f*j*u-e*m*u;c.n41=p*v*y-m*w*y-p*t*x+j*w*x+m*t*B-j*v*B;c.n42=f*w*y-h*v*y+h*t*x-e*w*x-f*t*B+e*v*B;c.n43=h*m*y-f*p*y-h*j*x+e*p*x+f*j*B-e*m*B;c.n44=f*p*t-h*m*t+h*j*v-e*p*v-f*j*w+e*m*w;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,h=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,p=-b.n32*b.n11+b.n31*b.n12,o=b.n23*b.n12-b.n22*b.n13,t=-b.n23*b.n11+b.n21*b.n13,v=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*j+b.n31*o;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*k;e[3]=b*j;e[4]=b*m;e[5]=b*p;e[6]=b*o;e[7]=b*t;e[8]=b*v;return c};
|
||||
THREE.Matrix4.makeFrustum=function(b,c,e,f,h,k){var j;j=new THREE.Matrix4;j.n11=2*h/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*h/(f-e);j.n23=(f+e)/(f-e);j.n24=0;j.n31=0;j.n32=0;j.n33=-(k+h)/(k-h);j.n34=-2*k*h/(k-h);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,c,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,e,f)};
|
||||
THREE.Matrix4.makeOrtho=function(b,c,e,f,h,k){var j,m,o,t;j=new THREE.Matrix4;m=c-b;o=e-f;t=k-h;j.n11=2/m;j.n12=0;j.n13=0;j.n14=-((c+b)/m);j.n21=0;j.n22=2/o;j.n23=0;j.n24=-((e+f)/o);j.n31=0;j.n32=0;j.n33=-2/t;j.n34=-((k+h)/t);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;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
|
||||
THREE.Matrix4.makeOrtho=function(b,c,e,f,h,k){var j,m,p,o;j=new THREE.Matrix4;m=c-b;p=e-f;o=k-h;j.n11=2/m;j.n12=0;j.n13=0;j.n14=-((c+b)/m);j.n21=0;j.n22=2/p;j.n23=0;j.n24=-((e+f)/p);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((k+h)/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;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
|
||||
THREE.Object3D=function(){this.id=THREE.Object3DCount++;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.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;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.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""};
|
||||
THREE.Object3D.prototype={constructor:THREE.Object3D,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)===
|
||||
@@ -55,27 +55,27 @@ this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matri
|
||||
THREE.Quaternion.prototype={constructor:THREE.Quaternion,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,h=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-h),h=Math.sin(-h),k=Math.cos(e),e=Math.sin(e),j=b*c,m=f*h;this.w=j*k-m*e;this.x=j*e+m*k;this.y=f*c*k+b*h*e;this.z=b*h*k-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},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z);
|
||||
this.normalize();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,h=this.w,k=b.x,j=b.y,m=b.z,b=b.w;this.x=c*b+h*k+e*m-f*j;this.y=e*b+h*j+f*k-c*m;this.z=f*b+h*m+c*j-e*k;this.w=h*b-c*k-e*j-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,h=b.z,k=this.x,j=this.y,m=this.z,o=this.w,t=o*e+j*h-m*f,p=o*f+m*e-k*h,v=o*h+k*f-j*e,e=-k*
|
||||
e-j*f-m*h;c.x=t*o+e*-k+p*-m-v*-j;c.y=p*o+e*-j+v*-k-t*-m;c.z=v*o+e*-m+t*-j-p*-k;return c}};THREE.Quaternion.slerp=function(b,c,e,f){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var k=Math.acos(h),j=Math.sqrt(1-h*h);if(Math.abs(j)<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;h=Math.sin((1-f)*k)/j;f=Math.sin(f*k)/j;e.w=b.w*h+c.w*f;e.x=b.x*h+c.x*f;e.y=b.y*h+c.y*f;e.z=b.z*h+c.z*f;return e};
|
||||
this.x,e=this.y,f=this.z,h=this.w,k=b.x,j=b.y,m=b.z,b=b.w;this.x=c*b+h*k+e*m-f*j;this.y=e*b+h*j+f*k-c*m;this.z=f*b+h*m+c*j-e*k;this.w=h*b-c*k-e*j-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,h=b.z,k=this.x,j=this.y,m=this.z,p=this.w,o=p*e+j*h-m*f,t=p*f+m*e-k*h,v=p*h+k*f-j*e,e=-k*
|
||||
e-j*f-m*h;c.x=o*p+e*-k+t*-m-v*-j;c.y=t*p+e*-j+v*-k-o*-m;c.z=v*p+e*-m+o*-j-t*-k;return c}};THREE.Quaternion.slerp=function(b,c,e,f){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var k=Math.acos(h),j=Math.sqrt(1-h*h);if(Math.abs(j)<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;h=Math.sin((1-f)*k)/j;f=Math.sin(f*k)/j;e.w=b.w*h+c.w*f;e.x=b.x*h+c.x*f;e.y=b.y*h+c.y*f;e.z=b.z*h+c.z*f;return e};
|
||||
THREE.Vertex=function(b){this.position=b||new THREE.Vector3};THREE.Face3=function(b,c,e,f,h,k){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=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};
|
||||
THREE.Face4=function(b,c,e,f,h,k,j){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=k instanceof THREE.Color?k:new THREE.Color;this.vertexColors=k instanceof Array?k:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.u=b||0;this.v=c||0};
|
||||
THREE.UV.prototype={constructor:THREE.UV,set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.u=b.u;this.v=b.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
|
||||
THREE.Geometry=function(){this.id=THREE.GeometryCount++;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.dynamic=this.hasTangents=!1};
|
||||
THREE.Geometry.prototype={constructor:THREE.Geometry,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,h,k,j,m=new THREE.Vector3,o=new THREE.Vector3;f=0;for(h=this.faces.length;f<h;f++){k=this.faces[f];if(b&&k.vertexNormals.length){m.set(0,0,0);c=0;for(e=k.vertexNormals.length;c<e;c++)m.addSelf(k.vertexNormals[c]);m.divideScalar(3)}else c=this.vertices[k.a],e=this.vertices[k.b],j=this.vertices[k.c],m.sub(j.position,e.position),o.sub(c.position,e.position),m.crossSelf(o);m.isZero()||
|
||||
e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var c,e,f,h,k,j,m=new THREE.Vector3,p=new THREE.Vector3;f=0;for(h=this.faces.length;f<h;f++){k=this.faces[f];if(b&&k.vertexNormals.length){m.set(0,0,0);c=0;for(e=k.vertexNormals.length;c<e;c++)m.addSelf(k.vertexNormals[c]);m.divideScalar(3)}else c=this.vertices[k.a],e=this.vertices[k.b],j=this.vertices[k.c],m.sub(j.position,e.position),p.sub(c.position,e.position),m.crossSelf(p);m.isZero()||
|
||||
m.normalize();k.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,c,e,f,h,k,n){m=b.vertices[c].position;o=b.vertices[e].position;t=b.vertices[f].position;p=j[h];v=j[k];w=j[n];u=o.x-m.x;y=t.x-m.x;x=o.y-m.y;B=t.y-m.y;z=o.z-m.z;H=t.z-m.z;D=v.u-p.u;I=w.u-p.u;K=v.v-p.v;M=w.v-p.v;C=1/(D*M-I*K);F.set((M*u-K*y)*
|
||||
C,(M*x-K*B)*C,(M*z-K*H)*C);L.set((D*y-I*u)*C,(D*B-I*x)*C,(D*H-I*z)*C);E[c].addSelf(F);E[e].addSelf(F);E[f].addSelf(F);Y[c].addSelf(L);Y[e].addSelf(L);Y[f].addSelf(L)}var c,e,f,h,k,j,m,o,t,p,v,w,u,y,x,B,z,H,D,I,K,M,C,J,E=[],Y=[],F=new THREE.Vector3,L=new THREE.Vector3,N=new THREE.Vector3,P=new THREE.Vector3,n=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)E[c]=new THREE.Vector3,Y[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)k=this.faces[c],j=this.faceVertexUvs[0][c],k instanceof
|
||||
THREE.Face3?b(this,k.a,k.b,k.c,0,1,2):k instanceof THREE.Face4&&(b(this,k.a,k.b,k.c,0,1,2),b(this,k.a,k.b,k.d,0,1,3));var V=["a","b","c","d"];c=0;for(e=this.faces.length;c<e;c++){k=this.faces[c];for(f=0;f<k.vertexNormals.length;f++)n.copy(k.vertexNormals[f]),h=k[V[f]],J=E[h],N.copy(J),N.subSelf(n.multiplyScalar(n.dot(J))).normalize(),P.cross(k.vertexNormals[f],J),h=P.dot(Y[h]),h=h<0?-1:1,k.vertexTangents[f]=new THREE.Vector4(N.x,N.y,N.z,h)}this.hasTangents=!0},computeBoundingBox:function(){var b;
|
||||
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,h,k,n){m=b.vertices[e].position;p=b.vertices[c].position;o=b.vertices[f].position;t=j[h];v=j[k];w=j[n];u=p.x-m.x;y=o.x-m.x;x=p.y-m.y;B=o.y-m.y;z=p.z-m.z;D=o.z-m.z;C=v.u-t.u;E=w.u-t.u;J=v.v-t.v;O=w.v-t.v;K=1/(C*O-E*J);G.set((O*u-J*y)*
|
||||
K,(O*x-J*B)*K,(O*z-J*D)*K);M.set((C*y-E*u)*K,(C*B-E*x)*K,(C*D-E*z)*K);F[e].addSelf(G);F[c].addSelf(G);F[f].addSelf(G);Y[e].addSelf(M);Y[c].addSelf(M);Y[f].addSelf(M)}var c,e,f,h,k,j,m,p,o,t,v,w,u,y,x,B,z,D,C,E,J,O,K,I,F=[],Y=[],G=new THREE.Vector3,M=new THREE.Vector3,L=new THREE.Vector3,S=new THREE.Vector3,n=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)F[c]=new THREE.Vector3,Y[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)k=this.faces[c],j=this.faceVertexUvs[0][c],k instanceof
|
||||
THREE.Face3?b(this,k.a,k.b,k.c,0,1,2):k instanceof THREE.Face4&&(b(this,k.a,k.b,k.c,0,1,2),b(this,k.a,k.b,k.d,0,1,3));var V=["a","b","c","d"];c=0;for(e=this.faces.length;c<e;c++){k=this.faces[c];for(f=0;f<k.vertexNormals.length;f++)n.copy(k.vertexNormals[f]),h=k[V[f]],I=F[h],L.copy(I),L.subSelf(n.multiplyScalar(n.dot(I))).normalize(),S.cross(k.vertexNormals[f],I),h=S.dot(Y[h]),h=h<0?-1:1,k.vertexTangents[f]=new THREE.Vector4(L.x,L.y,L.z,h)}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,c){return Math.min(b,c)+"_"+Math.max(b,c)}function c(b,c,e){b[c]===
|
||||
void 0?(b[c]={set:{},array:[]},b[c].set[e]=1,b[c].array.push(e)):b[c].set[e]===void 0&&(b[c].set[e]=1,b[c].array.push(e))}var e,f,h,k,j,m={};e=0;for(f=this.faces.length;e<f;e++)j=this.faces[e],j instanceof THREE.Face3?(h=b(j.a,j.b),c(m,h,e),h=b(j.b,j.c),c(m,h,e),h=b(j.a,j.c),c(m,h,e)):j instanceof THREE.Face4&&(h=b(j.b,j.d),c(m,h,e),h=b(j.a,j.b),c(m,h,e),h=b(j.a,j.d),c(m,h,e),h=b(j.b,j.c),c(m,h,e),h=b(j.c,j.d),c(m,h,e));e=0;for(f=this.edges.length;e<f;e++){j=this.edges[e];h=j.vertexIndices[0];k=j.vertexIndices[1];
|
||||
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,h,k,j,m={};e=0;for(f=this.faces.length;e<f;e++)j=this.faces[e],j instanceof THREE.Face3?(h=b(j.a,j.b),c(m,h,e),h=b(j.b,j.c),c(m,h,e),h=b(j.a,j.c),c(m,h,e)):j instanceof THREE.Face4&&(h=b(j.b,j.d),c(m,h,e),h=b(j.a,j.b),c(m,h,e),h=b(j.a,j.d),c(m,h,e),h=b(j.b,j.c),c(m,h,e),h=b(j.c,j.d),c(m,h,e));e=0;for(f=this.edges.length;e<f;e++){j=this.edges[e];h=j.vertexIndices[0];k=j.vertexIndices[1];
|
||||
j.faceIndices=m[b(h,k)].array;for(h=0;h<j.faceIndices.length;h++)k=j.faceIndices[h],j.faces.push(this.faces[k])}}};THREE.GeometryCount=0;
|
||||
THREE.Spline=function(b){function c(b,c,e,f,j,h,k){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*k+(-3*(c-e)-2*b-f)*h+b*j+c}this.points=b;var e=[],f={x:0,y:0,z:0},h,k,j,m,o,t,p,v,w;this.initFromArray=function(b){this.points=[];for(var c=0;c<b.length;c++)this.points[c]={x:b[c][0],y:b[c][1],z:b[c][2]}};this.getPoint=function(b){h=(this.points.length-1)*b;k=Math.floor(h);j=h-k;e[0]=k==0?k:k-1;e[1]=k;e[2]=k>this.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+2;t=this.points[e[0]];p=this.points[e[1]];
|
||||
v=this.points[e[2]];w=this.points[e[3]];m=j*j;o=j*m;f.x=c(t.x,p.x,v.x,w.x,j,m,o);f.y=c(t.y,p.y,v.y,w.y,j,m,o);f.z=c(t.z,p.z,v.z,w.z,j,m,o);return f};this.getControlPointsArray=function(){var b,c,e=this.points.length,f=[];for(b=0;b<e;b++)c=this.points[b],f[b]=[c.x,c.y,c.z];return f};this.getLength=function(b){var c,e,f=c=c=0,j=new THREE.Vector3,h=new THREE.Vector3,k=[],m=0;k[0]=0;b||(b=100);e=this.points.length*b;j.copy(this.points[0]);for(b=1;b<e;b++)c=b/e,position=this.getPoint(c),h.copy(position),
|
||||
m+=h.distanceTo(j),j.copy(position),c*=this.points.length-1,c=Math.floor(c),c!=f&&(k[c]=m,f=c);k[k.length]=m;return{chunks:k,total:m}};this.reparametrizeByArcLength=function(b){var c,e,f,j,h,k,m=[],o=new THREE.Vector3,v=this.getLength();m.push(o.copy(this.points[0]).clone());for(c=1;c<this.points.length;c++){e=v.chunks[c]-v.chunks[c-1];k=Math.ceil(b*e/v.total);j=(c-1)/(this.points.length-1);h=c/(this.points.length-1);for(e=1;e<k-1;e++)f=j+e*(1/k)*(h-j),position=this.getPoint(f),m.push(o.copy(position).clone());
|
||||
m.push(o.copy(this.points[c]).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,h){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=e||0.1;this.far=f||2E3;this.target=h||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
|
||||
THREE.Spline=function(b){function c(b,e,c,f,j,h,k){b=(c-b)*0.5;f=(f-e)*0.5;return(2*(e-c)+b+f)*k+(-3*(e-c)-2*b-f)*h+b*j+e}this.points=b;var e=[],f={x:0,y:0,z:0},h,k,j,m,p,o,t,v,w;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){h=(this.points.length-1)*b;k=Math.floor(h);j=h-k;e[0]=k==0?k:k-1;e[1]=k;e[2]=k>this.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+2;o=this.points[e[0]];t=this.points[e[1]];
|
||||
v=this.points[e[2]];w=this.points[e[3]];m=j*j;p=j*m;f.x=c(o.x,t.x,v.x,w.x,j,m,p);f.y=c(o.y,t.y,v.y,w.y,j,m,p);f.z=c(o.z,t.z,v.z,w.z,j,m,p);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,h=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),h.copy(position),
|
||||
m+=h.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,h,k,m=[],p=new THREE.Vector3,v=this.getLength();m.push(p.copy(this.points[0]).clone());for(e=1;e<this.points.length;e++){c=v.chunks[e]-v.chunks[e-1];k=Math.ceil(b*c/v.total);j=(e-1)/(this.points.length-1);h=e/(this.points.length-1);for(c=1;c<k-1;c++)f=j+c*(1/k)*(h-j),position=this.getPoint(f),m.push(p.copy(position).clone());
|
||||
m.push(p.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,h){THREE.Object3D.call(this);this.fov=b||50;this.aspect=c||1;this.near=e||0.1;this.far=f||2E3;this.target=h||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(){if(this.fullWidth){var b=this.fullWidth/this.fullHeight,c=Math.tan(this.fov*Math.PI/360)*this.near,e=-c,f=b*e,b=Math.abs(b*c-f),e=Math.abs(c-e);this.projectionMatrix=THREE.Matrix4.makeFrustum(f+this.x*b/this.fullWidth,f+(this.x+this.width)*b/this.fullWidth,c-(this.y+this.height)*e/this.fullHeight,c-this.y*e/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
|
||||
THREE.Camera.prototype.setViewOffset=function(b,c,e,f,h,k){this.fullWidth=b;this.fullHeight=c;this.x=e;this.y=f;this.width=h;this.height=k;this.updateProjectionMatrix()};
|
||||
@@ -105,7 +105,7 @@ THREE.ParticleCanvasMaterial=function(b){THREE.Material.call(this,b);b=b||{};thi
|
||||
THREE.Texture=function(b,c,e,f,h,k){this.id=THREE.TextureCount++;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=h!==void 0?h:THREE.LinearFilter;this.minFilter=k!==void 0?k:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
|
||||
THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var b=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);b.offset.copy(this.offset);b.repeat.copy(this.repeat);return b}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
|
||||
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};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.DataTexture=function(b,c,e,f,h,k,j,m,o){THREE.Texture.call(this,null,h,k,j,m,o);this.image={data:b,width:c,height:e};this.format=f!==void 0?f:THREE.RGBAFormat};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
|
||||
THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(b,c,e,f,h,k,j,m,p){THREE.Texture.call(this,null,h,k,j,m,p);this.image={data:b,width:c,height:e};this.format=f!==void 0?f:THREE.RGBAFormat};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
|
||||
THREE.DataTexture.prototype.clone=function(){var b=new THREE.DataTexture(this.data.slice(0),this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);b.offset.copy(this.offset);b.repeat.copy(this.repeat);return b};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,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;
|
||||
@@ -131,58 +131,58 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.c
|
||||
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.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.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,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=o[m]=o[m]||new THREE.RenderableVertex;m++;return b}function c(b,c){return c.z-b.z}function e(b,c){var e=0,f=1,j=b.z+b.w,h=c.z+c.w,k=-b.z+b.w,m=-c.z+c.w;return j>=0&&h>=0&&k>=0&&m>=0?!0:j<0&&h<0||k<0&&m<0?!1:(j<0?e=Math.max(e,j/(j-h)):h<0&&(f=Math.min(f,j/(j-h))),k<0?e=Math.max(e,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),f<e?!1:(b.lerpSelf(c,e),c.lerpSelf(b,1-f),!0))}var f,h,k=[],j,m,o=[],t,p,v=[],w,u=[],y,x,B=[],z,H,D=[],I=[],K=[],M=new THREE.Vector4,C=new THREE.Vector4,
|
||||
J=new THREE.Matrix4,E=new THREE.Matrix4,Y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,L=new THREE.Vector4;this.projectVector=function(b,c){J.multiply(c.projectionMatrix,c.matrixWorldInverse);J.multiplyVector3(b);return b};this.unprojectVector=function(b,c){J.multiply(c.matrixWorld,THREE.Matrix4.makeInvert(c.projectionMatrix));J.multiplyVector3(b);return b};this.projectObjects=function(b,e,j){var m,o;h=I.length=0;
|
||||
m=b.objects;b=0;for(e=m.length;b<e;b++){o=m[b];var v;if(!(v=!o.visible))if(v=o instanceof THREE.Mesh){a:{v=void 0;for(var t=o.matrixWorld,u=-o.geometry.boundingSphere.radius*Math.max(o.scale.x,Math.max(o.scale.y,o.scale.z)),p=0;p<6;p++)if(v=Y[p].x*t.n14+Y[p].y*t.n24+Y[p].z*t.n34+Y[p].w,v<=u){v=!1;break a}v=!0}v=!v}if(!v)v=k[h]=k[h]||new THREE.RenderableObject,h++,f=v,M.copy(o.position),J.multiplyVector3(M),f.object=o,f.z=M.z,I.push(f)}j&&I.sort(c);return I};this.projectScene=function(f,h,k){var I=
|
||||
h.near,M=h.far,R,aa,Z,ia,U,ea,ga,$,S,W,da,fa,la,X,ja,qa,ka;H=x=w=p=K.length=0;h.matrixAutoUpdate&&h.update(void 0,!0);f.update(void 0,!1,h);J.multiply(h.projectionMatrix,h.matrixWorldInverse);Y[0].set(J.n41-J.n11,J.n42-J.n12,J.n43-J.n13,J.n44-J.n14);Y[1].set(J.n41+J.n11,J.n42+J.n12,J.n43+J.n13,J.n44+J.n14);Y[2].set(J.n41+J.n21,J.n42+J.n22,J.n43+J.n23,J.n44+J.n24);Y[3].set(J.n41-J.n21,J.n42-J.n22,J.n43-J.n23,J.n44-J.n24);Y[4].set(J.n41-J.n31,J.n42-J.n32,J.n43-J.n33,J.n44-J.n34);Y[5].set(J.n41+J.n31,
|
||||
J.n42+J.n32,J.n43+J.n33,J.n44+J.n34);for(R=0;R<6;R++)S=Y[R],S.divideScalar(Math.sqrt(S.x*S.x+S.y*S.y+S.z*S.z));S=this.projectObjects(f,h,!0);f=0;for(R=S.length;f<R;f++)if(W=S[f].object,W.visible)if(da=W.matrixWorld,fa=W.matrixRotationWorld,la=W.materials,X=W.overdraw,m=0,W instanceof THREE.Mesh){ja=W.geometry;ia=ja.vertices;qa=ja.faces;ja=ja.faceVertexUvs;aa=0;for(Z=ia.length;aa<Z;aa++)j=b(),j.positionWorld.copy(ia[aa].position),da.multiplyVector3(j.positionWorld),j.positionScreen.copy(j.positionWorld),
|
||||
J.multiplyVector4(j.positionScreen),j.positionScreen.x/=j.positionScreen.w,j.positionScreen.y/=j.positionScreen.w,j.visible=j.positionScreen.z>I&&j.positionScreen.z<M;ia=0;for(aa=qa.length;ia<aa;ia++){Z=qa[ia];if(Z instanceof THREE.Face3)if(U=o[Z.a],ea=o[Z.b],ga=o[Z.c],U.visible&&ea.visible&&ga.visible&&(W.doubleSided||W.flipSided!=(ga.positionScreen.x-U.positionScreen.x)*(ea.positionScreen.y-U.positionScreen.y)-(ga.positionScreen.y-U.positionScreen.y)*(ea.positionScreen.x-U.positionScreen.x)<0))$=
|
||||
v[p]=v[p]||new THREE.RenderableFace3,p++,t=$,t.v1.copy(U),t.v2.copy(ea),t.v3.copy(ga);else continue;else if(Z instanceof THREE.Face4)if(U=o[Z.a],ea=o[Z.b],ga=o[Z.c],$=o[Z.d],U.visible&&ea.visible&&ga.visible&&$.visible&&(W.doubleSided||W.flipSided!=(($.positionScreen.x-U.positionScreen.x)*(ea.positionScreen.y-U.positionScreen.y)-($.positionScreen.y-U.positionScreen.y)*(ea.positionScreen.x-U.positionScreen.x)<0||(ea.positionScreen.x-ga.positionScreen.x)*($.positionScreen.y-ga.positionScreen.y)-(ea.positionScreen.y-
|
||||
ga.positionScreen.y)*($.positionScreen.x-ga.positionScreen.x)<0)))ka=u[w]=u[w]||new THREE.RenderableFace4,w++,t=ka,t.v1.copy(U),t.v2.copy(ea),t.v3.copy(ga),t.v4.copy($);else continue;t.normalWorld.copy(Z.normal);fa.multiplyVector3(t.normalWorld);t.centroidWorld.copy(Z.centroid);da.multiplyVector3(t.centroidWorld);t.centroidScreen.copy(t.centroidWorld);J.multiplyVector3(t.centroidScreen);ga=Z.vertexNormals;U=0;for(ea=ga.length;U<ea;U++)$=t.vertexNormalsWorld[U],$.copy(ga[U]),fa.multiplyVector3($);
|
||||
U=0;for(ea=ja.length;U<ea;U++)if(ka=ja[U][ia]){ga=0;for($=ka.length;ga<$;ga++)t.uvs[U][ga]=ka[ga]}t.meshMaterials=la;t.faceMaterials=Z.materials;t.overdraw=X;t.z=t.centroidScreen.z;K.push(t)}}else if(W instanceof THREE.Line){E.multiply(J,da);ia=W.geometry.vertices;U=b();U.positionScreen.copy(ia[0].position);E.multiplyVector4(U.positionScreen);aa=1;for(Z=ia.length;aa<Z;aa++)if(U=b(),U.positionScreen.copy(ia[aa].position),E.multiplyVector4(U.positionScreen),ea=o[m-2],F.copy(U.positionScreen),L.copy(ea.positionScreen),
|
||||
e(F,L))F.multiplyScalar(1/F.w),L.multiplyScalar(1/L.w),da=B[x]=B[x]||new THREE.RenderableLine,x++,y=da,y.v1.positionScreen.copy(F),y.v2.positionScreen.copy(L),y.z=Math.max(F.z,L.z),y.materials=W.materials,K.push(y)}else if(W instanceof THREE.Particle&&(C.set(W.matrixWorld.n14,W.matrixWorld.n24,W.matrixWorld.n34,1),J.multiplyVector4(C),C.z/=C.w,C.z>0&&C.z<1))da=D[H]=D[H]||new THREE.RenderableParticle,H++,z=da,z.x=C.x/C.w,z.y=C.y/C.w,z.z=C.z,z.rotation=W.rotation.z,z.scale.x=W.scale.x*Math.abs(z.x-
|
||||
(C.x+h.projectionMatrix.n11)/(C.w+h.projectionMatrix.n14)),z.scale.y=W.scale.y*Math.abs(z.y-(C.y+h.projectionMatrix.n22)/(C.w+h.projectionMatrix.n24)),z.materials=W.materials,K.push(z);k&&K.sort(c);return K}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,h,k;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;h=e/2;k=f/2};this.render=function(e,f){var o,t,p,v,w,u,y,x;b=c.projectScene(e,f);o=0;for(t=b.length;o<t;o++)if(w=b[o],w instanceof THREE.RenderableParticle){y=w.x*h+h;x=w.y*k+k;p=0;for(v=w.material.length;p<v;p++)if(u=w.material[p],u instanceof THREE.ParticleDOMMaterial)u=u.domElement,u.style.left=y+"px",u.style.top=x+"px"}}};
|
||||
THREE.CanvasRenderer=function(b){function c(b){if(B!=b)u.globalAlpha=B=b}function e(b){if(z!=b){switch(b){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}z=b}}function f(b){if(H!=b)u.strokeStyle=H=b}function h(b){if(D!=b)u.fillStyle=D=b}var k=this,j=null,m=new THREE.Projector,b=b||{},o=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
|
||||
t,p,v,w,u=o.getContext("2d"),y=new THREE.Color(0),x=0,B=1,z=0,H=null,D=null,I=null,K=null,M=null,C,J,E,Y,F=new THREE.RenderableVertex,L=new THREE.RenderableVertex,N,P,n,V,ha,R,aa,Z,ia,U,ea,ga,$=new THREE.Color(0),S=new THREE.Color(0),W=new THREE.Color(0),da=new THREE.Color(0),fa=new THREE.Color(0),la=[],X,ja,qa,ka,ma,Ga,za,Ja,Ka,Ua,ra=new THREE.Rectangle,na=new THREE.Rectangle,ca=new THREE.Rectangle,ya=!1,wa=new THREE.Color,oa=new THREE.Color,Ea=new THREE.Color,Ha=new THREE.Color,ta=new THREE.Vector3,
|
||||
T,Ba,sa,Aa,Xa,Ca,b=16;T=document.createElement("canvas");T.width=T.height=2;Ba=T.getContext("2d");Ba.fillStyle="rgba(0,0,0,1)";Ba.fillRect(0,0,2,2);sa=Ba.getImageData(0,0,2,2);Aa=sa.data;Xa=document.createElement("canvas");Xa.width=Xa.height=b;Ca=Xa.getContext("2d");Ca.translate(-b/2,-b/2);Ca.scale(b,b);b--;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(b,c){t=b;p=c;v=Math.floor(t/2);w=Math.floor(p/2);o.width=t;o.height=
|
||||
p;ra.set(-v,-w,v,w);na.set(-v,-w,v,w);B=1;z=0;M=K=I=D=H=null};this.setClearColor=function(b,c){y.copy(b);x=c;na.set(-v,-w,v,w)};this.setClearColorHex=function(b,c){y.setHex(b);x=c;na.set(-v,-w,v,w)};this.clear=function(){u.setTransform(1,0,0,-1,v,w);na.isEmpty()||(na.minSelf(ra),na.inflate(2),x<1&&u.clearRect(Math.floor(na.getX()),Math.floor(na.getY()),Math.floor(na.getWidth()),Math.floor(na.getHeight())),x>0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+
|
||||
Math.floor(y.b*255)+","+x+")"),u.fillRect(Math.floor(na.getX()),Math.floor(na.getY()),Math.floor(na.getWidth()),Math.floor(na.getHeight()))),na.empty())};this.render=function(b,o){function t(b){var c,e,f,j=b.lights;oa.setRGB(0,0,0);Ea.setRGB(0,0,0);Ha.setRGB(0,0,0);b=0;for(c=j.length;b<c;b++)e=j[b],f=e.color,e instanceof THREE.AmbientLight?(oa.r+=f.r,oa.g+=f.g,oa.b+=f.b):e instanceof THREE.DirectionalLight?(Ea.r+=f.r,Ea.g+=f.g,Ea.b+=f.b):e instanceof THREE.PointLight&&(Ha.r+=f.r,Ha.g+=f.g,Ha.b+=f.b)}
|
||||
function p(b,c,e,f){var j,h,k,m,n=b.lights,b=0;for(j=n.length;b<j;b++)h=n[b],k=h.color,h instanceof THREE.DirectionalLight?(m=e.dot(h.position),m<=0||(m*=h.intensity,f.r+=k.r*m,f.g+=k.g*m,f.b+=k.b*m)):h instanceof THREE.PointLight&&(m=e.dot(ta.sub(h.position,c).normalize()),m<=0||(m*=h.distance==0?1:1-Math.min(c.distanceTo(h.position)/h.distance,1),m!=0&&(m*=h.intensity,f.r+=k.r*m,f.g+=k.g*m,f.b+=k.b*m)))}function y(b,j,k){c(k.opacity);e(k.blending);var m,n,o,t,sa,p;if(k instanceof THREE.ParticleBasicMaterial){if(k.map)t=
|
||||
k.map.image,sa=t.width>>1,p=t.height>>1,k=j.scale.x*v,o=j.scale.y*w,m=k*sa,n=o*p,ca.set(b.x-m,b.y-n,b.x+m,b.y+n),ra.instersects(ca)&&(u.save(),u.translate(b.x,b.y),u.rotate(-j.rotation),u.scale(k,-o),u.translate(-sa,-p),u.drawImage(t,0,0),u.restore())}else k instanceof THREE.ParticleCanvasMaterial&&(m=j.scale.x*v,n=j.scale.y*w,ca.set(b.x-m,b.y-n,b.x+m,b.y+n),ra.instersects(ca)&&(f(k.color.getContextStyle()),h(k.color.getContextStyle()),u.save(),u.translate(b.x,b.y),u.rotate(-j.rotation),u.scale(m,
|
||||
n),k.program(u),u.restore()))}function x(b,j,h,k){c(k.opacity);e(k.blending);u.beginPath();u.moveTo(b.positionScreen.x,b.positionScreen.y);u.lineTo(j.positionScreen.x,j.positionScreen.y);u.closePath();if(k instanceof THREE.LineBasicMaterial){b=k.linewidth;if(I!=b)u.lineWidth=I=b;b=k.linecap;if(K!=b)u.lineCap=K=b;b=k.linejoin;if(M!=b)u.lineJoin=M=b;f(k.color.getContextStyle());u.stroke();ca.inflate(k.linewidth*2)}}function B(b,f,j,h,m,v,t,u,sa){k.data.vertices+=3;k.data.faces++;c(u.opacity);e(u.blending);
|
||||
N=b.positionScreen.x;P=b.positionScreen.y;n=f.positionScreen.x;V=f.positionScreen.y;ha=j.positionScreen.x;R=j.positionScreen.y;D(N,P,n,V,ha,R);if(u instanceof THREE.MeshBasicMaterial)if(u.map)u.map.mapping instanceof THREE.UVMapping&&(ka=t.uvs[0],$a(N,P,n,V,ha,R,ka[h].u,ka[h].v,ka[m].u,ka[m].v,ka[v].u,ka[v].v,u.map));else if(u.envMap){if(u.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=o.matrixWorldInverse,ta.copy(t.vertexNormalsWorld[0]),ma=(ta.x*b.n11+ta.y*b.n12+ta.z*b.n13)*0.5+0.5,
|
||||
Ga=-(ta.x*b.n21+ta.y*b.n22+ta.z*b.n23)*0.5+0.5,ta.copy(t.vertexNormalsWorld[1]),za=(ta.x*b.n11+ta.y*b.n12+ta.z*b.n13)*0.5+0.5,Ja=-(ta.x*b.n21+ta.y*b.n22+ta.z*b.n23)*0.5+0.5,ta.copy(t.vertexNormalsWorld[2]),Ka=(ta.x*b.n11+ta.y*b.n12+ta.z*b.n13)*0.5+0.5,Ua=-(ta.x*b.n21+ta.y*b.n22+ta.z*b.n23)*0.5+0.5,$a(N,P,n,V,ha,R,ma,Ga,za,Ja,Ka,Ua,u.envMap)}else u.wireframe?La(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color);else if(u instanceof THREE.MeshLambertMaterial)u.map&&!u.wireframe&&
|
||||
(u.map.mapping instanceof THREE.UVMapping&&(ka=t.uvs[0],$a(N,P,n,V,ha,R,ka[h].u,ka[h].v,ka[m].u,ka[m].v,ka[v].u,ka[v].v,u.map)),e(THREE.SubtractiveBlending)),ya?!u.wireframe&&u.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==3?(S.r=W.r=da.r=oa.r,S.g=W.g=da.g=oa.g,S.b=W.b=da.b=oa.b,p(sa,t.v1.positionWorld,t.vertexNormalsWorld[0],S),p(sa,t.v2.positionWorld,t.vertexNormalsWorld[1],W),p(sa,t.v3.positionWorld,t.vertexNormalsWorld[2],da),fa.r=(W.r+da.r)*0.5,fa.g=(W.g+da.g)*0.5,fa.b=(W.b+da.b)*
|
||||
0.5,qa=Ya(S,W,da,fa),Va(N,P,n,V,ha,R,0,0,1,0,0,1,qa)):(wa.r=oa.r,wa.g=oa.g,wa.b=oa.b,p(sa,t.centroidWorld,t.normalWorld,wa),$.r=Math.max(0,Math.min(u.color.r*wa.r,1)),$.g=Math.max(0,Math.min(u.color.g*wa.g,1)),$.b=Math.max(0,Math.min(u.color.b*wa.b,1)),u.wireframe?La($,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma($)):u.wireframe?La(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color);else if(u instanceof THREE.MeshDepthMaterial)X=o.near,ja=o.far,S.r=
|
||||
S.g=S.b=1-Pa(b.positionScreen.z,X,ja),W.r=W.g=W.b=1-Pa(f.positionScreen.z,X,ja),da.r=da.g=da.b=1-Pa(j.positionScreen.z,X,ja),fa.r=(W.r+da.r)*0.5,fa.g=(W.g+da.g)*0.5,fa.b=(W.b+da.b)*0.5,qa=Ya(S,W,da,fa),Va(N,P,n,V,ha,R,0,0,1,0,0,1,qa);else if(u instanceof THREE.MeshNormalMaterial)$.r=Wa(t.normalWorld.x),$.g=Wa(t.normalWorld.y),$.b=Wa(t.normalWorld.z),u.wireframe?La($,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma($)}function z(b,f,j,h,m,v,t,u,sa){k.data.vertices+=4;k.data.faces++;
|
||||
c(u.opacity);e(u.blending);if(u.map||u.envMap)B(b,f,h,0,1,3,t,u,sa),B(m,j,v,1,2,3,t,u,sa);else if(N=b.positionScreen.x,P=b.positionScreen.y,n=f.positionScreen.x,V=f.positionScreen.y,ha=j.positionScreen.x,R=j.positionScreen.y,aa=h.positionScreen.x,Z=h.positionScreen.y,ia=m.positionScreen.x,U=m.positionScreen.y,ea=v.positionScreen.x,ga=v.positionScreen.y,u instanceof THREE.MeshBasicMaterial)H(N,P,n,V,ha,R,aa,Z),u.wireframe?La(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color);
|
||||
else if(u instanceof THREE.MeshLambertMaterial)ya?!u.wireframe&&u.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==4?(S.r=W.r=da.r=fa.r=oa.r,S.g=W.g=da.g=fa.g=oa.g,S.b=W.b=da.b=fa.b=oa.b,p(sa,t.v1.positionWorld,t.vertexNormalsWorld[0],S),p(sa,t.v2.positionWorld,t.vertexNormalsWorld[1],W),p(sa,t.v4.positionWorld,t.vertexNormalsWorld[3],da),p(sa,t.v3.positionWorld,t.vertexNormalsWorld[2],fa),qa=Ya(S,W,da,fa),D(N,P,n,V,aa,Z),Va(N,P,n,V,aa,Z,0,0,1,0,0,1,qa),D(ia,U,ha,R,ea,ga),Va(ia,U,ha,R,ea,
|
||||
ga,1,0,1,1,0,1,qa)):(wa.r=oa.r,wa.g=oa.g,wa.b=oa.b,p(sa,t.centroidWorld,t.normalWorld,wa),$.r=Math.max(0,Math.min(u.color.r*wa.r,1)),$.g=Math.max(0,Math.min(u.color.g*wa.g,1)),$.b=Math.max(0,Math.min(u.color.b*wa.b,1)),H(N,P,n,V,ha,R,aa,Z),u.wireframe?La($,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma($)):(H(N,P,n,V,ha,R,aa,Z),u.wireframe?La(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color));else if(u instanceof THREE.MeshNormalMaterial)$.r=Wa(t.normalWorld.x),
|
||||
$.g=Wa(t.normalWorld.y),$.b=Wa(t.normalWorld.z),H(N,P,n,V,ha,R,aa,Z),u.wireframe?La($,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma($);else if(u instanceof THREE.MeshDepthMaterial)X=o.near,ja=o.far,S.r=S.g=S.b=1-Pa(b.positionScreen.z,X,ja),W.r=W.g=W.b=1-Pa(f.positionScreen.z,X,ja),da.r=da.g=da.b=1-Pa(h.positionScreen.z,X,ja),fa.r=fa.g=fa.b=1-Pa(j.positionScreen.z,X,ja),qa=Ya(S,W,da,fa),D(N,P,n,V,aa,Z),Va(N,P,n,V,aa,Z,0,0,1,0,0,1,qa),D(ia,U,ha,R,ea,ga),Va(ia,U,ha,R,ea,ga,1,0,1,1,
|
||||
0,1,qa)}function D(b,c,e,f,j,h){u.beginPath();u.moveTo(b,c);u.lineTo(e,f);u.lineTo(j,h);u.lineTo(b,c);u.closePath()}function H(b,c,e,f,j,h,k,m){u.beginPath();u.moveTo(b,c);u.lineTo(e,f);u.lineTo(j,h);u.lineTo(k,m);u.lineTo(b,c);u.closePath()}function La(b,c,e,j){if(I!=c)u.lineWidth=I=c;if(K!=e)u.lineCap=K=e;if(M!=j)u.lineJoin=M=j;f(b.getContextStyle());u.stroke();ca.inflate(c*2)}function Ma(b){h(b.getContextStyle());u.fill()}function $a(b,c,e,f,j,k,m,n,o,t,v,sa,p){if(p.image.width!=0){if(p.needsUpdate==
|
||||
!0||la[p.id]==void 0){var w=p.wrapS==THREE.RepeatWrapping,Ca=p.wrapT==THREE.RepeatWrapping;la[p.id]=u.createPattern(p.image,w&&Ca?"repeat":w&&!Ca?"repeat-x":!w&&Ca?"repeat-y":"no-repeat");p.needsUpdate=!1}h(la[p.id]);var w=p.offset.x/p.repeat.x,Ca=p.offset.y/p.repeat.y,y=(p.image.width-1)*p.repeat.x,p=(p.image.height-1)*p.repeat.y,m=(m+w)*y,n=(n+Ca)*p,o=(o+w)*y,t=(t+Ca)*p,v=(v+w)*y,sa=(sa+Ca)*p;e-=b;f-=c;j-=b;k-=c;o-=m;t-=n;v-=m;sa-=n;w=1/(o*sa-v*t);p=(sa*e-t*j)*w;t=(sa*f-t*k)*w;e=(o*j-v*e)*w;f=(o*
|
||||
k-v*f)*w;b=b-p*m-e*n;c=c-t*m-f*n;u.save();u.transform(p,t,e,f,b,c);u.fill();u.restore()}}function Va(b,c,e,f,j,h,k,m,n,o,t,v,sa){var p,w;p=sa.width-1;w=sa.height-1;k*=p;m*=w;n*=p;o*=w;t*=p;v*=w;e-=b;f-=c;j-=b;h-=c;n-=k;o-=m;t-=k;v-=m;w=1/(n*v-t*o);p=(v*e-o*j)*w;o=(v*f-o*h)*w;e=(n*j-t*e)*w;f=(n*h-t*f)*w;b=b-p*k-e*m;c=c-o*k-f*m;u.save();u.transform(p,o,e,f,b,c);u.clip();u.drawImage(sa,0,0);u.restore()}function Ya(b,c,e,f){var j=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),k=~~(c.r*255),m=~~(c.g*255),c=~~(c.b*
|
||||
255),n=~~(e.r*255),o=~~(e.g*255),e=~~(e.b*255),u=~~(f.r*255),t=~~(f.g*255),f=~~(f.b*255);Aa[0]=j<0?0:j>255?255:j;Aa[1]=h<0?0:h>255?255:h;Aa[2]=b<0?0:b>255?255:b;Aa[4]=k<0?0:k>255?255:k;Aa[5]=m<0?0:m>255?255:m;Aa[6]=c<0?0:c>255?255:c;Aa[8]=n<0?0:n>255?255:n;Aa[9]=o<0?0:o>255?255:o;Aa[10]=e<0?0:e>255?255:e;Aa[12]=u<0?0:u>255?255:u;Aa[13]=t<0?0:t>255?255:t;Aa[14]=f<0?0:f>255?255:f;Ba.putImageData(sa,0,0);Ca.drawImage(T,0,0);return Xa}function Pa(b,c,e){b=(b-c)/(e-c);return b*b*(3-2*b)}function Wa(b){b=
|
||||
(b+1)*0.5;return b<0?0:b>1?1:b}function Na(b,c){var e=c.x-b.x,f=c.y-b.y,j=e*e+f*f;j!=0&&(j=1/Math.sqrt(j),e*=j,f*=j,c.x+=e,c.y+=f,b.x-=e,b.y-=f)}var Za,ab,pa,Da,Oa,G,A,O;this.autoClear?this.clear():u.setTransform(1,0,0,-1,v,w);k.data.vertices=0;k.data.faces=0;j=m.projectScene(b,o,this.sortElements);(ya=b.lights.length>0)&&t(b);Za=0;for(ab=j.length;Za<ab;Za++){pa=j[Za];ca.empty();if(pa instanceof THREE.RenderableParticle){C=pa;C.x*=v;C.y*=w;Da=0;for(Oa=pa.materials.length;Da<Oa;)O=pa.materials[Da++],
|
||||
O.opacity!=0&&y(C,pa,O,b)}else if(pa instanceof THREE.RenderableLine){if(C=pa.v1,J=pa.v2,C.positionScreen.x*=v,C.positionScreen.y*=w,J.positionScreen.x*=v,J.positionScreen.y*=w,ca.addPoint(C.positionScreen.x,C.positionScreen.y),ca.addPoint(J.positionScreen.x,J.positionScreen.y),ra.instersects(ca)){Da=0;for(Oa=pa.materials.length;Da<Oa;)O=pa.materials[Da++],O.opacity!=0&&x(C,J,pa,O,b)}}else if(pa instanceof THREE.RenderableFace3){if(C=pa.v1,J=pa.v2,E=pa.v3,C.positionScreen.x*=v,C.positionScreen.y*=
|
||||
w,J.positionScreen.x*=v,J.positionScreen.y*=w,E.positionScreen.x*=v,E.positionScreen.y*=w,pa.overdraw&&(Na(C.positionScreen,J.positionScreen),Na(J.positionScreen,E.positionScreen),Na(E.positionScreen,C.positionScreen)),ca.add3Points(C.positionScreen.x,C.positionScreen.y,J.positionScreen.x,J.positionScreen.y,E.positionScreen.x,E.positionScreen.y),ra.instersects(ca)){Da=0;for(Oa=pa.meshMaterials.length;Da<Oa;)if(O=pa.meshMaterials[Da++],O instanceof THREE.MeshFaceMaterial){G=0;for(A=pa.faceMaterials.length;G<
|
||||
A;)(O=pa.faceMaterials[G++])&&O.opacity!=0&&B(C,J,E,0,1,2,pa,O,b)}else O.opacity!=0&&B(C,J,E,0,1,2,pa,O,b)}}else if(pa instanceof THREE.RenderableFace4&&(C=pa.v1,J=pa.v2,E=pa.v3,Y=pa.v4,C.positionScreen.x*=v,C.positionScreen.y*=w,J.positionScreen.x*=v,J.positionScreen.y*=w,E.positionScreen.x*=v,E.positionScreen.y*=w,Y.positionScreen.x*=v,Y.positionScreen.y*=w,F.positionScreen.copy(J.positionScreen),L.positionScreen.copy(Y.positionScreen),pa.overdraw&&(Na(C.positionScreen,J.positionScreen),Na(J.positionScreen,
|
||||
Y.positionScreen),Na(Y.positionScreen,C.positionScreen),Na(E.positionScreen,F.positionScreen),Na(E.positionScreen,L.positionScreen)),ca.addPoint(C.positionScreen.x,C.positionScreen.y),ca.addPoint(J.positionScreen.x,J.positionScreen.y),ca.addPoint(E.positionScreen.x,E.positionScreen.y),ca.addPoint(Y.positionScreen.x,Y.positionScreen.y),ra.instersects(ca))){Da=0;for(Oa=pa.meshMaterials.length;Da<Oa;)if(O=pa.meshMaterials[Da++],O instanceof THREE.MeshFaceMaterial){G=0;for(A=pa.faceMaterials.length;G<
|
||||
A;)(O=pa.faceMaterials[G++])&&O.opacity!=0&&z(C,J,E,Y,F,L,pa,O,b)}else O.opacity!=0&&z(C,J,E,Y,F,L,pa,O,b)}na.addRectangle(ca)}u.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function b(b,c,e){var f,j,h,k;f=0;for(j=b.lights.length;f<j;f++)h=b.lights[f],h instanceof THREE.DirectionalLight?(k=c.normalWorld.dot(h.position)*h.intensity,k>0&&(e.r+=h.color.r*k,e.g+=h.color.g*k,e.b+=h.color.b*k)):h instanceof THREE.PointLight&&(Y.sub(h.position,c.centroidWorld),Y.normalize(),k=c.normalWorld.dot(Y)*h.intensity,k>0&&(e.r+=h.color.r*k,e.g+=h.color.g*k,e.b+=h.color.b*k))}function c(c,e,j,m,n,u){k.data.vertices+=3;k.data.faces++;N=f(P++);N.setAttribute("d",
|
||||
"M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?I.copy(n.color):n instanceof THREE.MeshLambertMaterial?D?(K.r=M.r,K.g=M.g,K.b=M.b,b(u,m,K),I.r=Math.max(0,Math.min(n.color.r*K.r,1)),I.g=Math.max(0,Math.min(n.color.g*K.g,1)),I.b=Math.max(0,Math.min(n.color.b*K.b,1))):I.copy(n.color):n instanceof THREE.MeshDepthMaterial?(E=1-n.__2near/(n.__farPlusNear-m.z*n.__farMinusNear),
|
||||
I.setRGB(E,E,E)):n instanceof THREE.MeshNormalMaterial&&I.setRGB(h(m.normalWorld.x),h(m.normalWorld.y),h(m.normalWorld.z));n.wireframe?N.setAttribute("style","fill: none; stroke: "+I.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):N.setAttribute("style","fill: "+I.getContextStyle()+"; fill-opacity: "+n.opacity);o.appendChild(N)}function e(c,e,j,m,n,u,t){k.data.vertices+=4;k.data.faces++;
|
||||
N=f(P++);N.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");u instanceof THREE.MeshBasicMaterial?I.copy(u.color):u instanceof THREE.MeshLambertMaterial?D?(K.r=M.r,K.g=M.g,K.b=M.b,b(t,n,K),I.r=Math.max(0,Math.min(u.color.r*K.r,1)),I.g=Math.max(0,Math.min(u.color.g*K.g,1)),I.b=Math.max(0,Math.min(u.color.b*K.b,1))):I.copy(u.color):u instanceof
|
||||
THREE.MeshDepthMaterial?(E=1-u.__2near/(u.__farPlusNear-n.z*u.__farMinusNear),I.setRGB(E,E,E)):u instanceof THREE.MeshNormalMaterial&&I.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));u.wireframe?N.setAttribute("style","fill: none; stroke: "+I.getContextStyle()+"; stroke-width: "+u.wireframeLinewidth+"; stroke-opacity: "+u.opacity+"; stroke-linecap: "+u.wireframeLinecap+"; stroke-linejoin: "+u.wireframeLinejoin):N.setAttribute("style","fill: "+I.getContextStyle()+"; fill-opacity: "+
|
||||
u.opacity);o.appendChild(N)}function f(b){F[b]==null&&(F[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),V==0&&F[b].setAttribute("shape-rendering","crispEdges"));return F[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var k=this,j=null,m=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),t,p,v,w,u,y,x,B,z=new THREE.Rectangle,H=new THREE.Rectangle,D=!1,I=new THREE.Color(16777215),K=new THREE.Color(16777215),M=new THREE.Color(0),C=new THREE.Color(0),
|
||||
J=new THREE.Color(0),E,Y=new THREE.Vector3,F=[],L=[],N,P,n,V=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":V=1;break;case "low":V=0}};this.setSize=function(b,c){t=b;p=c;v=t/2;w=p/2;o.setAttribute("viewBox",-v+" "+-w+" "+t+" "+p);o.setAttribute("width",t);o.setAttribute("height",p);z.set(-v,-w,v,w)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=
|
||||
function(b,f){var h,t,p,I,K,F,E,S;this.autoClear&&this.clear();k.data.vertices=0;k.data.faces=0;j=m.projectScene(b,f,this.sortElements);n=P=0;if(D=b.lights.length>0){E=b.lights;M.setRGB(0,0,0);C.setRGB(0,0,0);J.setRGB(0,0,0);h=0;for(t=E.length;h<t;h++)p=E[h],I=p.color,p instanceof THREE.AmbientLight?(M.r+=I.r,M.g+=I.g,M.b+=I.b):p instanceof THREE.DirectionalLight?(C.r+=I.r,C.g+=I.g,C.b+=I.b):p instanceof THREE.PointLight&&(J.r+=I.r,J.g+=I.g,J.b+=I.b)}h=0;for(t=j.length;h<t;h++)if(E=j[h],H.empty(),
|
||||
E instanceof THREE.RenderableParticle){u=E;u.x*=v;u.y*=-w;p=0;for(I=E.materials.length;p<I;)p++}else if(E instanceof THREE.RenderableLine){if(u=E.v1,y=E.v2,u.positionScreen.x*=v,u.positionScreen.y*=-w,y.positionScreen.x*=v,y.positionScreen.y*=-w,H.addPoint(u.positionScreen.x,u.positionScreen.y),H.addPoint(y.positionScreen.x,y.positionScreen.y),z.instersects(H)){p=0;for(I=E.materials.length;p<I;)if((S=E.materials[p++])&&S.opacity!=0){K=u;F=y;var W=n++;L[W]==null&&(L[W]=document.createElementNS("http://www.w3.org/2000/svg",
|
||||
"line"),V==0&&L[W].setAttribute("shape-rendering","crispEdges"));N=L[W];N.setAttribute("x1",K.positionScreen.x);N.setAttribute("y1",K.positionScreen.y);N.setAttribute("x2",F.positionScreen.x);N.setAttribute("y2",F.positionScreen.y);S instanceof THREE.LineBasicMaterial&&(N.setAttribute("style","fill: none; stroke: "+S.color.getContextStyle()+"; stroke-width: "+S.linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.linecap+"; stroke-linejoin: "+S.linejoin),o.appendChild(N))}}}else if(E instanceof
|
||||
THREE.RenderableFace3){if(u=E.v1,y=E.v2,x=E.v3,u.positionScreen.x*=v,u.positionScreen.y*=-w,y.positionScreen.x*=v,y.positionScreen.y*=-w,x.positionScreen.x*=v,x.positionScreen.y*=-w,H.addPoint(u.positionScreen.x,u.positionScreen.y),H.addPoint(y.positionScreen.x,y.positionScreen.y),H.addPoint(x.positionScreen.x,x.positionScreen.y),z.instersects(H)){p=0;for(I=E.meshMaterials.length;p<I;)if(S=E.meshMaterials[p++],S instanceof THREE.MeshFaceMaterial){K=0;for(F=E.faceMaterials.length;K<F;)(S=E.faceMaterials[K++])&&
|
||||
S.opacity!=0&&c(u,y,x,E,S,b)}else S&&S.opacity!=0&&c(u,y,x,E,S,b)}}else if(E instanceof THREE.RenderableFace4&&(u=E.v1,y=E.v2,x=E.v3,B=E.v4,u.positionScreen.x*=v,u.positionScreen.y*=-w,y.positionScreen.x*=v,y.positionScreen.y*=-w,x.positionScreen.x*=v,x.positionScreen.y*=-w,B.positionScreen.x*=v,B.positionScreen.y*=-w,H.addPoint(u.positionScreen.x,u.positionScreen.y),H.addPoint(y.positionScreen.x,y.positionScreen.y),H.addPoint(x.positionScreen.x,x.positionScreen.y),H.addPoint(B.positionScreen.x,B.positionScreen.y),
|
||||
z.instersects(H))){p=0;for(I=E.meshMaterials.length;p<I;)if(S=E.meshMaterials[p++],S instanceof THREE.MeshFaceMaterial){K=0;for(F=E.faceMaterials.length;K<F;)(S=E.faceMaterials[K++])&&S.opacity!=0&&e(u,y,x,B,E,S,b)}else S&&S.opacity!=0&&e(u,y,x,B,E,S,b)}}};
|
||||
THREE.Projector=function(){function b(){var b=p[m]=p[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,h=e.z+e.w,k=-b.z+b.w,m=-e.z+e.w;return j>=0&&h>=0&&k>=0&&m>=0?!0:j<0&&h<0||k<0&&m<0?!1:(j<0?c=Math.max(c,j/(j-h)):h<0&&(f=Math.min(f,j/(j-h))),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,h,k=[],j,m,p=[],o,t,v=[],w,u=[],y,x,B=[],z,D,C=[],E=[],J=[],O=new THREE.Vector4,K=new THREE.Vector4,
|
||||
I=new THREE.Matrix4,F=new THREE.Matrix4,Y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],G=new THREE.Vector4,M=new THREE.Vector4;this.projectVector=function(b,e){I.multiply(e.projectionMatrix,e.matrixWorldInverse);I.multiplyVector3(b);return b};this.unprojectVector=function(b,e){I.multiply(e.matrixWorld,THREE.Matrix4.makeInvert(e.projectionMatrix));I.multiplyVector3(b);return b};this.projectObjects=function(b,e,j){var m,p;h=E.length=0;
|
||||
m=b.objects;b=0;for(e=m.length;b<e;b++){p=m[b];var v;if(!(v=!p.visible))if(v=p instanceof THREE.Mesh){a:{v=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)),t=0;t<6;t++)if(v=Y[t].x*o.n14+Y[t].y*o.n24+Y[t].z*o.n34+Y[t].w,v<=u){v=!1;break a}v=!0}v=!v}if(!v)v=k[h]=k[h]||new THREE.RenderableObject,h++,f=v,O.copy(p.position),I.multiplyVector3(O),f.object=p,f.z=O.z,E.push(f)}j&&E.sort(c);return E};this.projectScene=function(f,h,k){var E=
|
||||
h.near,O=h.far,Q,da,$,ka,U,aa,ja,ha,X,ca,ga,ia,ma,Z,N,ra,la;D=x=w=t=J.length=0;h.matrixAutoUpdate&&h.update(void 0,!0);f.update(void 0,!1,h);I.multiply(h.projectionMatrix,h.matrixWorldInverse);Y[0].set(I.n41-I.n11,I.n42-I.n12,I.n43-I.n13,I.n44-I.n14);Y[1].set(I.n41+I.n11,I.n42+I.n12,I.n43+I.n13,I.n44+I.n14);Y[2].set(I.n41+I.n21,I.n42+I.n22,I.n43+I.n23,I.n44+I.n24);Y[3].set(I.n41-I.n21,I.n42-I.n22,I.n43-I.n23,I.n44-I.n24);Y[4].set(I.n41-I.n31,I.n42-I.n32,I.n43-I.n33,I.n44-I.n34);Y[5].set(I.n41+I.n31,
|
||||
I.n42+I.n32,I.n43+I.n33,I.n44+I.n34);for(Q=0;Q<6;Q++)X=Y[Q],X.divideScalar(Math.sqrt(X.x*X.x+X.y*X.y+X.z*X.z));X=this.projectObjects(f,h,!0);f=0;for(Q=X.length;f<Q;f++)if(ca=X[f].object,ca.visible)if(ga=ca.matrixWorld,ia=ca.matrixRotationWorld,ma=ca.materials,Z=ca.overdraw,m=0,ca instanceof THREE.Mesh){N=ca.geometry;ka=N.vertices;ra=N.faces;N=N.faceVertexUvs;da=0;for($=ka.length;da<$;da++)j=b(),j.positionWorld.copy(ka[da].position),ga.multiplyVector3(j.positionWorld),j.positionScreen.copy(j.positionWorld),
|
||||
I.multiplyVector4(j.positionScreen),j.positionScreen.x/=j.positionScreen.w,j.positionScreen.y/=j.positionScreen.w,j.visible=j.positionScreen.z>E&&j.positionScreen.z<O;ka=0;for(da=ra.length;ka<da;ka++){$=ra[ka];if($ instanceof THREE.Face3)if(U=p[$.a],aa=p[$.b],ja=p[$.c],U.visible&&aa.visible&&ja.visible&&(ca.doubleSided||ca.flipSided!=(ja.positionScreen.x-U.positionScreen.x)*(aa.positionScreen.y-U.positionScreen.y)-(ja.positionScreen.y-U.positionScreen.y)*(aa.positionScreen.x-U.positionScreen.x)<0))ha=
|
||||
v[t]=v[t]||new THREE.RenderableFace3,t++,o=ha,o.v1.copy(U),o.v2.copy(aa),o.v3.copy(ja);else continue;else if($ instanceof THREE.Face4)if(U=p[$.a],aa=p[$.b],ja=p[$.c],ha=p[$.d],U.visible&&aa.visible&&ja.visible&&ha.visible&&(ca.doubleSided||ca.flipSided!=((ha.positionScreen.x-U.positionScreen.x)*(aa.positionScreen.y-U.positionScreen.y)-(ha.positionScreen.y-U.positionScreen.y)*(aa.positionScreen.x-U.positionScreen.x)<0||(aa.positionScreen.x-ja.positionScreen.x)*(ha.positionScreen.y-ja.positionScreen.y)-
|
||||
(aa.positionScreen.y-ja.positionScreen.y)*(ha.positionScreen.x-ja.positionScreen.x)<0)))la=u[w]=u[w]||new THREE.RenderableFace4,w++,o=la,o.v1.copy(U),o.v2.copy(aa),o.v3.copy(ja),o.v4.copy(ha);else continue;o.normalWorld.copy($.normal);ia.multiplyVector3(o.normalWorld);o.centroidWorld.copy($.centroid);ga.multiplyVector3(o.centroidWorld);o.centroidScreen.copy(o.centroidWorld);I.multiplyVector3(o.centroidScreen);ja=$.vertexNormals;U=0;for(aa=ja.length;U<aa;U++)ha=o.vertexNormalsWorld[U],ha.copy(ja[U]),
|
||||
ia.multiplyVector3(ha);U=0;for(aa=N.length;U<aa;U++)if(la=N[U][ka]){ja=0;for(ha=la.length;ja<ha;ja++)o.uvs[U][ja]=la[ja]}o.meshMaterials=ma;o.faceMaterials=$.materials;o.overdraw=Z;o.z=o.centroidScreen.z;J.push(o)}}else if(ca instanceof THREE.Line){F.multiply(I,ga);ka=ca.geometry.vertices;U=b();U.positionScreen.copy(ka[0].position);F.multiplyVector4(U.positionScreen);da=1;for($=ka.length;da<$;da++)if(U=b(),U.positionScreen.copy(ka[da].position),F.multiplyVector4(U.positionScreen),aa=p[m-2],G.copy(U.positionScreen),
|
||||
M.copy(aa.positionScreen),e(G,M))G.multiplyScalar(1/G.w),M.multiplyScalar(1/M.w),ga=B[x]=B[x]||new THREE.RenderableLine,x++,y=ga,y.v1.positionScreen.copy(G),y.v2.positionScreen.copy(M),y.z=Math.max(G.z,M.z),y.materials=ca.materials,J.push(y)}else if(ca instanceof THREE.Particle&&(K.set(ca.matrixWorld.n14,ca.matrixWorld.n24,ca.matrixWorld.n34,1),I.multiplyVector4(K),K.z/=K.w,K.z>0&&K.z<1))ga=C[D]=C[D]||new THREE.RenderableParticle,D++,z=ga,z.x=K.x/K.w,z.y=K.y/K.w,z.z=K.z,z.rotation=ca.rotation.z,z.scale.x=
|
||||
ca.scale.x*Math.abs(z.x-(K.x+h.projectionMatrix.n11)/(K.w+h.projectionMatrix.n14)),z.scale.y=ca.scale.y*Math.abs(z.y-(K.y+h.projectionMatrix.n22)/(K.w+h.projectionMatrix.n24)),z.materials=ca.materials,J.push(z);k&&J.sort(c);return J}};
|
||||
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,h,k;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;h=e/2;k=f/2};this.render=function(e,f){var p,o,t,v,w,u,y,x;b=c.projectScene(e,f);p=0;for(o=b.length;p<o;p++)if(w=b[p],w instanceof THREE.RenderableParticle){y=w.x*h+h;x=w.y*k+k;t=0;for(v=w.material.length;t<v;t++)if(u=w.material[t],u instanceof THREE.ParticleDOMMaterial)u=u.domElement,u.style.left=y+"px",u.style.top=x+"px"}}};
|
||||
THREE.CanvasRenderer=function(b){function c(b){if(B!=b)u.globalAlpha=B=b}function e(b){if(z!=b){switch(b){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}z=b}}function f(b){if(D!=b)u.strokeStyle=D=b}function h(b){if(C!=b)u.fillStyle=C=b}var k=this,j=null,m=new THREE.Projector,b=b||{},p=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
|
||||
o,t,v,w,u=p.getContext("2d"),y=new THREE.Color(0),x=0,B=1,z=0,D=null,C=null,E=null,J=null,O=null,K,I,F,Y,G=new THREE.RenderableVertex,M=new THREE.RenderableVertex,L,S,n,V,fa,Q,da,$,ka,U,aa,ja,ha=new THREE.Color(0),X=new THREE.Color(0),ca=new THREE.Color(0),ga=new THREE.Color(0),ia=new THREE.Color(0),ma=[],Z,N,ra,la,sa,Ha,oa,va,Ja,Da,pa=new THREE.Rectangle,ta=new THREE.Rectangle,ea=new THREE.Rectangle,ya=!1,xa=new THREE.Color,wa=new THREE.Color,Ea=new THREE.Color,Fa=new THREE.Color,na=new THREE.Vector3,
|
||||
T,Aa,W,za,Va,Ba,b=16;T=document.createElement("canvas");T.width=T.height=2;Aa=T.getContext("2d");Aa.fillStyle="rgba(0,0,0,1)";Aa.fillRect(0,0,2,2);W=Aa.getImageData(0,0,2,2);za=W.data;Va=document.createElement("canvas");Va.width=Va.height=b;Ba=Va.getContext("2d");Ba.translate(-b/2,-b/2);Ba.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;v=Math.floor(o/2);w=Math.floor(t/2);p.width=o;p.height=t;pa.set(-v,
|
||||
-w,v,w);ta.set(-v,-w,v,w);B=1;z=0;O=J=E=C=D=null};this.setClearColor=function(b,e){y.copy(b);x=e;ta.set(-v,-w,v,w)};this.setClearColorHex=function(b,e){y.setHex(b);x=e;ta.set(-v,-w,v,w)};this.clear=function(){u.setTransform(1,0,0,-1,v,w);ta.isEmpty()||(ta.minSelf(pa),ta.inflate(2),x<1&&u.clearRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight())),x>0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*
|
||||
255)+","+x+")"),u.fillRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight()))),ta.empty())};this.render=function(b,p){function o(b){var e,c,f,j=b.lights;wa.setRGB(0,0,0);Ea.setRGB(0,0,0);Fa.setRGB(0,0,0);b=0;for(e=j.length;b<e;b++)c=j[b],f=c.color,c instanceof THREE.AmbientLight?(wa.r+=f.r,wa.g+=f.g,wa.b+=f.b):c instanceof THREE.DirectionalLight?(Ea.r+=f.r,Ea.g+=f.g,Ea.b+=f.b):c instanceof THREE.PointLight&&(Fa.r+=f.r,Fa.g+=f.g,Fa.b+=f.b)}function t(b,
|
||||
e,c,f){var j,h,k,n,m=b.lights,b=0;for(j=m.length;b<j;b++)h=m[b],k=h.color,h instanceof THREE.DirectionalLight?(n=c.dot(h.position),n<=0||(n*=h.intensity,f.r+=k.r*n,f.g+=k.g*n,f.b+=k.b*n)):h instanceof THREE.PointLight&&(n=c.dot(na.sub(h.position,e).normalize()),n<=0||(n*=h.distance==0?1:1-Math.min(e.distanceTo(h.position)/h.distance,1),n!=0&&(n*=h.intensity,f.r+=k.r*n,f.g+=k.g*n,f.b+=k.b*n)))}function y(b,j,k){c(k.opacity);e(k.blending);var n,m,p,o,W,t;if(k instanceof THREE.ParticleBasicMaterial){if(k.map)o=
|
||||
k.map.image,W=o.width>>1,t=o.height>>1,k=j.scale.x*v,p=j.scale.y*w,n=k*W,m=p*t,ea.set(b.x-n,b.y-m,b.x+n,b.y+m),pa.instersects(ea)&&(u.save(),u.translate(b.x,b.y),u.rotate(-j.rotation),u.scale(k,-p),u.translate(-W,-t),u.drawImage(o,0,0),u.restore())}else k instanceof THREE.ParticleCanvasMaterial&&(n=j.scale.x*v,m=j.scale.y*w,ea.set(b.x-n,b.y-m,b.x+n,b.y+m),pa.instersects(ea)&&(f(k.color.getContextStyle()),h(k.color.getContextStyle()),u.save(),u.translate(b.x,b.y),u.rotate(-j.rotation),u.scale(n,m),
|
||||
k.program(u),u.restore()))}function B(b,j,h,k){c(k.opacity);e(k.blending);u.beginPath();u.moveTo(b.positionScreen.x,b.positionScreen.y);u.lineTo(j.positionScreen.x,j.positionScreen.y);u.closePath();if(k instanceof THREE.LineBasicMaterial){b=k.linewidth;if(E!=b)u.lineWidth=E=b;b=k.linecap;if(J!=b)u.lineCap=J=b;b=k.linejoin;if(O!=b)u.lineJoin=O=b;f(k.color.getContextStyle());u.stroke();ea.inflate(k.linewidth*2)}}function x(b,f,j,h,m,v,o,W,u){k.data.vertices+=3;k.data.faces++;c(W.opacity);e(W.blending);
|
||||
L=b.positionScreen.x;S=b.positionScreen.y;n=f.positionScreen.x;V=f.positionScreen.y;fa=j.positionScreen.x;Q=j.positionScreen.y;D(L,S,n,V,fa,Q);if(W instanceof THREE.MeshBasicMaterial)if(W.map)W.map.mapping instanceof THREE.UVMapping&&(la=o.uvs[0],Ya(L,S,n,V,fa,Q,la[h].u,la[h].v,la[m].u,la[m].v,la[v].u,la[v].v,W.map));else if(W.envMap){if(W.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=p.matrixWorldInverse,na.copy(o.vertexNormalsWorld[0]),sa=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,
|
||||
Ha=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(o.vertexNormalsWorld[1]),oa=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,va=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(o.vertexNormalsWorld[2]),Ja=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,Da=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,Ya(L,S,n,V,fa,Q,sa,Ha,oa,va,Ja,Da,W.envMap)}else W.wireframe?Ka(W.color,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):La(W.color);else if(W instanceof THREE.MeshLambertMaterial)W.map&&!W.wireframe&&
|
||||
(W.map.mapping instanceof THREE.UVMapping&&(la=o.uvs[0],Ya(L,S,n,V,fa,Q,la[h].u,la[h].v,la[m].u,la[m].v,la[v].u,la[v].v,W.map)),e(THREE.SubtractiveBlending)),ya?!W.wireframe&&W.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==3?(X.r=ca.r=ga.r=wa.r,X.g=ca.g=ga.g=wa.g,X.b=ca.b=ga.b=wa.b,t(u,o.v1.positionWorld,o.vertexNormalsWorld[0],X),t(u,o.v2.positionWorld,o.vertexNormalsWorld[1],ca),t(u,o.v3.positionWorld,o.vertexNormalsWorld[2],ga),ia.r=(ca.r+ga.r)*0.5,ia.g=(ca.g+ga.g)*0.5,ia.b=(ca.b+
|
||||
ga.b)*0.5,ra=Wa(X,ca,ga,ia),Ta(L,S,n,V,fa,Q,0,0,1,0,0,1,ra)):(xa.r=wa.r,xa.g=wa.g,xa.b=wa.b,t(u,o.centroidWorld,o.normalWorld,xa),ha.r=Math.max(0,Math.min(W.color.r*xa.r,1)),ha.g=Math.max(0,Math.min(W.color.g*xa.g,1)),ha.b=Math.max(0,Math.min(W.color.b*xa.b,1)),W.wireframe?Ka(ha,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):La(ha)):W.wireframe?Ka(W.color,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):La(W.color);else if(W instanceof THREE.MeshDepthMaterial)Z=p.near,N=
|
||||
p.far,X.r=X.g=X.b=1-Oa(b.positionScreen.z,Z,N),ca.r=ca.g=ca.b=1-Oa(f.positionScreen.z,Z,N),ga.r=ga.g=ga.b=1-Oa(j.positionScreen.z,Z,N),ia.r=(ca.r+ga.r)*0.5,ia.g=(ca.g+ga.g)*0.5,ia.b=(ca.b+ga.b)*0.5,ra=Wa(X,ca,ga,ia),Ta(L,S,n,V,fa,Q,0,0,1,0,0,1,ra);else if(W instanceof THREE.MeshNormalMaterial)ha.r=Ua(o.normalWorld.x),ha.g=Ua(o.normalWorld.y),ha.b=Ua(o.normalWorld.z),W.wireframe?Ka(ha,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):La(ha)}function z(b,f,j,h,m,v,W,o,u){k.data.vertices+=
|
||||
4;k.data.faces++;c(o.opacity);e(o.blending);if(o.map||o.envMap)x(b,f,h,0,1,3,W,o,u),x(m,j,v,1,2,3,W,o,u);else if(L=b.positionScreen.x,S=b.positionScreen.y,n=f.positionScreen.x,V=f.positionScreen.y,fa=j.positionScreen.x,Q=j.positionScreen.y,da=h.positionScreen.x,$=h.positionScreen.y,ka=m.positionScreen.x,U=m.positionScreen.y,aa=v.positionScreen.x,ja=v.positionScreen.y,o instanceof THREE.MeshBasicMaterial)C(L,S,n,V,fa,Q,da,$),o.wireframe?Ka(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):
|
||||
La(o.color);else if(o instanceof THREE.MeshLambertMaterial)ya?!o.wireframe&&o.shading==THREE.SmoothShading&&W.vertexNormalsWorld.length==4?(X.r=ca.r=ga.r=ia.r=wa.r,X.g=ca.g=ga.g=ia.g=wa.g,X.b=ca.b=ga.b=ia.b=wa.b,t(u,W.v1.positionWorld,W.vertexNormalsWorld[0],X),t(u,W.v2.positionWorld,W.vertexNormalsWorld[1],ca),t(u,W.v4.positionWorld,W.vertexNormalsWorld[3],ga),t(u,W.v3.positionWorld,W.vertexNormalsWorld[2],ia),ra=Wa(X,ca,ga,ia),D(L,S,n,V,da,$),Ta(L,S,n,V,da,$,0,0,1,0,0,1,ra),D(ka,U,fa,Q,aa,ja),Ta(ka,
|
||||
U,fa,Q,aa,ja,1,0,1,1,0,1,ra)):(xa.r=wa.r,xa.g=wa.g,xa.b=wa.b,t(u,W.centroidWorld,W.normalWorld,xa),ha.r=Math.max(0,Math.min(o.color.r*xa.r,1)),ha.g=Math.max(0,Math.min(o.color.g*xa.g,1)),ha.b=Math.max(0,Math.min(o.color.b*xa.b,1)),C(L,S,n,V,fa,Q,da,$),o.wireframe?Ka(ha,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(ha)):(C(L,S,n,V,fa,Q,da,$),o.wireframe?Ka(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(o.color));else if(o instanceof THREE.MeshNormalMaterial)ha.r=
|
||||
Ua(W.normalWorld.x),ha.g=Ua(W.normalWorld.y),ha.b=Ua(W.normalWorld.z),C(L,S,n,V,fa,Q,da,$),o.wireframe?Ka(ha,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(ha);else if(o instanceof THREE.MeshDepthMaterial)Z=p.near,N=p.far,X.r=X.g=X.b=1-Oa(b.positionScreen.z,Z,N),ca.r=ca.g=ca.b=1-Oa(f.positionScreen.z,Z,N),ga.r=ga.g=ga.b=1-Oa(h.positionScreen.z,Z,N),ia.r=ia.g=ia.b=1-Oa(j.positionScreen.z,Z,N),ra=Wa(X,ca,ga,ia),D(L,S,n,V,da,$),Ta(L,S,n,V,da,$,0,0,1,0,0,1,ra),D(ka,U,fa,Q,aa,ja),Ta(ka,
|
||||
U,fa,Q,aa,ja,1,0,1,1,0,1,ra)}function D(b,e,c,f,j,h){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(j,h);u.lineTo(b,e);u.closePath()}function C(b,e,c,f,j,h,k,n){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(j,h);u.lineTo(k,n);u.lineTo(b,e);u.closePath()}function Ka(b,e,c,j){if(E!=e)u.lineWidth=E=e;if(J!=c)u.lineCap=J=c;if(O!=j)u.lineJoin=O=j;f(b.getContextStyle());u.stroke();ea.inflate(e*2)}function La(b){h(b.getContextStyle());u.fill()}function Ya(b,e,c,f,j,k,n,m,o,W,p,v,t){if(t.image.width!=
|
||||
0){if(t.needsUpdate==!0||ma[t.id]==void 0){var w=t.wrapS==THREE.RepeatWrapping,Ba=t.wrapT==THREE.RepeatWrapping;ma[t.id]=u.createPattern(t.image,w&&Ba?"repeat":w&&!Ba?"repeat-x":!w&&Ba?"repeat-y":"no-repeat");t.needsUpdate=!1}h(ma[t.id]);var w=t.offset.x/t.repeat.x,Ba=t.offset.y/t.repeat.y,y=(t.image.width-1)*t.repeat.x,t=(t.image.height-1)*t.repeat.y,n=(n+w)*y,m=(m+Ba)*t,o=(o+w)*y,W=(W+Ba)*t,p=(p+w)*y,v=(v+Ba)*t;c-=b;f-=e;j-=b;k-=e;o-=n;W-=m;p-=n;v-=m;w=1/(o*v-p*W);t=(v*c-W*j)*w;W=(v*f-W*k)*w;c=
|
||||
(o*j-p*c)*w;f=(o*k-p*f)*w;b=b-t*n-c*m;e=e-W*n-f*m;u.save();u.transform(t,W,c,f,b,e);u.fill();u.restore()}}function Ta(b,e,c,f,j,h,k,n,m,o,W,p,v){var t,w;t=v.width-1;w=v.height-1;k*=t;n*=w;m*=t;o*=w;W*=t;p*=w;c-=b;f-=e;j-=b;h-=e;m-=k;o-=n;W-=k;p-=n;w=1/(m*p-W*o);t=(p*c-o*j)*w;o=(p*f-o*h)*w;c=(m*j-W*c)*w;f=(m*h-W*f)*w;b=b-t*k-c*n;e=e-o*k-f*n;u.save();u.transform(t,o,c,f,b,e);u.clip();u.drawImage(v,0,0);u.restore()}function Wa(b,e,c,f){var j=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),k=~~(e.r*255),n=~~(e.g*
|
||||
255),e=~~(e.b*255),m=~~(c.r*255),o=~~(c.g*255),c=~~(c.b*255),p=~~(f.r*255),v=~~(f.g*255),f=~~(f.b*255);za[0]=j<0?0:j>255?255:j;za[1]=h<0?0:h>255?255:h;za[2]=b<0?0:b>255?255:b;za[4]=k<0?0:k>255?255:k;za[5]=n<0?0:n>255?255:n;za[6]=e<0?0:e>255?255:e;za[8]=m<0?0:m>255?255:m;za[9]=o<0?0:o>255?255:o;za[10]=c<0?0:c>255?255:c;za[12]=p<0?0:p>255?255:p;za[13]=v<0?0:v>255?255:v;za[14]=f<0?0:f>255?255:f;Aa.putImageData(W,0,0);Ba.drawImage(T,0,0);return Va}function Oa(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Ua(b){b=
|
||||
(b+1)*0.5;return b<0?0:b>1?1:b}function Ma(b,e){var c=e.x-b.x,f=e.y-b.y,j=c*c+f*f;j!=0&&(j=1/Math.sqrt(j),c*=j,f*=j,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Xa,Za,qa,Ca,Na,H,A,P;this.autoClear?this.clear():u.setTransform(1,0,0,-1,v,w);k.data.vertices=0;k.data.faces=0;j=m.projectScene(b,p,this.sortElements);(ya=b.lights.length>0)&&o(b);Xa=0;for(Za=j.length;Xa<Za;Xa++){qa=j[Xa];ea.empty();if(qa instanceof THREE.RenderableParticle){K=qa;K.x*=v;K.y*=w;Ca=0;for(Na=qa.materials.length;Ca<Na;)P=qa.materials[Ca++],
|
||||
P.opacity!=0&&y(K,qa,P,b)}else if(qa instanceof THREE.RenderableLine){if(K=qa.v1,I=qa.v2,K.positionScreen.x*=v,K.positionScreen.y*=w,I.positionScreen.x*=v,I.positionScreen.y*=w,ea.addPoint(K.positionScreen.x,K.positionScreen.y),ea.addPoint(I.positionScreen.x,I.positionScreen.y),pa.instersects(ea)){Ca=0;for(Na=qa.materials.length;Ca<Na;)P=qa.materials[Ca++],P.opacity!=0&&B(K,I,qa,P,b)}}else if(qa instanceof THREE.RenderableFace3){if(K=qa.v1,I=qa.v2,F=qa.v3,K.positionScreen.x*=v,K.positionScreen.y*=
|
||||
w,I.positionScreen.x*=v,I.positionScreen.y*=w,F.positionScreen.x*=v,F.positionScreen.y*=w,qa.overdraw&&(Ma(K.positionScreen,I.positionScreen),Ma(I.positionScreen,F.positionScreen),Ma(F.positionScreen,K.positionScreen)),ea.add3Points(K.positionScreen.x,K.positionScreen.y,I.positionScreen.x,I.positionScreen.y,F.positionScreen.x,F.positionScreen.y),pa.instersects(ea)){Ca=0;for(Na=qa.meshMaterials.length;Ca<Na;)if(P=qa.meshMaterials[Ca++],P instanceof THREE.MeshFaceMaterial){H=0;for(A=qa.faceMaterials.length;H<
|
||||
A;)(P=qa.faceMaterials[H++])&&P.opacity!=0&&x(K,I,F,0,1,2,qa,P,b)}else P.opacity!=0&&x(K,I,F,0,1,2,qa,P,b)}}else if(qa instanceof THREE.RenderableFace4&&(K=qa.v1,I=qa.v2,F=qa.v3,Y=qa.v4,K.positionScreen.x*=v,K.positionScreen.y*=w,I.positionScreen.x*=v,I.positionScreen.y*=w,F.positionScreen.x*=v,F.positionScreen.y*=w,Y.positionScreen.x*=v,Y.positionScreen.y*=w,G.positionScreen.copy(I.positionScreen),M.positionScreen.copy(Y.positionScreen),qa.overdraw&&(Ma(K.positionScreen,I.positionScreen),Ma(I.positionScreen,
|
||||
Y.positionScreen),Ma(Y.positionScreen,K.positionScreen),Ma(F.positionScreen,G.positionScreen),Ma(F.positionScreen,M.positionScreen)),ea.addPoint(K.positionScreen.x,K.positionScreen.y),ea.addPoint(I.positionScreen.x,I.positionScreen.y),ea.addPoint(F.positionScreen.x,F.positionScreen.y),ea.addPoint(Y.positionScreen.x,Y.positionScreen.y),pa.instersects(ea))){Ca=0;for(Na=qa.meshMaterials.length;Ca<Na;)if(P=qa.meshMaterials[Ca++],P instanceof THREE.MeshFaceMaterial){H=0;for(A=qa.faceMaterials.length;H<
|
||||
A;)(P=qa.faceMaterials[H++])&&P.opacity!=0&&z(K,I,F,Y,G,M,qa,P,b)}else P.opacity!=0&&z(K,I,F,Y,G,M,qa,P,b)}ta.addRectangle(ea)}u.setTransform(1,0,0,1,0,0)}};
|
||||
THREE.SVGRenderer=function(){function b(b,e,c){var f,j,h,k;f=0;for(j=b.lights.length;f<j;f++)h=b.lights[f],h instanceof THREE.DirectionalLight?(k=e.normalWorld.dot(h.position)*h.intensity,k>0&&(c.r+=h.color.r*k,c.g+=h.color.g*k,c.b+=h.color.b*k)):h instanceof THREE.PointLight&&(Y.sub(h.position,e.centroidWorld),Y.normalize(),k=e.normalWorld.dot(Y)*h.intensity,k>0&&(c.r+=h.color.r*k,c.g+=h.color.g*k,c.b+=h.color.b*k))}function c(e,c,j,n,m,o){k.data.vertices+=3;k.data.faces++;L=f(S++);L.setAttribute("d",
|
||||
"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");m instanceof THREE.MeshBasicMaterial?E.copy(m.color):m instanceof THREE.MeshLambertMaterial?C?(J.r=O.r,J.g=O.g,J.b=O.b,b(o,n,J),E.r=Math.max(0,Math.min(m.color.r*J.r,1)),E.g=Math.max(0,Math.min(m.color.g*J.g,1)),E.b=Math.max(0,Math.min(m.color.b*J.b,1))):E.copy(m.color):m instanceof THREE.MeshDepthMaterial?(F=1-m.__2near/(m.__farPlusNear-n.z*m.__farMinusNear),
|
||||
E.setRGB(F,F,F)):m instanceof THREE.MeshNormalMaterial&&E.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));m.wireframe?L.setAttribute("style","fill: none; stroke: "+E.getContextStyle()+"; stroke-width: "+m.wireframeLinewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframeLinecap+"; stroke-linejoin: "+m.wireframeLinejoin):L.setAttribute("style","fill: "+E.getContextStyle()+"; fill-opacity: "+m.opacity);p.appendChild(L)}function e(e,c,j,n,m,o,v){k.data.vertices+=4;k.data.faces++;
|
||||
L=f(S++);L.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");o instanceof THREE.MeshBasicMaterial?E.copy(o.color):o instanceof THREE.MeshLambertMaterial?C?(J.r=O.r,J.g=O.g,J.b=O.b,b(v,m,J),E.r=Math.max(0,Math.min(o.color.r*J.r,1)),E.g=Math.max(0,Math.min(o.color.g*J.g,1)),E.b=Math.max(0,Math.min(o.color.b*J.b,1))):E.copy(o.color):o instanceof
|
||||
THREE.MeshDepthMaterial?(F=1-o.__2near/(o.__farPlusNear-m.z*o.__farMinusNear),E.setRGB(F,F,F)):o instanceof THREE.MeshNormalMaterial&&E.setRGB(h(m.normalWorld.x),h(m.normalWorld.y),h(m.normalWorld.z));o.wireframe?L.setAttribute("style","fill: none; stroke: "+E.getContextStyle()+"; stroke-width: "+o.wireframeLinewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframeLinecap+"; stroke-linejoin: "+o.wireframeLinejoin):L.setAttribute("style","fill: "+E.getContextStyle()+"; fill-opacity: "+
|
||||
o.opacity);p.appendChild(L)}function f(b){G[b]==null&&(G[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),V==0&&G[b].setAttribute("shape-rendering","crispEdges"));return G[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var k=this,j=null,m=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,t,v,w,u,y,x,B,z=new THREE.Rectangle,D=new THREE.Rectangle,C=!1,E=new THREE.Color(16777215),J=new THREE.Color(16777215),O=new THREE.Color(0),K=new THREE.Color(0),
|
||||
I=new THREE.Color(0),F,Y=new THREE.Vector3,G=[],M=[],L,S,n,V=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":V=1;break;case "low":V=0}};this.setSize=function(b,e){o=b;t=e;v=o/2;w=t/2;p.setAttribute("viewBox",-v+" "+-w+" "+o+" "+t);p.setAttribute("width",o);p.setAttribute("height",t);z.set(-v,-w,v,w)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};this.render=
|
||||
function(b,f){var h,o,t,E,J,G,F,X;this.autoClear&&this.clear();k.data.vertices=0;k.data.faces=0;j=m.projectScene(b,f,this.sortElements);n=S=0;if(C=b.lights.length>0){F=b.lights;O.setRGB(0,0,0);K.setRGB(0,0,0);I.setRGB(0,0,0);h=0;for(o=F.length;h<o;h++)t=F[h],E=t.color,t instanceof THREE.AmbientLight?(O.r+=E.r,O.g+=E.g,O.b+=E.b):t instanceof THREE.DirectionalLight?(K.r+=E.r,K.g+=E.g,K.b+=E.b):t instanceof THREE.PointLight&&(I.r+=E.r,I.g+=E.g,I.b+=E.b)}h=0;for(o=j.length;h<o;h++)if(F=j[h],D.empty(),
|
||||
F instanceof THREE.RenderableParticle){u=F;u.x*=v;u.y*=-w;t=0;for(E=F.materials.length;t<E;)t++}else if(F instanceof THREE.RenderableLine){if(u=F.v1,y=F.v2,u.positionScreen.x*=v,u.positionScreen.y*=-w,y.positionScreen.x*=v,y.positionScreen.y*=-w,D.addPoint(u.positionScreen.x,u.positionScreen.y),D.addPoint(y.positionScreen.x,y.positionScreen.y),z.instersects(D)){t=0;for(E=F.materials.length;t<E;)if((X=F.materials[t++])&&X.opacity!=0){J=u;G=y;var ca=n++;M[ca]==null&&(M[ca]=document.createElementNS("http://www.w3.org/2000/svg",
|
||||
"line"),V==0&&M[ca].setAttribute("shape-rendering","crispEdges"));L=M[ca];L.setAttribute("x1",J.positionScreen.x);L.setAttribute("y1",J.positionScreen.y);L.setAttribute("x2",G.positionScreen.x);L.setAttribute("y2",G.positionScreen.y);X instanceof THREE.LineBasicMaterial&&(L.setAttribute("style","fill: none; stroke: "+X.color.getContextStyle()+"; stroke-width: "+X.linewidth+"; stroke-opacity: "+X.opacity+"; stroke-linecap: "+X.linecap+"; stroke-linejoin: "+X.linejoin),p.appendChild(L))}}}else if(F instanceof
|
||||
THREE.RenderableFace3){if(u=F.v1,y=F.v2,x=F.v3,u.positionScreen.x*=v,u.positionScreen.y*=-w,y.positionScreen.x*=v,y.positionScreen.y*=-w,x.positionScreen.x*=v,x.positionScreen.y*=-w,D.addPoint(u.positionScreen.x,u.positionScreen.y),D.addPoint(y.positionScreen.x,y.positionScreen.y),D.addPoint(x.positionScreen.x,x.positionScreen.y),z.instersects(D)){t=0;for(E=F.meshMaterials.length;t<E;)if(X=F.meshMaterials[t++],X instanceof THREE.MeshFaceMaterial){J=0;for(G=F.faceMaterials.length;J<G;)(X=F.faceMaterials[J++])&&
|
||||
X.opacity!=0&&c(u,y,x,F,X,b)}else X&&X.opacity!=0&&c(u,y,x,F,X,b)}}else if(F instanceof THREE.RenderableFace4&&(u=F.v1,y=F.v2,x=F.v3,B=F.v4,u.positionScreen.x*=v,u.positionScreen.y*=-w,y.positionScreen.x*=v,y.positionScreen.y*=-w,x.positionScreen.x*=v,x.positionScreen.y*=-w,B.positionScreen.x*=v,B.positionScreen.y*=-w,D.addPoint(u.positionScreen.x,u.positionScreen.y),D.addPoint(y.positionScreen.x,y.positionScreen.y),D.addPoint(x.positionScreen.x,x.positionScreen.y),D.addPoint(B.positionScreen.x,B.positionScreen.y),
|
||||
z.instersects(D))){t=0;for(E=F.meshMaterials.length;t<E;)if(X=F.meshMaterials[t++],X instanceof THREE.MeshFaceMaterial){J=0;for(G=F.faceMaterials.length;J<G;)(X=F.faceMaterials[J++])&&X.opacity!=0&&e(u,y,x,B,F,X,b)}else X&&X.opacity!=0&&e(u,y,x,B,F,X,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",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",
|
||||
@@ -218,119 +218,119 @@ THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderCh
|
||||
"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_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;",
|
||||
THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},depthRGBA:{uniforms:{},fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}",vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,
|
||||
"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")}};
|
||||
THREE.WebGLRenderer=function(b){function c(b,c,e){var f,j,h,k=b.vertices,m=k.length,u=b.colors,o=u.length,t=b.__vertexArray,v=b.__colorArray,p=b.__sortArray,w=b.__dirtyVertices,y=b.__dirtyColors,B=b.__webglCustomAttributes,x,z;if(B)for(x in B)B[x].offset=0;if(e.sortParticles){ja.multiplySelf(e.matrixWorld);for(f=0;f<m;f++)j=k[f].position,ma.copy(j),ja.multiplyVector3(ma),p[f]=[ma.z,f];p.sort(function(b,c){return c[0]-b[0]});for(f=0;f<m;f++)j=k[p[f][1]].position,h=f*3,t[h]=j.x,t[h+1]=j.y,t[h+2]=j.z;
|
||||
for(f=0;f<o;f++)h=f*3,color=u[p[f][1]],v[h]=color.r,v[h+1]=color.g,v[h+2]=color.b;if(B)for(x in B){f=B[x];u=f.value.length;for(h=0;h<u;h++){index=p[h][1];o=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[o]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")z=f.value[index];f.size===2?(f.array[o]=z.x,f.array[o+1]=z.y):f.size===3?f.type==="c"?(f.array[o]=z.r,f.array[o+1]=z.g,f.array[o+2]=z.b):(f.array[o]=z.x,f.array[o+1]=z.y,f.array[o+2]=z.z):(f.array[o]=
|
||||
z.x,f.array[o+1]=z.y,f.array[o+2]=z.z,f.array[o+3]=z.w)}f.offset+=f.size}}}else{if(w)for(f=0;f<m;f++)j=k[f].position,h=f*3,t[h]=j.x,t[h+1]=j.y,t[h+2]=j.z;if(y)for(f=0;f<o;f++)color=u[f],h=f*3,v[h]=color.r,v[h+1]=color.g,v[h+2]=color.b;if(B)for(x in B)if(f=B[x],f.__original.needsUpdate){u=f.value.length;for(h=0;h<u;h++){o=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[o]=f.value[h]}else{if(f.boundTo===void 0||f.boundTo==="vertices")z=f.value[h];f.size===2?(f.array[o]=
|
||||
z.x,f.array[o+1]=z.y):f.size===3?f.type==="c"?(f.array[o]=z.r,f.array[o+1]=z.g,f.array[o+2]=z.b):(f.array[o]=z.x,f.array[o+1]=z.y,f.array[o+2]=z.z):(f.array[o]=z.x,f.array[o+1]=z.y,f.array[o+2]=z.z,f.array[o+3]=z.w)}f.offset+=f.size}}}if(w||e.sortParticles)n.bindBuffer(n.ARRAY_BUFFER,b.__webglVertexBuffer),n.bufferData(n.ARRAY_BUFFER,t,c);if(y||e.sortParticles)n.bindBuffer(n.ARRAY_BUFFER,b.__webglColorBuffer),n.bufferData(n.ARRAY_BUFFER,v,c);if(B)for(x in B)if(f=B[x],f.__original.needsUpdate||e.sortParticles)n.bindBuffer(n.ARRAY_BUFFER,
|
||||
f.buffer),n.bufferData(n.ARRAY_BUFFER,f.array,c)}function e(b,c,e,f,j){f.program||P.initMaterial(f,c,e,j);if(f.morphTargets&&!j.__webglMorphTargetInfluences){j.__webglMorphTargetInfluences=new Float32Array(P.maxMorphTargets);for(var h=0,k=P.maxMorphTargets;h<k;h++)j.__webglMorphTargetInfluences[h]=0}var h=f.program,k=h.uniforms,m=f.uniforms;h!=ha&&(n.useProgram(h),ha=h);n.uniformMatrix4fv(k.projectionMatrix,!1,qa);if(e&&(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=e.color,e instanceof THREE.Fog)m.fogNear.value=e.near,m.fogFar.value=e.far;else if(e instanceof THREE.FogExp2)m.fogDensity.value=e.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var o,u,t,v=0,p=0,w=0,y,z,B,x=Ga,D=x.directional.colors,H=x.directional.positions,I=x.point.colors,X=x.point.positions,E=x.point.distances,
|
||||
K=0,F=0,e=u=B=0;for(o=c.length;e<o;e++)if(u=c[e],t=u.color,y=u.position,z=u.intensity,B=u.distance,u instanceof THREE.AmbientLight)v+=t.r,p+=t.g,w+=t.b;else if(u instanceof THREE.DirectionalLight)B=K*3,D[B]=t.r*z,D[B+1]=t.g*z,D[B+2]=t.b*z,H[B]=y.x,H[B+1]=y.y,H[B+2]=y.z,K+=1;else if(u instanceof THREE.SpotLight)B=K*3,D[B]=t.r*z,D[B+1]=t.g*z,D[B+2]=t.b*z,t=1/y.length(),H[B]=y.x*t,H[B+1]=y.y*t,H[B+2]=y.z*t,K+=1;else if(u instanceof THREE.PointLight)u=F*3,I[u]=t.r*z,I[u+1]=t.g*z,I[u+2]=t.b*z,X[u]=y.x,
|
||||
X[u+1]=y.y,X[u+2]=y.z,E[F]=B,F+=1;for(e=K*3;e<D.length;e++)D[e]=0;for(e=F*3;e<I.length;e++)I[e]=0;x.point.length=F;x.directional.length=K;x.ambient[0]=v;x.ambient[1]=p;x.ambient[2]=w;c=Ga;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=za.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;if(j.receiveShadow&&!f._shadowPass&&m.shadowMatrix){for(c=0;c<ya.length;c++)m.shadowMatrix.value[c]=ya[c],m.shadowMap.texture[c]=P.shadowMap[c];m.shadowDarkness.value=P.shadowMapDarkness;m.shadowBias.value=P.shadowMapBias}for(var ja in m)if(o=h.uniforms[ja])if(e=m[ja],v=e.type,c=e.value,v=="i")n.uniform1i(o,c);else if(v=="f")n.uniform1f(o,c);else if(v=="v2")n.uniform2f(o,c.x,c.y);else if(v=="v3")n.uniform3f(o,c.x,c.y,
|
||||
c.z);else if(v=="v4")n.uniform4f(o,c.x,c.y,c.z,c.w);else if(v=="c")n.uniform3f(o,c.r,c.g,c.b);else if(v=="fv1")n.uniform1fv(o,c);else if(v=="fv")n.uniform3fv(o,c);else if(v=="v3v"){if(!e._array)e._array=new Float32Array(3*c.length);v=0;for(p=c.length;v<p;v++)w=v*3,e._array[w]=c[v].x,e._array[w+1]=c[v].y,e._array[w+2]=c[v].z;n.uniform3fv(o,e._array)}else if(v=="m4"){if(!e._array)e._array=new Float32Array(16);c.flattenToArray(e._array);n.uniformMatrix4fv(o,!1,e._array)}else if(v=="m4v"){if(!e._array)e._array=
|
||||
new Float32Array(16*c.length);v=0;for(p=c.length;v<p;v++)c[v].flattenToArrayOffset(e._array,v*16);n.uniformMatrix4fv(o,!1,e._array)}else if(v=="t"){if(n.uniform1i(o,c),o=e.texture)if(o.image instanceof Array&&o.image.length==6){if(e=o,e.image.length==6)if(e.needsUpdate){if(!e.image.__webglTextureCube)e.image.__webglTextureCube=n.createTexture();n.activeTexture(n.TEXTURE0+c);n.bindTexture(n.TEXTURE_CUBE_MAP,e.image.__webglTextureCube);for(c=0;c<6;c++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,
|
||||
n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e.image[c]);C(n.TEXTURE_CUBE_MAP,e,e.image[0]);e.needsUpdate=!1}else n.activeTexture(n.TEXTURE0+c),n.bindTexture(n.TEXTURE_CUBE_MAP,e.image.__webglTextureCube)}else o instanceof THREE.WebGLRenderTargetCube?(e=o,n.activeTexture(n.TEXTURE0+c),n.bindTexture(n.TEXTURE_CUBE_MAP,e.__webglTexture)):J(o,c)}else if(v=="tv"){if(!e._array){e._array=[];v=0;for(p=e.texture.length;v<p;v++)e._array[v]=c+v}n.uniform1iv(o,e._array);v=0;for(p=e.texture.length;v<p;v++)(o=e.texture[v])&&
|
||||
J(o,e._array[v])}n.uniformMatrix4fv(k.modelViewMatrix,!1,j._modelViewMatrixArray);k.normalMatrix&&n.uniformMatrix3fv(k.normalMatrix,!1,j._normalMatrixArray);(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&k.cameraPosition!==null&&n.uniform3f(k.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning||j.receiveShadow)&&k.objectMatrix!==null&&n.uniformMatrix4fv(k.objectMatrix,!1,j._objectMatrixArray);
|
||||
(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&k.viewMatrix!==null&&n.uniformMatrix4fv(k.viewMatrix,!1,ka);f.skinning&&(n.uniformMatrix4fv(k.cameraInverseMatrix,!1,ka),n.uniformMatrix4fv(k.boneGlobalMatrices,!1,j.boneMatrices));return h}function f(b,c,f,j,h,k){if(j.opacity!=0){var m,b=e(b,c,f,j,k).attributes;if(!j.morphTargets&&b.position>=0)n.bindBuffer(n.ARRAY_BUFFER,h.__webglVertexBuffer),n.vertexAttribPointer(b.position,
|
||||
3,n.FLOAT,!1,0,0);else if(k.morphTargetBase){c=j.program.attributes;k.morphTargetBase!==-1?(n.bindBuffer(n.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[k.morphTargetBase]),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0)):c.position>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglVertexBuffer),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,o=k.morphTargetForcedOrder,u=k.morphTargetInfluences;f<j.numSupportedMorphTargets&&f<o.length;)n.bindBuffer(n.ARRAY_BUFFER,
|
||||
h.__webglMorphTargetsBuffers[o[f]]),n.vertexAttribPointer(c["morphTarget"+f],3,n.FLOAT,!1,0,0),k.__webglMorphTargetInfluences[f]=u[o[f]],f++;else{var o=[],t=-1,v=0,u=k.morphTargetInfluences,p,w=u.length,f=0;for(k.morphTargetBase!==-1&&(o[k.morphTargetBase]=!0);f<j.numSupportedMorphTargets;){for(p=0;p<w;p++)!o[p]&&u[p]>t&&(v=p,t=u[v]);n.bindBuffer(n.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[v]);n.vertexAttribPointer(c["morphTarget"+f],3,n.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=t;o[v]=1;t=
|
||||
-1;f++}}j.program.uniforms.morphTargetInfluences!==null&&n.uniform1fv(j.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>=0&&(c=h.__webglCustomAttributes[m],n.bindBuffer(n.ARRAY_BUFFER,c.buffer),n.vertexAttribPointer(b[m],c.size,n.FLOAT,!1,0,0));b.color>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglColorBuffer),n.vertexAttribPointer(b.color,3,n.FLOAT,!1,0,0));b.normal>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglNormalBuffer),
|
||||
n.vertexAttribPointer(b.normal,3,n.FLOAT,!1,0,0));b.tangent>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglTangentBuffer),n.vertexAttribPointer(b.tangent,4,n.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(n.bindBuffer(n.ARRAY_BUFFER,h.__webglUVBuffer),n.vertexAttribPointer(b.uv,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv)):n.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(n.bindBuffer(n.ARRAY_BUFFER,h.__webglUV2Buffer),n.vertexAttribPointer(b.uv2,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv2)):
|
||||
n.disableVertexAttribArray(b.uv2));j.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglSkinVertexABuffer),n.vertexAttribPointer(b.skinVertexA,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),n.vertexAttribPointer(b.skinVertexB,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),n.vertexAttribPointer(b.skinIndex,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),
|
||||
n.vertexAttribPointer(b.skinWeight,4,n.FLOAT,!1,0,0));k instanceof THREE.Mesh?(j.wireframe?(n.lineWidth(j.wireframeLinewidth),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),n.drawElements(n.LINES,h.__webglLineCount,n.UNSIGNED_SHORT,0)):(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),n.drawElements(n.TRIANGLES,h.__webglFaceCount,n.UNSIGNED_SHORT,0)),P.data.vertices+=h.__webglFaceCount,P.data.faces+=h.__webglFaceCount/3,P.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip?
|
||||
n.LINE_STRIP:n.LINES,n.lineWidth(j.linewidth),n.drawArrays(k,0,h.__webglLineCount),P.data.drawCalls++):k instanceof THREE.ParticleSystem?(n.drawArrays(n.POINTS,0,h.__webglParticleCount),P.data.drawCalls++):k instanceof THREE.Ribbon&&(n.drawArrays(n.TRIANGLE_STRIP,0,h.__webglVertexCount),P.data.drawCalls++)}}function h(b,c,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=n.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=n.createBuffer();b.hasPos&&(n.bindBuffer(n.ARRAY_BUFFER,b.__webglVertexBuffer),
|
||||
n.bufferData(n.ARRAY_BUFFER,b.positionArray,n.DYNAMIC_DRAW),n.enableVertexAttribArray(c.attributes.position),n.vertexAttribPointer(c.attributes.position,3,n.FLOAT,!1,0,0));if(b.hasNormal){n.bindBuffer(n.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,h,j,k,m,o,u,t,v,p,w=b.count*3;for(p=0;p<w;p+=9)e=b.normalArray,f=e[p],h=e[p+1],j=e[p+2],k=e[p+3],o=e[p+4],t=e[p+5],m=e[p+6],u=e[p+7],v=e[p+8],f=(f+k+m)/3,h=(h+o+u)/3,j=(j+t+v)/3,e[p]=f,e[p+1]=h,e[p+2]=j,e[p+3]=f,e[p+4]=h,e[p+5]=j,e[p+
|
||||
6]=f,e[p+7]=h,e[p+8]=j}n.bufferData(n.ARRAY_BUFFER,b.normalArray,n.DYNAMIC_DRAW);n.enableVertexAttribArray(c.attributes.normal);n.vertexAttribPointer(c.attributes.normal,3,n.FLOAT,!1,0,0)}n.drawArrays(n.TRIANGLES,0,b.count);b.count=0}function k(b){if(Z!=b.doubleSided)b.doubleSided?n.disable(n.CULL_FACE):n.enable(n.CULL_FACE),Z=b.doubleSided;if(ia!=b.flipSided)b.flipSided?n.frontFace(n.CW):n.frontFace(n.CCW),ia=b.flipSided}function j(b){ea!=b&&(b?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),ea=b)}
|
||||
function m(b,c,e){ga!=b&&(b?n.enable(n.POLYGON_OFFSET_FILL):n.disable(n.POLYGON_OFFSET_FILL),ga=b);if(b&&($!=c||S!=e))n.polygonOffset(c,e),$=c,S=e}function o(b){X[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);X[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);X[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);X[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);X[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);X[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+
|
||||
b.n34);for(var c,b=0;b<6;b++)c=X[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function t(b){for(var c=b.matrixWorld,e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),f=0;f<6;f++)if(b=X[f].x*c.n14+X[f].y*c.n24+X[f].z*c.n34+X[f].w,b<=e)return!1;return!0}function p(b,c){b.list[b.count]=c;b.count+=1}function v(b){var c,e,f=b.object,h=b.opaque,j=b.transparent;j.count=0;b=h.count=0;for(c=f.materials.length;b<c;b++)e=f.materials[b],e.transparent?p(j,e):p(h,e)}
|
||||
function w(b){var c,e,f,h,j=b.object,k=b.buffer,m=b.opaque,n=b.transparent;n.count=0;b=m.count=0;for(f=j.materials.length;b<f;b++)if(c=j.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(e=k.materials.length;c<e;c++)(h=k.materials[c])&&(h.transparent?p(n,h):p(m,h))}else(h=c)&&(h.transparent?p(n,h):p(m,h))}function u(b,c){return c.z-b.z}function y(b,c){var m,u,v,p=0,w,y,z,x,D=b.lights;ca||(ca=new THREE.Camera(P.shadowCameraFov,c.aspect,P.shadowCameraNear,P.shadowCameraFar));m=0;for(u=D.length;m<
|
||||
u;m++)if(v=D[m],v instanceof THREE.SpotLight&&v.castShadow){P.shadowMap[p]||(P.shadowMap[p]=new THREE.WebGLRenderTarget(P.shadowMapWidth,P.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));ya[p]||(ya[p]=new THREE.Matrix4);w=P.shadowMap[p];y=ya[p];ca.position.copy(v.position);ca.target.position.copy(v.target.position);ca.update(void 0,!0);b.update(void 0,!1,ca);y.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);y.multiplySelf(ca.projectionMatrix);
|
||||
y.multiplySelf(ca.matrixWorldInverse);ca.matrixWorldInverse.flattenToArray(ka);ca.projectionMatrix.flattenToArray(qa);ja.multiply(ca.projectionMatrix,ca.matrixWorldInverse);o(ja);P.initWebGLObjects(b);E(w);n.clearColor(1,1,1,1);P.clear();n.clearColor(ra.r,ra.g,ra.b,na);y=b.__webglObjects.length;v=b.__webglObjectsImmediate.length;for(w=0;w<y;w++)z=b.__webglObjects[w],x=z.object,x.visible&&x.castShadow?!(x instanceof THREE.Mesh)||t(x)?(x.matrixWorld.flattenToArray(x._objectMatrixArray),B(x,ca,!1),z.render=
|
||||
!0):z.render=!1:z.render=!1;j(!0);M(THREE.NormalBlending);for(w=0;w<y;w++)if(z=b.__webglObjects[w],z.render)x=z.object,buffer=z.buffer,k(x),z=x.customDepthMaterial?x.customDepthMaterial:x.geometry.morphTargets.length?Ea:oa,f(ca,D,null,z,buffer,x);for(w=0;w<v;w++)z=b.__webglObjectsImmediate[w],x=z.object,x.visible&&x.castShadow&&(x.matrixAutoUpdate&&x.matrixWorld.flattenToArray(x._objectMatrixArray),B(x,ca,!1),k(x),program=e(ca,D,null,oa,x),x.render(function(b){h(b,program,oa.shading)}));p++}}function x(b,
|
||||
c){var e,f,h;e=T.attributes;var j=T.uniforms,k=la/fa,m,o=[],v=fa*0.5,t=la*0.5,p=!0;n.useProgram(T.program);ha=T.program;ea=U=-1;Ba||(n.enableVertexAttribArray(T.attributes.position),n.enableVertexAttribArray(T.attributes.uv),Ba=!0);n.disable(n.CULL_FACE);n.enable(n.BLEND);n.depthMask(!0);n.bindBuffer(n.ARRAY_BUFFER,T.vertexBuffer);n.vertexAttribPointer(e.position,2,n.FLOAT,!1,16,0);n.vertexAttribPointer(e.uv,2,n.FLOAT,!1,16,8);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,T.elementBuffer);n.uniformMatrix4fv(j.projectionMatrix,
|
||||
!1,qa);n.activeTexture(n.TEXTURE0);n.uniform1i(j.map,0);e=0;for(f=b.__webglSprites.length;e<f;e++)h=b.__webglSprites[e],h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(u);e=0;for(f=b.__webglSprites.length;e<f;e++)h=b.__webglSprites[e],h.material===void 0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(n.uniform1i(j.useScreenCoordinates,1),n.uniform3f(j.screenPosition,
|
||||
(h.position.x-v)/v,(t-h.position.y)/t,Math.max(0,Math.min(1,h.position.z)))):(n.uniform1i(j.useScreenCoordinates,0),n.uniform1i(j.affectedByDistance,h.affectedByDistance?1:0),n.uniformMatrix4fv(j.modelViewMatrix,!1,h._modelViewMatrixArray)),m=h.map.image.width/(h.scaleByViewport?la:1),o[0]=m*k*h.scale.x,o[1]=m*h.scale.y,n.uniform2f(j.uvScale,h.uvScale.x,h.uvScale.y),n.uniform2f(j.uvOffset,h.uvOffset.x,h.uvOffset.y),n.uniform2f(j.alignment,h.alignment.x,h.alignment.y),n.uniform1f(j.opacity,h.opacity),
|
||||
n.uniform1f(j.rotation,h.rotation),n.uniform2fv(j.scale,o),h.mergeWith3D&&!p?(n.enable(n.DEPTH_TEST),p=!0):!h.mergeWith3D&&p&&(n.disable(n.DEPTH_TEST),p=!1),M(h.blending),J(h.map,0),n.drawElements(n.TRIANGLES,6,n.UNSIGNED_SHORT,0));n.enable(n.CULL_FACE);n.enable(n.DEPTH_TEST);n.depthMask(aa)}function B(b,c,e){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);e&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function z(b){var c,
|
||||
e,f,h;h=b.__materials;b=0;for(e=h.length;b<e;b++)if(f=h[b],f.attributes)for(c in f.attributes)if(f.attributes[c].needsUpdate)return!0;return!1}function H(b){var c,e,f,h;h=b.__materials;b=0;for(e=h.length;b<e;b++)if(f=h[b],f.attributes)for(c in f.attributes)f.attributes[c].needsUpdate=!1}function D(b,c){var e;for(e=b.length-1;e>=0;e--)b[e].object==c&&b.splice(e,1)}function I(b){function c(b){var h=[];e=0;for(f=b.length;e<f;e++)b[e]==void 0?h.push("undefined"):h.push(b[e].id);return h.join("_")}var e,
|
||||
f,h,j,k,m,n,o,u={},v=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};h=0;for(j=b.faces.length;h<j;h++)k=b.faces[h],m=k.materials,n=c(m),u[n]==void 0&&(u[n]={hash:n,counter:0}),o=u[n].hash+"_"+u[n].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[],materials:m,vertices:0,numMorphTargets:v}),k=k instanceof THREE.Face3?3:4,b.geometryGroups[o].vertices+k>65535&&(u[n].counter+=1,o=u[n].hash+"_"+u[n].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[],
|
||||
materials:m,vertices:0,numMorphTargets:v})),b.geometryGroups[o].faces.push(h),b.geometryGroups[o].vertices+=k}function K(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(b){if(b!=U){switch(b){case THREE.AdditiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE);break;case THREE.SubtractiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,
|
||||
n.SRC_COLOR);break;default:n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}U=b}}function C(b,c,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(n.texParameteri(b,n.TEXTURE_WRAP_S,N(c.wrapS)),n.texParameteri(b,n.TEXTURE_WRAP_T,N(c.wrapT)),n.texParameteri(b,n.TEXTURE_MAG_FILTER,N(c.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,N(c.minFilter)),n.generateMipmap(b)):(n.texParameteri(b,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),
|
||||
n.texParameteri(b,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(b,n.TEXTURE_MAG_FILTER,L(c.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,L(c.minFilter)))}function J(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=n.createTexture();n.activeTexture(n.TEXTURE0+c);n.bindTexture(n.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?n.texImage2D(n.TEXTURE_2D,0,N(b.format),b.image.width,b.image.height,0,N(b.format),n.UNSIGNED_BYTE,b.image.data):n.texImage2D(n.TEXTURE_2D,
|
||||
0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,b.image);C(n.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else n.activeTexture(n.TEXTURE0+c),n.bindTexture(n.TEXTURE_2D,b.__webglTexture)}function E(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=n.createRenderbuffer();b.__webglTexture=n.createTexture();if(c){n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture);C(n.TEXTURE_CUBE_MAP,
|
||||
b,b);b.__webglFramebuffer=[];for(var e=0;e<6;e++)b.__webglFramebuffer[e]=n.createFramebuffer(),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,N(b.format),b.width,b.height,0,N(b.format),N(b.type),null)}else b.__webglFramebuffer=n.createFramebuffer(),n.bindTexture(n.TEXTURE_2D,b.__webglTexture),C(n.TEXTURE_2D,b,b),n.texImage2D(n.TEXTURE_2D,0,N(b.format),b.width,b.height,0,N(b.format),N(b.type),null);n.bindRenderbuffer(n.RENDERBUFFER,b.__webglRenderbuffer);if(c)for(e=0;e<6;++e)n.bindFramebuffer(n.FRAMEBUFFER,
|
||||
b.__webglFramebuffer[e]),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+e,b.__webglTexture,0);else n.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&
|
||||
b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):n.renderbufferStorage(n.RENDERBUFFER,n.RGBA4,b.width,b.height);c?n.bindTexture(n.TEXTURE_CUBE_MAP,null):n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null)}var f,h;b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,e=b.width,b=b.height,
|
||||
h=f=0):(c=null,e=fa,b=la,f=W,h=da);c!=R&&(n.bindFramebuffer(n.FRAMEBUFFER,c),n.viewport(f,h,e,b),R=c)}function Y(b){b instanceof THREE.WebGLRenderTargetCube?(n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture),n.generateMipmap(n.TEXTURE_CUBE_MAP),n.bindTexture(n.TEXTURE_CUBE_MAP,null)):(n.bindTexture(n.TEXTURE_2D,b.__webglTexture),n.generateMipmap(n.TEXTURE_2D),n.bindTexture(n.TEXTURE_2D,null))}function F(b,c){var e;b=="fragment"?e=n.createShader(n.FRAGMENT_SHADER):b=="vertex"&&(e=n.createShader(n.VERTEX_SHADER));
|
||||
n.shaderSource(e,c);n.compileShader(e);if(!n.getShaderParameter(e,n.COMPILE_STATUS))return console.error(n.getShaderInfoLog(e)),console.error(c),null;return e}function L(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return n.NEAREST;default:return n.LINEAR}}function N(b){switch(b){case THREE.RepeatWrapping:return n.REPEAT;case THREE.ClampToEdgeWrapping:return n.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return n.MIRRORED_REPEAT;
|
||||
THREE.WebGLRenderer=function(b){function c(b,e,c){var f,j,h,k=b.vertices,m=k.length,o=b.colors,p=o.length,v=b.__vertexArray,t=b.__colorArray,u=b.__sortArray,w=b.__dirtyVertices,y=b.__dirtyColors,x=b.__webglCustomAttributes,B,z;if(x)for(B in x)x[B].offset=0;if(c.sortParticles){N.multiplySelf(c.matrixWorld);for(f=0;f<m;f++)j=k[f].position,sa.copy(j),N.multiplyVector3(sa),u[f]=[sa.z,f];u.sort(function(b,e){return e[0]-b[0]});for(f=0;f<m;f++)j=k[u[f][1]].position,h=f*3,v[h]=j.x,v[h+1]=j.y,v[h+2]=j.z;
|
||||
for(f=0;f<p;f++)h=f*3,color=o[u[f][1]],t[h]=color.r,t[h+1]=color.g,t[h+2]=color.b;if(x)for(B in x){f=x[B];o=f.value.length;for(h=0;h<o;h++){index=u[h][1];p=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[p]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")z=f.value[index];f.size===2?(f.array[p]=z.x,f.array[p+1]=z.y):f.size===3?f.type==="c"?(f.array[p]=z.r,f.array[p+1]=z.g,f.array[p+2]=z.b):(f.array[p]=z.x,f.array[p+1]=z.y,f.array[p+2]=z.z):(f.array[p]=
|
||||
z.x,f.array[p+1]=z.y,f.array[p+2]=z.z,f.array[p+3]=z.w)}f.offset+=f.size}}}else{if(w)for(f=0;f<m;f++)j=k[f].position,h=f*3,v[h]=j.x,v[h+1]=j.y,v[h+2]=j.z;if(y)for(f=0;f<p;f++)color=o[f],h=f*3,t[h]=color.r,t[h+1]=color.g,t[h+2]=color.b;if(x)for(B in x)if(f=x[B],f.__original.needsUpdate){o=f.value.length;for(h=0;h<o;h++){p=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[p]=f.value[h]}else{if(f.boundTo===void 0||f.boundTo==="vertices")z=f.value[h];f.size===2?(f.array[p]=
|
||||
z.x,f.array[p+1]=z.y):f.size===3?f.type==="c"?(f.array[p]=z.r,f.array[p+1]=z.g,f.array[p+2]=z.b):(f.array[p]=z.x,f.array[p+1]=z.y,f.array[p+2]=z.z):(f.array[p]=z.x,f.array[p+1]=z.y,f.array[p+2]=z.z,f.array[p+3]=z.w)}f.offset+=f.size}}}if(w||c.sortParticles)n.bindBuffer(n.ARRAY_BUFFER,b.__webglVertexBuffer),n.bufferData(n.ARRAY_BUFFER,v,e);if(y||c.sortParticles)n.bindBuffer(n.ARRAY_BUFFER,b.__webglColorBuffer),n.bufferData(n.ARRAY_BUFFER,t,e);if(x)for(B in x)if(f=x[B],f.__original.needsUpdate||c.sortParticles)n.bindBuffer(n.ARRAY_BUFFER,
|
||||
f.buffer),n.bufferData(n.ARRAY_BUFFER,f.array,e)}function e(b,e,c,f,h){f.program||S.initMaterial(f,e,c,h);if(f.morphTargets&&!h.__webglMorphTargetInfluences){h.__webglMorphTargetInfluences=new Float32Array(S.maxMorphTargets);for(var j=0,k=S.maxMorphTargets;j<k;j++)h.__webglMorphTargetInfluences[j]=0}var j=f.program,k=j.uniforms,m=f.uniforms;j!=fa&&(n.useProgram(j),fa=j);n.uniformMatrix4fv(k.projectionMatrix,!1,ra);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 o,p,v,t=0,u=0,w=0,y,z,x,B=Ha,D=B.directional.colors,C=B.directional.positions,E=B.point.colors,Z=B.point.positions,F=B.point.distances,
|
||||
J=0,N=0,c=p=x=0;for(o=e.length;c<o;c++)if(p=e[c],v=p.color,y=p.position,z=p.intensity,x=p.distance,p instanceof THREE.AmbientLight)t+=v.r,u+=v.g,w+=v.b;else if(p instanceof THREE.DirectionalLight)x=J*3,D[x]=v.r*z,D[x+1]=v.g*z,D[x+2]=v.b*z,C[x]=y.x,C[x+1]=y.y,C[x+2]=y.z,J+=1;else if(p instanceof THREE.SpotLight)x=J*3,D[x]=v.r*z,D[x+1]=v.g*z,D[x+2]=v.b*z,v=1/y.length(),C[x]=y.x*v,C[x+1]=y.y*v,C[x+2]=y.z*v,J+=1;else if(p instanceof THREE.PointLight)p=N*3,E[p]=v.r*z,E[p+1]=v.g*z,E[p+2]=v.b*z,Z[p]=y.x,
|
||||
Z[p+1]=y.y,Z[p+2]=y.z,F[N]=x,N+=1;for(c=J*3;c<D.length;c++)D[c]=0;for(c=N*3;c<E.length;c++)E[c]=0;B.point.length=N;B.directional.length=J;B.ambient[0]=t;B.ambient[1]=u;B.ambient[2]=w;e=Ha;m.enableLighting.value=e.directional.length+e.point.length;m.ambientLightColor.value=e.ambient;m.directionalLightColor.value=e.directional.colors;m.directionalLightDirection.value=e.directional.positions;m.pointLightColor.value=e.point.colors;m.pointLightPosition.value=e.point.positions;m.pointLightDistance.value=
|
||||
e.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=oa.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;if(h.receiveShadow&&!f._shadowPass&&m.shadowMatrix){for(e=0;e<ya.length;e++)m.shadowMatrix.value[e]=ya[e],m.shadowMap.texture[e]=S.shadowMap[e];m.shadowDarkness.value=S.shadowMapDarkness;m.shadowBias.value=S.shadowMapBias}for(var G in m)if(o=j.uniforms[G])if(c=m[G],t=c.type,e=c.value,t=="i")n.uniform1i(o,e);else if(t=="f")n.uniform1f(o,e);else if(t=="v2")n.uniform2f(o,e.x,e.y);else if(t=="v3")n.uniform3f(o,e.x,e.y,e.z);
|
||||
else if(t=="v4")n.uniform4f(o,e.x,e.y,e.z,e.w);else if(t=="c")n.uniform3f(o,e.r,e.g,e.b);else if(t=="fv1")n.uniform1fv(o,e);else if(t=="fv")n.uniform3fv(o,e);else if(t=="v3v"){if(!c._array)c._array=new Float32Array(3*e.length);t=0;for(u=e.length;t<u;t++)w=t*3,c._array[w]=e[t].x,c._array[w+1]=e[t].y,c._array[w+2]=e[t].z;n.uniform3fv(o,c._array)}else if(t=="m4"){if(!c._array)c._array=new Float32Array(16);e.flattenToArray(c._array);n.uniformMatrix4fv(o,!1,c._array)}else if(t=="m4v"){if(!c._array)c._array=
|
||||
new Float32Array(16*e.length);t=0;for(u=e.length;t<u;t++)e[t].flattenToArrayOffset(c._array,t*16);n.uniformMatrix4fv(o,!1,c._array)}else if(t=="t"){if(n.uniform1i(o,e),o=c.texture)if(o.image instanceof Array&&o.image.length==6){if(c=o,c.image.length==6)if(c.needsUpdate){if(!c.image.__webglTextureCube)c.image.__webglTextureCube=n.createTexture();n.activeTexture(n.TEXTURE0+e);n.bindTexture(n.TEXTURE_CUBE_MAP,c.image.__webglTextureCube);for(e=0;e<6;e++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,
|
||||
n.RGBA,n.RGBA,n.UNSIGNED_BYTE,c.image[e]);K(n.TEXTURE_CUBE_MAP,c,c.image[0]);c.needsUpdate=!1}else n.activeTexture(n.TEXTURE0+e),n.bindTexture(n.TEXTURE_CUBE_MAP,c.image.__webglTextureCube)}else o instanceof THREE.WebGLRenderTargetCube?(c=o,n.activeTexture(n.TEXTURE0+e),n.bindTexture(n.TEXTURE_CUBE_MAP,c.__webglTexture)):I(o,e)}else if(t=="tv"){if(!c._array){c._array=[];t=0;for(u=c.texture.length;t<u;t++)c._array[t]=e+t}n.uniform1iv(o,c._array);t=0;for(u=c.texture.length;t<u;t++)(o=c.texture[t])&&
|
||||
I(o,c._array[t])}n.uniformMatrix4fv(k.modelViewMatrix,!1,h._modelViewMatrixArray);k.normalMatrix&&n.uniformMatrix3fv(k.normalMatrix,!1,h._normalMatrixArray);(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&k.cameraPosition!==null&&n.uniform3f(k.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial||f.envMap||f.skinning||h.receiveShadow)&&k.objectMatrix!==null&&n.uniformMatrix4fv(k.objectMatrix,!1,h._objectMatrixArray);
|
||||
(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&k.viewMatrix!==null&&n.uniformMatrix4fv(k.viewMatrix,!1,la);f.skinning&&(n.uniformMatrix4fv(k.cameraInverseMatrix,!1,la),n.uniformMatrix4fv(k.boneGlobalMatrices,!1,h.boneMatrices));return j}function f(b,c,f,h,j,k){if(h.opacity!=0){var m,b=e(b,c,f,h,k).attributes;if(!h.morphTargets&&b.position>=0)n.bindBuffer(n.ARRAY_BUFFER,j.__webglVertexBuffer),n.vertexAttribPointer(b.position,
|
||||
3,n.FLOAT,!1,0,0);else if(k.morphTargetBase){c=h.program.attributes;k.morphTargetBase!==-1?(n.bindBuffer(n.ARRAY_BUFFER,j.__webglMorphTargetsBuffers[k.morphTargetBase]),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0)):c.position>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglVertexBuffer),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,o=k.morphTargetForcedOrder,p=k.morphTargetInfluences;f<h.numSupportedMorphTargets&&f<o.length;)n.bindBuffer(n.ARRAY_BUFFER,
|
||||
j.__webglMorphTargetsBuffers[o[f]]),n.vertexAttribPointer(c["morphTarget"+f],3,n.FLOAT,!1,0,0),k.__webglMorphTargetInfluences[f]=p[o[f]],f++;else{var o=[],v=-1,t=0,p=k.morphTargetInfluences,u,w=p.length,f=0;for(k.morphTargetBase!==-1&&(o[k.morphTargetBase]=!0);f<h.numSupportedMorphTargets;){for(u=0;u<w;u++)!o[u]&&p[u]>v&&(t=u,v=p[t]);n.bindBuffer(n.ARRAY_BUFFER,j.__webglMorphTargetsBuffers[t]);n.vertexAttribPointer(c["morphTarget"+f],3,n.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=v;o[t]=1;v=
|
||||
-1;f++}}h.program.uniforms.morphTargetInfluences!==null&&n.uniform1fv(h.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(j.__webglCustomAttributes)for(m in j.__webglCustomAttributes)b[m]>=0&&(c=j.__webglCustomAttributes[m],n.bindBuffer(n.ARRAY_BUFFER,c.buffer),n.vertexAttribPointer(b[m],c.size,n.FLOAT,!1,0,0));b.color>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglColorBuffer),n.vertexAttribPointer(b.color,3,n.FLOAT,!1,0,0));b.normal>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglNormalBuffer),
|
||||
n.vertexAttribPointer(b.normal,3,n.FLOAT,!1,0,0));b.tangent>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglTangentBuffer),n.vertexAttribPointer(b.tangent,4,n.FLOAT,!1,0,0));b.uv>=0&&(j.__webglUVBuffer?(n.bindBuffer(n.ARRAY_BUFFER,j.__webglUVBuffer),n.vertexAttribPointer(b.uv,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv)):n.disableVertexAttribArray(b.uv));b.uv2>=0&&(j.__webglUV2Buffer?(n.bindBuffer(n.ARRAY_BUFFER,j.__webglUV2Buffer),n.vertexAttribPointer(b.uv2,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv2)):
|
||||
n.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglSkinVertexABuffer),n.vertexAttribPointer(b.skinVertexA,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,j.__webglSkinVertexBBuffer),n.vertexAttribPointer(b.skinVertexB,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,j.__webglSkinIndicesBuffer),n.vertexAttribPointer(b.skinIndex,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,j.__webglSkinWeightsBuffer),
|
||||
n.vertexAttribPointer(b.skinWeight,4,n.FLOAT,!1,0,0));k instanceof THREE.Mesh?(h.wireframe?(n.lineWidth(h.wireframeLinewidth),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,j.__webglLineBuffer),n.drawElements(n.LINES,j.__webglLineCount,n.UNSIGNED_SHORT,0)):(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,j.__webglFaceBuffer),n.drawElements(n.TRIANGLES,j.__webglFaceCount,n.UNSIGNED_SHORT,0)),S.data.vertices+=j.__webglFaceCount,S.data.faces+=j.__webglFaceCount/3,S.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip?
|
||||
n.LINE_STRIP:n.LINES,n.lineWidth(h.linewidth),n.drawArrays(k,0,j.__webglLineCount),S.data.drawCalls++):k instanceof THREE.ParticleSystem?(n.drawArrays(n.POINTS,0,j.__webglParticleCount),S.data.drawCalls++):k instanceof THREE.Ribbon&&(n.drawArrays(n.TRIANGLE_STRIP,0,j.__webglVertexCount),S.data.drawCalls++)}}function h(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=n.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=n.createBuffer();b.hasPos&&(n.bindBuffer(n.ARRAY_BUFFER,b.__webglVertexBuffer),
|
||||
n.bufferData(n.ARRAY_BUFFER,b.positionArray,n.DYNAMIC_DRAW),n.enableVertexAttribArray(e.attributes.position),n.vertexAttribPointer(e.attributes.position,3,n.FLOAT,!1,0,0));if(b.hasNormal){n.bindBuffer(n.ARRAY_BUFFER,b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,j,h,k,m,o,p,v,t,u,w=b.count*3;for(u=0;u<w;u+=9)c=b.normalArray,f=c[u],j=c[u+1],h=c[u+2],k=c[u+3],o=c[u+4],v=c[u+5],m=c[u+6],p=c[u+7],t=c[u+8],f=(f+k+m)/3,j=(j+o+p)/3,h=(h+v+t)/3,c[u]=f,c[u+1]=j,c[u+2]=h,c[u+3]=f,c[u+4]=j,c[u+5]=h,c[u+
|
||||
6]=f,c[u+7]=j,c[u+8]=h}n.bufferData(n.ARRAY_BUFFER,b.normalArray,n.DYNAMIC_DRAW);n.enableVertexAttribArray(e.attributes.normal);n.vertexAttribPointer(e.attributes.normal,3,n.FLOAT,!1,0,0)}n.drawArrays(n.TRIANGLES,0,b.count);b.count=0}function k(b){if($!=b.doubleSided)b.doubleSided?n.disable(n.CULL_FACE):n.enable(n.CULL_FACE),$=b.doubleSided;if(ka!=b.flipSided)b.flipSided?n.frontFace(n.CW):n.frontFace(n.CCW),ka=b.flipSided}function j(b){aa!=b&&(b?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),aa=b)}
|
||||
function m(b,e,c){ja!=b&&(b?n.enable(n.POLYGON_OFFSET_FILL):n.disable(n.POLYGON_OFFSET_FILL),ja=b);if(b&&(ha!=e||X!=c))n.polygonOffset(e,c),ha=e,X=c}function p(b){Z[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);Z[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);Z[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);Z[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);Z[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);Z[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=Z[b],e.divideScalar(Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z))}function o(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=Z[f].x*e.n14+Z[f].y*e.n24+Z[f].z*e.n34+Z[f].w,b<=c)return!1;return!0}function t(b,e){b.list[b.count]=e;b.count+=1}function v(b){var e,c,f=b.object,j=b.opaque,h=b.transparent;h.count=0;b=j.count=0;for(e=f.materials.length;b<e;b++)c=f.materials[b],c.transparent?t(h,c):t(j,c)}
|
||||
function w(b){var e,c,f,j,h=b.object,k=b.buffer,m=b.opaque,n=b.transparent;n.count=0;b=m.count=0;for(f=h.materials.length;b<f;b++)if(e=h.materials[b],e instanceof THREE.MeshFaceMaterial){e=0;for(c=k.materials.length;e<c;e++)(j=k.materials[e])&&(j.transparent?t(n,j):t(m,j))}else(j=e)&&(j.transparent?t(n,j):t(m,j))}function u(b,e){return e.z-b.z}function y(b,c){var m,v,t,u=0,w,y,z,x,D=b.lights;ea||(ea=new THREE.Camera(S.shadowCameraFov,c.aspect,S.shadowCameraNear,S.shadowCameraFar));m=0;for(v=D.length;m<
|
||||
v;m++)if(t=D[m],t instanceof THREE.SpotLight&&t.castShadow){S.shadowMap[u]||(S.shadowMap[u]=new THREE.WebGLRenderTarget(S.shadowMapWidth,S.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));ya[u]||(ya[u]=new THREE.Matrix4);w=S.shadowMap[u];y=ya[u];ea.position.copy(t.position);ea.target.position.copy(t.target.position);ea.update(void 0,!0);b.update(void 0,!1,ea);y.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);y.multiplySelf(ea.projectionMatrix);
|
||||
y.multiplySelf(ea.matrixWorldInverse);ea.matrixWorldInverse.flattenToArray(la);ea.projectionMatrix.flattenToArray(ra);N.multiply(ea.projectionMatrix,ea.matrixWorldInverse);p(N);S.initWebGLObjects(b);F(w);n.clearColor(1,1,1,1);S.clear();n.clearColor(pa.r,pa.g,pa.b,ta);y=b.__webglObjects.length;t=b.__webglObjectsImmediate.length;for(w=0;w<y;w++)z=b.__webglObjects[w],x=z.object,x.visible&&x.castShadow?!(x instanceof THREE.Mesh)||o(x)?(x.matrixWorld.flattenToArray(x._objectMatrixArray),B(x,ea,!1),z.render=
|
||||
!0):z.render=!1:z.render=!1;j(!0);O(THREE.NormalBlending);for(w=0;w<y;w++)if(z=b.__webglObjects[w],z.render)x=z.object,buffer=z.buffer,k(x),z=x.customDepthMaterial?x.customDepthMaterial:x.geometry.morphTargets.length?Ea:wa,f(ea,D,null,z,buffer,x);for(w=0;w<t;w++)z=b.__webglObjectsImmediate[w],x=z.object,x.visible&&x.castShadow&&(x.matrixAutoUpdate&&x.matrixWorld.flattenToArray(x._objectMatrixArray),B(x,ea,!1),k(x),program=e(ea,D,null,wa,x),x.render(function(b){h(b,program,wa.shading)}));u++}}function x(b,
|
||||
e){var c,f,j;c=T.attributes;var h=T.uniforms,k=ma/ia,m,o=[],p=ia*0.5,v=ma*0.5,t=!0;n.useProgram(T.program);fa=T.program;aa=U=-1;Aa||(n.enableVertexAttribArray(T.attributes.position),n.enableVertexAttribArray(T.attributes.uv),Aa=!0);n.disable(n.CULL_FACE);n.enable(n.BLEND);n.depthMask(!0);n.bindBuffer(n.ARRAY_BUFFER,T.vertexBuffer);n.vertexAttribPointer(c.position,2,n.FLOAT,!1,16,0);n.vertexAttribPointer(c.uv,2,n.FLOAT,!1,16,8);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,T.elementBuffer);n.uniformMatrix4fv(h.projectionMatrix,
|
||||
!1,ra);n.activeTexture(n.TEXTURE0);n.uniform1i(h.map,0);c=0;for(f=b.__webglSprites.length;c<f;c++)j=b.__webglSprites[c],j.useScreenCoordinates?j.z=-j.position.z:(j._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,j.matrixWorld,j._modelViewMatrixArray),j.z=-j._modelViewMatrix.n34);b.__webglSprites.sort(u);c=0;for(f=b.__webglSprites.length;c<f;c++)j=b.__webglSprites[c],j.material===void 0&&j.map&&j.map.image&&j.map.image.width&&(j.useScreenCoordinates?(n.uniform1i(h.useScreenCoordinates,1),n.uniform3f(h.screenPosition,
|
||||
(j.position.x-p)/p,(v-j.position.y)/v,Math.max(0,Math.min(1,j.position.z)))):(n.uniform1i(h.useScreenCoordinates,0),n.uniform1i(h.affectedByDistance,j.affectedByDistance?1:0),n.uniformMatrix4fv(h.modelViewMatrix,!1,j._modelViewMatrixArray)),m=j.map.image.width/(j.scaleByViewport?ma:1),o[0]=m*k*j.scale.x,o[1]=m*j.scale.y,n.uniform2f(h.uvScale,j.uvScale.x,j.uvScale.y),n.uniform2f(h.uvOffset,j.uvOffset.x,j.uvOffset.y),n.uniform2f(h.alignment,j.alignment.x,j.alignment.y),n.uniform1f(h.opacity,j.opacity),
|
||||
n.uniform1f(h.rotation,j.rotation),n.uniform2fv(h.scale,o),j.mergeWith3D&&!t?(n.enable(n.DEPTH_TEST),t=!0):!j.mergeWith3D&&t&&(n.disable(n.DEPTH_TEST),t=!1),O(j.blending),I(j.map,0),n.drawElements(n.TRIANGLES,6,n.UNSIGNED_SHORT,0));n.enable(n.CULL_FACE);n.enable(n.DEPTH_TEST);n.depthMask(da)}function B(b,e,c){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function z(b){var e,
|
||||
c,f,j;j=b.__materials;b=0;for(c=j.length;b<c;b++)if(f=j[b],f.attributes)for(e in f.attributes)if(f.attributes[e].needsUpdate)return!0;return!1}function D(b){var e,c,f,j;j=b.__materials;b=0;for(c=j.length;b<c;b++)if(f=j[b],f.attributes)for(e in f.attributes)f.attributes[e].needsUpdate=!1}function C(b,e){var c;for(c=b.length-1;c>=0;c--)b[c].object==e&&b.splice(c,1)}function E(b){function e(b){var j=[];c=0;for(f=b.length;c<f;c++)b[c]==void 0?j.push("undefined"):j.push(b[c].id);return j.join("_")}var c,
|
||||
f,j,h,k,m,n,o,p={},v=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};j=0;for(h=b.faces.length;j<h;j++)k=b.faces[j],m=k.materials,n=e(m),p[n]==void 0&&(p[n]={hash:n,counter:0}),o=p[n].hash+"_"+p[n].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[],materials:m,vertices:0,numMorphTargets:v}),k=k instanceof THREE.Face3?3:4,b.geometryGroups[o].vertices+k>65535&&(p[n].counter+=1,o=p[n].hash+"_"+p[n].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[],
|
||||
materials:m,vertices:0,numMorphTargets:v})),b.geometryGroups[o].faces.push(j),b.geometryGroups[o].vertices+=k}function J(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function O(b){if(b!=U){switch(b){case THREE.AdditiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE);break;case THREE.SubtractiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,
|
||||
n.SRC_COLOR);break;default:n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}U=b}}function K(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(n.texParameteri(b,n.TEXTURE_WRAP_S,L(e.wrapS)),n.texParameteri(b,n.TEXTURE_WRAP_T,L(e.wrapT)),n.texParameteri(b,n.TEXTURE_MAG_FILTER,L(e.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,L(e.minFilter)),n.generateMipmap(b)):(n.texParameteri(b,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),
|
||||
n.texParameteri(b,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(b,n.TEXTURE_MAG_FILTER,M(e.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,M(e.minFilter)))}function I(b,e){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=n.createTexture();n.activeTexture(n.TEXTURE0+e);n.bindTexture(n.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?n.texImage2D(n.TEXTURE_2D,0,L(b.format),b.image.width,b.image.height,0,L(b.format),n.UNSIGNED_BYTE,b.image.data):n.texImage2D(n.TEXTURE_2D,
|
||||
0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,b.image);K(n.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else n.activeTexture(n.TEXTURE0+e),n.bindTexture(n.TEXTURE_2D,b.__webglTexture)}function F(b){var e=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=n.createRenderbuffer();b.__webglTexture=n.createTexture();if(e){n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture);K(n.TEXTURE_CUBE_MAP,
|
||||
b,b);b.__webglFramebuffer=[];for(var c=0;c<6;c++)b.__webglFramebuffer[c]=n.createFramebuffer(),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,L(b.format),b.width,b.height,0,L(b.format),L(b.type),null)}else b.__webglFramebuffer=n.createFramebuffer(),n.bindTexture(n.TEXTURE_2D,b.__webglTexture),K(n.TEXTURE_2D,b,b),n.texImage2D(n.TEXTURE_2D,0,L(b.format),b.width,b.height,0,L(b.format),L(b.type),null);n.bindRenderbuffer(n.RENDERBUFFER,b.__webglRenderbuffer);if(e)for(c=0;c<6;++c)n.bindFramebuffer(n.FRAMEBUFFER,
|
||||
b.__webglFramebuffer[c]),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+c,b.__webglTexture,0);else n.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&
|
||||
b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):n.renderbufferStorage(n.RENDERBUFFER,n.RGBA4,b.width,b.height);e?n.bindTexture(n.TEXTURE_CUBE_MAP,null):n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null)}var f,j;b?(e=e?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,c=b.width,b=b.height,
|
||||
j=f=0):(e=null,c=ia,b=ma,f=ca,j=ga);e!=Q&&(n.bindFramebuffer(n.FRAMEBUFFER,e),n.viewport(f,j,c,b),Q=e)}function Y(b){b instanceof THREE.WebGLRenderTargetCube?(n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture),n.generateMipmap(n.TEXTURE_CUBE_MAP),n.bindTexture(n.TEXTURE_CUBE_MAP,null)):(n.bindTexture(n.TEXTURE_2D,b.__webglTexture),n.generateMipmap(n.TEXTURE_2D),n.bindTexture(n.TEXTURE_2D,null))}function G(b,e){var c;b=="fragment"?c=n.createShader(n.FRAGMENT_SHADER):b=="vertex"&&(c=n.createShader(n.VERTEX_SHADER));
|
||||
n.shaderSource(c,e);n.compileShader(c);if(!n.getShaderParameter(c,n.COMPILE_STATUS))return console.error(n.getShaderInfoLog(c)),console.error(e),null;return c}function M(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return n.NEAREST;default:return n.LINEAR}}function L(b){switch(b){case THREE.RepeatWrapping:return n.REPEAT;case THREE.ClampToEdgeWrapping:return n.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return n.MIRRORED_REPEAT;
|
||||
case THREE.NearestFilter:return n.NEAREST;case THREE.NearestMipMapNearestFilter:return n.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return n.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return n.LINEAR;case THREE.LinearMipMapNearestFilter:return n.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return n.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return n.BYTE;case THREE.UnsignedByteType:return n.UNSIGNED_BYTE;case THREE.ShortType:return n.SHORT;case THREE.UnsignedShortType:return n.UNSIGNED_SHORT;
|
||||
case THREE.IntType:return n.INT;case THREE.UnsignedShortType:return n.UNSIGNED_INT;case THREE.FloatType:return n.FLOAT;case THREE.AlphaFormat:return n.ALPHA;case THREE.RGBFormat:return n.RGB;case THREE.RGBAFormat:return n.RGBA;case THREE.LuminanceFormat:return n.LUMINANCE;case THREE.LuminanceAlphaFormat:return n.LUMINANCE_ALPHA}return 0}var P=this,n,V=[],ha=null,R=null,aa=!0,Z=null,ia=null,U=null,ea=null,ga=null,$=null,S=null,W=0,da=0,fa=0,la=0,X=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
|
||||
new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ja=new THREE.Matrix4,qa=new Float32Array(16),ka=new Float32Array(16),ma=new THREE.Vector4,Ga={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},za=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Ja=b.stencil!==void 0?b.stencil:!0,Ka=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,Ua=b.antialias!==void 0?b.antialias:!1,ra=b.clearColor!==void 0?new THREE.Color(b.clearColor):
|
||||
new THREE.Color(0),na=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=za;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ca,ya=[],b=THREE.ShaderLib.depthRGBA,
|
||||
wa=THREE.UniformsUtils.clone(b.uniforms),oa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:wa}),Ea=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:wa,morphTargets:!0});oa._shadowPass=!0;Ea._shadowPass=!0;try{if(!(n=za.getContext("experimental-webgl",{antialias:Ua,stencil:Ja,preserveDrawingBuffer:Ka})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+n.getParameter(n.VERSION)+
|
||||
" | "+n.getParameter(n.VENDOR)+" | "+n.getParameter(n.RENDERER)+" | "+n.getParameter(n.SHADING_LANGUAGE_VERSION))}catch(Ha){console.error(Ha)}n.clearColor(0,0,0,1);n.clearDepth(1);n.clearStencil(0);n.enable(n.DEPTH_TEST);n.depthFunc(n.LEQUAL);n.frontFace(n.CCW);n.cullFace(n.BACK);n.enable(n.CULL_FACE);n.enable(n.BLEND);n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA);n.clearColor(ra.r,ra.g,ra.b,na);this.context=n;var ta=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,
|
||||
case THREE.IntType:return n.INT;case THREE.UnsignedShortType:return n.UNSIGNED_INT;case THREE.FloatType:return n.FLOAT;case THREE.AlphaFormat:return n.ALPHA;case THREE.RGBFormat:return n.RGB;case THREE.RGBAFormat:return n.RGBA;case THREE.LuminanceFormat:return n.LUMINANCE;case THREE.LuminanceAlphaFormat:return n.LUMINANCE_ALPHA}return 0}var S=this,n,V=[],fa=null,Q=null,da=!0,$=null,ka=null,U=null,aa=null,ja=null,ha=null,X=null,ca=0,ga=0,ia=0,ma=0,Z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
|
||||
new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Matrix4,ra=new Float32Array(16),la=new Float32Array(16),sa=new THREE.Vector4,Ha={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},oa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),va=b.stencil!==void 0?b.stencil:!0,Ja=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,Da=b.antialias!==void 0?b.antialias:!1,pa=b.clearColor!==void 0?new THREE.Color(b.clearColor):
|
||||
new THREE.Color(0),ta=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=oa;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ea,ya=[],b=THREE.ShaderLib.depthRGBA,
|
||||
xa=THREE.UniformsUtils.clone(b.uniforms),wa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:xa}),Ea=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:xa,morphTargets:!0});wa._shadowPass=!0;Ea._shadowPass=!0;try{if(!(n=oa.getContext("experimental-webgl",{antialias:Da,stencil:va,preserveDrawingBuffer:Ja})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+n.getParameter(n.VERSION)+
|
||||
" | "+n.getParameter(n.VENDOR)+" | "+n.getParameter(n.RENDERER)+" | "+n.getParameter(n.SHADING_LANGUAGE_VERSION))}catch(Fa){console.error(Fa)}n.clearColor(0,0,0,1);n.clearDepth(1);n.clearStencil(0);n.enable(n.DEPTH_TEST);n.depthFunc(n.LEQUAL);n.frontFace(n.CCW);n.cullFace(n.BACK);n.enable(n.CULL_FACE);n.enable(n.BLEND);n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA);n.clearColor(pa.r,pa.g,pa.b,ta);this.context=n;var na=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,
|
||||
T={};T.vertices=new Float32Array(16);T.faces=new Uint16Array(6);i=0;T.vertices[i++]=-1;T.vertices[i++]=-1;T.vertices[i++]=0;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=-1;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=0;T.vertices[i++]=-1;T.vertices[i++]=1;T.vertices[i++]=0;i=T.vertices[i++]=0;T.faces[i++]=0;T.faces[i++]=1;T.faces[i++]=2;T.faces[i++]=0;T.faces[i++]=2;T.faces[i++]=3;T.vertexBuffer=n.createBuffer();T.elementBuffer=n.createBuffer();
|
||||
n.bindBuffer(n.ARRAY_BUFFER,T.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,T.vertices,n.STATIC_DRAW);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,T.elementBuffer);n.bufferData(n.ELEMENT_ARRAY_BUFFER,T.faces,n.STATIC_DRAW);T.program=n.createProgram();n.attachShader(T.program,F("fragment",THREE.ShaderLib.sprite.fragmentShader));n.attachShader(T.program,F("vertex",THREE.ShaderLib.sprite.vertexShader));n.linkProgram(T.program);T.attributes={};T.uniforms={};T.attributes.position=n.getAttribLocation(T.program,"position");
|
||||
n.bindBuffer(n.ARRAY_BUFFER,T.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,T.vertices,n.STATIC_DRAW);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,T.elementBuffer);n.bufferData(n.ELEMENT_ARRAY_BUFFER,T.faces,n.STATIC_DRAW);T.program=n.createProgram();n.attachShader(T.program,G("fragment",THREE.ShaderLib.sprite.fragmentShader));n.attachShader(T.program,G("vertex",THREE.ShaderLib.sprite.vertexShader));n.linkProgram(T.program);T.attributes={};T.uniforms={};T.attributes.position=n.getAttribLocation(T.program,"position");
|
||||
T.attributes.uv=n.getAttribLocation(T.program,"uv");T.uniforms.uvOffset=n.getUniformLocation(T.program,"uvOffset");T.uniforms.uvScale=n.getUniformLocation(T.program,"uvScale");T.uniforms.rotation=n.getUniformLocation(T.program,"rotation");T.uniforms.scale=n.getUniformLocation(T.program,"scale");T.uniforms.alignment=n.getUniformLocation(T.program,"alignment");T.uniforms.map=n.getUniformLocation(T.program,"map");T.uniforms.opacity=n.getUniformLocation(T.program,"opacity");T.uniforms.useScreenCoordinates=
|
||||
n.getUniformLocation(T.program,"useScreenCoordinates");T.uniforms.affectedByDistance=n.getUniformLocation(T.program,"affectedByDistance");T.uniforms.screenPosition=n.getUniformLocation(T.program,"screenPosition");T.uniforms.modelViewMatrix=n.getUniformLocation(T.program,"modelViewMatrix");T.uniforms.projectionMatrix=n.getUniformLocation(T.program,"projectionMatrix");var Ba=!1;this.setSize=function(b,c){za.width=b;za.height=c;this.setViewport(0,0,za.width,za.height)};this.setViewport=function(b,c,
|
||||
e,f){W=b;da=c;fa=e;la=f;n.viewport(W,da,fa,la)};this.setScissor=function(b,c,e,f){n.scissor(b,c,e,f)};this.enableScissorTest=function(b){b?n.enable(n.SCISSOR_TEST):n.disable(n.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){aa=b;n.depthMask(b)};this.setClearColorHex=function(b,c){ra.setHex(b);na=c;n.clearColor(ra.r,ra.g,ra.b,na)};this.setClearColor=function(b,c){ra.copy(b);na=c;n.clearColor(ra.r,ra.g,ra.b,na)};this.clear=function(){n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT|n.STENCIL_BUFFER_BIT)};
|
||||
this.getContext=function(){return n};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];n.deleteBuffer(c.__webglVertexBuffer);n.deleteBuffer(c.__webglNormalBuffer);n.deleteBuffer(c.__webglTangentBuffer);n.deleteBuffer(c.__webglColorBuffer);n.deleteBuffer(c.__webglUVBuffer);
|
||||
n.deleteBuffer(c.__webglUV2Buffer);n.deleteBuffer(c.__webglSkinVertexABuffer);n.deleteBuffer(c.__webglSkinVertexBBuffer);n.deleteBuffer(c.__webglSkinIndicesBuffer);n.deleteBuffer(c.__webglSkinWeightsBuffer);n.deleteBuffer(c.__webglFaceBuffer);n.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var e=0,f=c.numMorphTargets;e<f;e++)n.deleteBuffer(c.__webglMorphTargetsBuffers[e])}else if(b instanceof THREE.Ribbon)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer);
|
||||
else if(b instanceof THREE.Line)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.ParticleSystem)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer)};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,n.deleteTexture(b.__webglTexture)};this.initMaterial=function(b,c,e,f){var h,j,k;b instanceof THREE.MeshDepthMaterial?k="depth":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 o,u,v;o=v=m=0;for(u=c.length;o<u;o++)j=c[o],j instanceof THREE.SpotLight&&v++,j instanceof THREE.DirectionalLight&&
|
||||
v++,j instanceof THREE.PointLight&&m++;m+v<=_maxLights?o=v:(o=Math.ceil(_maxLights*v/(m+v)),m=_maxLights-o);j={directional:o,point:m};m=v=0;for(o=c.length;m<o;m++)u=c[m],u instanceof THREE.SpotLight&&u.castShadow&&v++;var t=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)t=f.bones.length;var p;a:{o=b.fragmentShader;u=b.vertexShader;var m=b.uniforms,c=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,
|
||||
morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:j.directional,maxPointLights:j.point,maxBones:t,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:v,alphaTest:b.alphaTest},w,f=[];k?f.push(k):(f.push(o),f.push(u));for(w in e)f.push(w),f.push(e[w]);k=f.join();w=0;for(f=V.length;w<f;w++)if(V[w].code==k){p=V[w].program;break a}w=n.createProgram();f=[ta?
|
||||
"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":"",e.sizeAttenuation?
|
||||
n.getUniformLocation(T.program,"useScreenCoordinates");T.uniforms.affectedByDistance=n.getUniformLocation(T.program,"affectedByDistance");T.uniforms.screenPosition=n.getUniformLocation(T.program,"screenPosition");T.uniforms.modelViewMatrix=n.getUniformLocation(T.program,"modelViewMatrix");T.uniforms.projectionMatrix=n.getUniformLocation(T.program,"projectionMatrix");var Aa=!1;this.setSize=function(b,e){oa.width=b;oa.height=e;this.setViewport(0,0,oa.width,oa.height)};this.setViewport=function(b,e,
|
||||
c,f){ca=b;ga=e;ia=c;ma=f;n.viewport(ca,ga,ia,ma)};this.setScissor=function(b,e,c,f){n.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?n.enable(n.SCISSOR_TEST):n.disable(n.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){da=b;n.depthMask(b)};this.setClearColorHex=function(b,e){pa.setHex(b);ta=e;n.clearColor(pa.r,pa.g,pa.b,ta)};this.setClearColor=function(b,e){pa.copy(b);ta=e;n.clearColor(pa.r,pa.g,pa.b,ta)};this.clear=function(){n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT|n.STENCIL_BUFFER_BIT)};
|
||||
this.getContext=function(){return n};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var e=b.geometry.geometryGroups[g];n.deleteBuffer(e.__webglVertexBuffer);n.deleteBuffer(e.__webglNormalBuffer);n.deleteBuffer(e.__webglTangentBuffer);n.deleteBuffer(e.__webglColorBuffer);n.deleteBuffer(e.__webglUVBuffer);
|
||||
n.deleteBuffer(e.__webglUV2Buffer);n.deleteBuffer(e.__webglSkinVertexABuffer);n.deleteBuffer(e.__webglSkinVertexBBuffer);n.deleteBuffer(e.__webglSkinIndicesBuffer);n.deleteBuffer(e.__webglSkinWeightsBuffer);n.deleteBuffer(e.__webglFaceBuffer);n.deleteBuffer(e.__webglLineBuffer);if(e.numMorphTargets)for(var c=0,f=e.numMorphTargets;c<f;c++)n.deleteBuffer(e.__webglMorphTargetsBuffers[c])}else if(b instanceof THREE.Ribbon)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer);
|
||||
else if(b instanceof THREE.Line)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.ParticleSystem)b=b.geometry,n.deleteBuffer(b.__webglVertexBuffer),n.deleteBuffer(b.__webglColorBuffer)};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,n.deleteTexture(b.__webglTexture)};this.initMaterial=function(b,e,c,f){var j,h,k;b instanceof THREE.MeshDepthMaterial?k="depth":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 o,p,v;o=v=m=0;for(p=e.length;o<p;o++)h=e[o],h instanceof THREE.SpotLight&&v++,h instanceof THREE.DirectionalLight&&
|
||||
v++,h instanceof THREE.PointLight&&m++;m+v<=_maxLights?o=v:(o=Math.ceil(_maxLights*v/(m+v)),m=_maxLights-o);h={directional:o,point:m};m=v=0;for(o=e.length;m<o;m++)p=e[m],p instanceof THREE.SpotLight&&p.castShadow&&v++;var t=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)t=f.bones.length;var u;a:{o=b.fragmentShader;p=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:h.directional,maxPointLights:h.point,maxBones:t,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:v,alphaTest:b.alphaTest},w,f=[];k?f.push(k):(f.push(o),f.push(p));for(w in c)f.push(w),f.push(c[w]);k=f.join();w=0;for(f=V.length;w<f;w++)if(V[w].code==k){u=V[w].program;break a}w=n.createProgram();f=[na?
|
||||
"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#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.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",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");
|
||||
j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,e.alphaTest?"#define ALPHATEST "+e.alphaTest:"",e.fog?"#define USE_FOG":"",e.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":
|
||||
"",e.shadowMapSoft?"#define SHADOWMAP_WIDTH "+e.shadowMapWidth.toFixed(1):"",e.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+e.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");n.attachShader(w,F("fragment",j+o));n.attachShader(w,F("vertex",f+u));n.linkProgram(w);n.getProgramParameter(w,n.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+n.getProgramParameter(w,n.VALIDATE_STATUS)+", gl error ["+n.getError()+"]");w.uniforms=
|
||||
{};w.attributes={};var y,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(y in m)f.push(y);y=f;f=0;for(m=y.length;f<m;f++)o=y[f],w.uniforms[o]=n.getUniformLocation(w,o);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(y=0;y<e.maxMorphTargets;y++)f.push("morphTarget"+y);for(p in c)f.push(p);p=f;y=0;for(c=p.length;y<c;y++)e=
|
||||
p[y],w.attributes[e]=n.getAttribLocation(w,e);V.push({program:w,code:k});p=w}b.program=p;p=b.program.attributes;p.position>=0&&n.enableVertexAttribArray(p.position);p.color>=0&&n.enableVertexAttribArray(p.color);p.normal>=0&&n.enableVertexAttribArray(p.normal);p.tangent>=0&&n.enableVertexAttribArray(p.tangent);b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(n.enableVertexAttribArray(p.skinVertexA),n.enableVertexAttribArray(p.skinVertexB),n.enableVertexAttribArray(p.skinIndex),
|
||||
n.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(h in b.attributes)p[h]!==void 0&&p[h]>=0&&n.enableVertexAttribArray(p[h]);if(b.morphTargets)for(h=b.numSupportedMorphTargets=0;h<this.maxMorphTargets;h++)y="morphTarget"+h,p[y]>=0&&(n.enableVertexAttribArray(p[y]),b.numSupportedMorphTargets++)};this.clearTarget=function(b,c,e,f){E(b);b=0;c&&(b|=n.COLOR_BUFFER_BIT);e&&(b|=n.DEPTH_BUFFER_BIT);f&&(b|=n.STENCIL_BUFFER_BIT);n.clear(b)};this.render=function(b,c,n,p){var z,D,H,I,X,J,K,F,C=b.lights,
|
||||
N=b.fog;this.shadowMapEnabled&&y(b,c);P.data.vertices=0;P.data.faces=0;P.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(ka);c.projectionMatrix.flattenToArray(qa);ja.multiply(c.projectionMatrix,c.matrixWorldInverse);o(ja);this.initWebGLObjects(b);E(n);(this.autoClear||p)&&this.clear();X=b.__webglObjects.length;for(p=0;p<X;p++)if(z=b.__webglObjects[p],K=z.object,K.visible)if(!(K instanceof THREE.Mesh)||t(K)){if(K.matrixWorld.flattenToArray(K._objectMatrixArray),
|
||||
B(K,c,!0),w(z),z.render=!0,this.sortObjects)z.object.renderDepth?z.z=z.object.renderDepth:(ma.copy(K.position),ja.multiplyVector3(ma),z.z=ma.z)}else z.render=!1;else z.render=!1;this.sortObjects&&b.__webglObjects.sort(u);J=b.__webglObjectsImmediate.length;for(p=0;p<J;p++)z=b.__webglObjectsImmediate[p],K=z.object,K.visible&&(K.matrixAutoUpdate&&K.matrixWorld.flattenToArray(K._objectMatrixArray),B(K,c,!0),v(z));if(b.overrideMaterial){j(b.overrideMaterial.depthTest);M(b.overrideMaterial.blending);for(p=
|
||||
0;p<X;p++)if(z=b.__webglObjects[p],z.render)K=z.object,F=z.buffer,k(K),f(c,C,N,b.overrideMaterial,F,K);for(p=0;p<J;p++)z=b.__webglObjectsImmediate[p],K=z.object,K.visible&&(k(K),D=e(c,C,N,b.overrideMaterial,K),K.render(function(c){h(c,D,b.overrideMaterial.shading)}))}else{M(THREE.NormalBlending);for(p=X-1;p>=0;p--)if(z=b.__webglObjects[p],z.render){K=z.object;F=z.buffer;H=z.opaque;k(K);for(z=0;z<H.count;z++)I=H.list[z],j(I.depthTest),m(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),f(c,
|
||||
C,N,I,F,K)}for(p=0;p<J;p++)if(z=b.__webglObjectsImmediate[p],K=z.object,K.visible){H=z.opaque;k(K);for(z=0;z<H.count;z++)I=H.list[z],j(I.depthTest),m(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),D=e(c,C,N,I,K),K.render(function(b){h(b,D,I.shading)})}for(p=0;p<X;p++)if(z=b.__webglObjects[p],z.render){K=z.object;F=z.buffer;H=z.transparent;k(K);for(z=0;z<H.count;z++)I=H.list[z],M(I.blending),j(I.depthTest),m(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),f(c,C,N,I,F,K)}for(p=
|
||||
0;p<J;p++)if(z=b.__webglObjectsImmediate[p],K=z.object,K.visible){H=z.transparent;k(K);for(z=0;z<H.count;z++)I=H.list[z],M(I.blending),j(I.depthTest),m(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),D=e(c,C,N,I,K),K.render(function(b){h(b,D,I.shading)})}}b.__webglSprites.length&&x(b,c);n&&n.minFilter!==THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter&&Y(n)};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglSprites=[];
|
||||
for(;b.__objectsAdded.length;){var e=b.__objectsAdded[0],f=b,h=void 0,j=void 0,k=void 0;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray),e instanceof THREE.Mesh)for(h in j=e.geometry,j.geometryGroups==void 0&&I(j),j.geometryGroups){k=j.geometryGroups[h];if(!k.__webglVertexBuffer){var m=k;m.__webglVertexBuffer=
|
||||
h=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",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":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":
|
||||
"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");n.attachShader(w,G("fragment",h+o));n.attachShader(w,G("vertex",f+p));n.linkProgram(w);n.getProgramParameter(w,n.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+n.getProgramParameter(w,n.VALIDATE_STATUS)+", gl error ["+n.getError()+"]");w.uniforms=
|
||||
{};w.attributes={};var x,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(x in m)f.push(x);x=f;f=0;for(m=x.length;f<m;f++)o=x[f],w.uniforms[o]=n.getUniformLocation(w,o);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(x=0;x<c.maxMorphTargets;x++)f.push("morphTarget"+x);for(u in e)f.push(u);u=f;x=0;for(e=u.length;x<e;x++)c=
|
||||
u[x],w.attributes[c]=n.getAttribLocation(w,c);V.push({program:w,code:k});u=w}b.program=u;u=b.program.attributes;u.position>=0&&n.enableVertexAttribArray(u.position);u.color>=0&&n.enableVertexAttribArray(u.color);u.normal>=0&&n.enableVertexAttribArray(u.normal);u.tangent>=0&&n.enableVertexAttribArray(u.tangent);b.skinning&&u.skinVertexA>=0&&u.skinVertexB>=0&&u.skinIndex>=0&&u.skinWeight>=0&&(n.enableVertexAttribArray(u.skinVertexA),n.enableVertexAttribArray(u.skinVertexB),n.enableVertexAttribArray(u.skinIndex),
|
||||
n.enableVertexAttribArray(u.skinWeight));if(b.attributes)for(j in b.attributes)u[j]!==void 0&&u[j]>=0&&n.enableVertexAttribArray(u[j]);if(b.morphTargets)for(j=b.numSupportedMorphTargets=0;j<this.maxMorphTargets;j++)x="morphTarget"+j,u[x]>=0&&(n.enableVertexAttribArray(u[x]),b.numSupportedMorphTargets++)};this.clearTarget=function(b,c,e,f){F(b);b=0;c&&(b|=n.COLOR_BUFFER_BIT);e&&(b|=n.DEPTH_BUFFER_BIT);f&&(b|=n.STENCIL_BUFFER_BIT);n.clear(b)};this.render=function(b,c,n,t){var z,D,C,E,Z,I,J,G,K=b.lights,
|
||||
M=b.fog;this.shadowMapEnabled&&y(b,c);S.data.vertices=0;S.data.faces=0;S.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(la);c.projectionMatrix.flattenToArray(ra);N.multiply(c.projectionMatrix,c.matrixWorldInverse);p(N);this.initWebGLObjects(b);F(n);(this.autoClear||t)&&this.clear();Z=b.__webglObjects.length;for(t=0;t<Z;t++)if(z=b.__webglObjects[t],J=z.object,J.visible)if(!(J instanceof THREE.Mesh)||o(J)){if(J.matrixWorld.flattenToArray(J._objectMatrixArray),
|
||||
B(J,c,!0),w(z),z.render=!0,this.sortObjects)z.object.renderDepth?z.z=z.object.renderDepth:(sa.copy(J.position),N.multiplyVector3(sa),z.z=sa.z)}else z.render=!1;else z.render=!1;this.sortObjects&&b.__webglObjects.sort(u);I=b.__webglObjectsImmediate.length;for(t=0;t<I;t++)z=b.__webglObjectsImmediate[t],J=z.object,J.visible&&(J.matrixAutoUpdate&&J.matrixWorld.flattenToArray(J._objectMatrixArray),B(J,c,!0),v(z));if(b.overrideMaterial){j(b.overrideMaterial.depthTest);O(b.overrideMaterial.blending);for(t=
|
||||
0;t<Z;t++)if(z=b.__webglObjects[t],z.render)J=z.object,G=z.buffer,k(J),f(c,K,M,b.overrideMaterial,G,J);for(t=0;t<I;t++)z=b.__webglObjectsImmediate[t],J=z.object,J.visible&&(k(J),D=e(c,K,M,b.overrideMaterial,J),J.render(function(c){h(c,D,b.overrideMaterial.shading)}))}else{O(THREE.NormalBlending);for(t=Z-1;t>=0;t--)if(z=b.__webglObjects[t],z.render){J=z.object;G=z.buffer;C=z.opaque;k(J);for(z=0;z<C.count;z++)E=C.list[z],j(E.depthTest),m(E.polygonOffset,E.polygonOffsetFactor,E.polygonOffsetUnits),f(c,
|
||||
K,M,E,G,J)}for(t=0;t<I;t++)if(z=b.__webglObjectsImmediate[t],J=z.object,J.visible){C=z.opaque;k(J);for(z=0;z<C.count;z++)E=C.list[z],j(E.depthTest),m(E.polygonOffset,E.polygonOffsetFactor,E.polygonOffsetUnits),D=e(c,K,M,E,J),J.render(function(b){h(b,D,E.shading)})}for(t=0;t<Z;t++)if(z=b.__webglObjects[t],z.render){J=z.object;G=z.buffer;C=z.transparent;k(J);for(z=0;z<C.count;z++)E=C.list[z],O(E.blending),j(E.depthTest),m(E.polygonOffset,E.polygonOffsetFactor,E.polygonOffsetUnits),f(c,K,M,E,G,J)}for(t=
|
||||
0;t<I;t++)if(z=b.__webglObjectsImmediate[t],J=z.object,J.visible){C=z.transparent;k(J);for(z=0;z<C.count;z++)E=C.list[z],O(E.blending),j(E.depthTest),m(E.polygonOffset,E.polygonOffsetFactor,E.polygonOffsetUnits),D=e(c,K,M,E,J),J.render(function(b){h(b,D,E.shading)})}}b.__webglSprites.length&&x(b,c);n&&n.minFilter!==THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter&&Y(n)};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglSprites=[];
|
||||
for(;b.__objectsAdded.length;){var e=b.__objectsAdded[0],f=b,j=void 0,h=void 0,k=void 0;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray),e instanceof THREE.Mesh)for(j in h=e.geometry,h.geometryGroups==void 0&&E(h),h.geometryGroups){k=h.geometryGroups[j];if(!k.__webglVertexBuffer){var m=k;m.__webglVertexBuffer=
|
||||
n.createBuffer();m.__webglNormalBuffer=n.createBuffer();m.__webglTangentBuffer=n.createBuffer();m.__webglColorBuffer=n.createBuffer();m.__webglUVBuffer=n.createBuffer();m.__webglUV2Buffer=n.createBuffer();m.__webglSkinVertexABuffer=n.createBuffer();m.__webglSkinVertexBBuffer=n.createBuffer();m.__webglSkinIndicesBuffer=n.createBuffer();m.__webglSkinWeightsBuffer=n.createBuffer();m.__webglFaceBuffer=n.createBuffer();m.__webglLineBuffer=n.createBuffer();if(m.numMorphTargets){var o=void 0,p=void 0;m.__webglMorphTargetsBuffers=
|
||||
[];o=0;for(p=m.numMorphTargets;o<p;o++)m.__webglMorphTargetsBuffers.push(n.createBuffer())}for(var m=k,o=e,u=void 0,v=void 0,t=void 0,w=t=void 0,y=void 0,x=void 0,B=x=p=0,X=t=v=void 0,J=X=v=u=void 0,t=void 0,w=o.geometry,y=w.faces,X=m.faces,u=0,v=X.length;u<v;u++)t=X[u],t=y[t],t instanceof THREE.Face3?(p+=3,x+=1,B+=3):t instanceof THREE.Face4&&(p+=4,x+=2,B+=4);for(var u=m,v=o,E=X=y=void 0,F=void 0,E=void 0,t=[],y=0,X=v.materials.length;y<X;y++)if(E=v.materials[y],E instanceof THREE.MeshFaceMaterial){E=
|
||||
0;for(l=u.materials.length;E<l;E++)(F=u.materials[E])&&t.push(F)}else(F=E)&&t.push(F);u=t;m.__materials=u;a:{y=v=void 0;X=u.length;for(v=0;v<X;v++)if(y=u[v],y.map||y.lightMap||y instanceof THREE.MeshShaderMaterial){v=!0;break a}v=!1}a:{X=y=void 0;t=u.length;for(y=0;y<t;y++)if(X=u[y],!(X instanceof THREE.MeshBasicMaterial&&!X.envMap||X instanceof THREE.MeshDepthMaterial)){X=X&&X.shading!=void 0&&X.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}X=!1}a:{t=y=void 0;E=u.length;
|
||||
for(y=0;y<E;y++)if(t=u[y],t.vertexColors){t=t.vertexColors;break a}t=!1}m.__vertexArray=new Float32Array(p*3);if(X)m.__normalArray=new Float32Array(p*3);if(w.hasTangents)m.__tangentArray=new Float32Array(p*4);if(t)m.__colorArray=new Float32Array(p*3);if(v){if(w.faceUvs.length>0||w.faceVertexUvs.length>0)m.__uvArray=new Float32Array(p*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(p*2)}if(o.geometry.skinWeights.length&&o.geometry.skinIndices.length)m.__skinVertexAArray=
|
||||
new Float32Array(p*4),m.__skinVertexBArray=new Float32Array(p*4),m.__skinIndexArray=new Float32Array(p*4),m.__skinWeightArray=new Float32Array(p*4);m.__faceArray=new Uint16Array(x*3+(o.geometry.edgeFaces?o.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(B*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];w=0;for(y=m.numMorphTargets;w<y;w++)m.__morphTargetsArrays.push(new Float32Array(p*3))}m.__needsSmoothNormals=X==THREE.SmoothShading;m.__uvType=v;m.__vertexColorType=t;m.__normalType=
|
||||
X;m.__webglFaceCount=x*3+(o.geometry.edgeFaces?o.geometry.edgeFaces.length*6:0);m.__webglLineCount=B*2;w=0;for(y=u.length;w<y;w++)if(v=u[w],v.attributes){if(m.__webglCustomAttributes===void 0)m.__webglCustomAttributes={};for(a in v.attributes){t=v.attributes[a];X={};for(J in t)X[J]=t[J];if(!X.__webglInitialized||X.createUniqueBuffers)X.__webglInitialized=!0,x=1,X.type==="v2"?x=2:X.type==="v3"?x=3:X.type==="v4"?x=4:X.type==="c"&&(x=3),X.size=x,X.array=new Float32Array(p*x),X.buffer=n.createBuffer(),
|
||||
X.buffer.belongsToAttribute=a,t.needsUpdate=!0,X.__original=t;m.__webglCustomAttributes[a]=X}}m.__inittedArrays=!0;j.__dirtyVertices=!0;j.__dirtyMorphTargets=!0;j.__dirtyElements=!0;j.__dirtyUvs=!0;j.__dirtyNormals=!0;j.__dirtyTangents=!0;j.__dirtyColors=!0}K(f.__webglObjects,k,e)}else if(e instanceof THREE.Ribbon){j=e.geometry;if(!j.__webglVertexBuffer)h=j,h.__webglVertexBuffer=n.createBuffer(),h.__webglColorBuffer=n.createBuffer(),h=j,k=h.vertices.length,h.__vertexArray=new Float32Array(k*3),h.__colorArray=
|
||||
new Float32Array(k*3),h.__webglVertexCount=k,j.__dirtyVertices=!0,j.__dirtyColors=!0;K(f.__webglObjects,j,e)}else if(e instanceof THREE.Line){j=e.geometry;if(!j.__webglVertexBuffer)h=j,h.__webglVertexBuffer=n.createBuffer(),h.__webglColorBuffer=n.createBuffer(),h=j,k=h.vertices.length,h.__vertexArray=new Float32Array(k*3),h.__colorArray=new Float32Array(k*3),h.__webglLineCount=k,j.__dirtyVertices=!0,j.__dirtyColors=!0;K(f.__webglObjects,j,e)}else if(e instanceof THREE.ParticleSystem){j=e.geometry;
|
||||
if(!j.__webglVertexBuffer){h=j;h.__webglVertexBuffer=n.createBuffer();h.__webglColorBuffer=n.createBuffer();h=j;k=e;m=h.vertices.length;h.__vertexArray=new Float32Array(m*3);h.__colorArray=new Float32Array(m*3);h.__sortArray=[];h.__webglParticleCount=m;h.__materials=k.materials;J=p=o=void 0;o=0;for(p=k.materials.length;o<p;o++)if(J=k.materials[o],J.attributes){if(h.__webglCustomAttributes===void 0)h.__webglCustomAttributes={};for(a in J.attributes){originalAttribute=J.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=
|
||||
originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(m*size),attribute.buffer=n.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;h.__webglCustomAttributes[a]=attribute}}j.__dirtyVertices=
|
||||
!0;j.__dirtyColors=!0}K(f.__webglObjects,j,e)}else THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes?f.__webglObjectsImmediate.push({object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}}):e instanceof THREE.Sprite&&f.__webglSprites.push(e);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){f=b.__objectsRemoved[0];e=b;if(f instanceof THREE.Mesh||f instanceof THREE.ParticleSystem||f instanceof THREE.Ribbon||f instanceof THREE.Line)D(e.__webglObjects,f);else if(f instanceof
|
||||
THREE.Sprite){e=e.__webglSprites;j=void 0;for(j=e.length-1;j>=0;j--)e[j]==f&&e.splice(j,1)}else f instanceof THREE.MarchingCubes&&D(e.__webglObjectsImmediate,f);b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e<f;e++)if(h=b.__webglObjects[e].object,o=m=j=k=void 0,h instanceof THREE.Mesh){j=h.geometry;for(k in j.geometryGroups)if(m=j.geometryGroups[k],o=z(m),j.__dirtyVertices||j.__dirtyMorphTargets||j.__dirtyElements||j.__dirtyUvs||j.__dirtyNormals||j.__dirtyColors||j.__dirtyTangents||
|
||||
o)if(o=m,p=n.DYNAMIC_DRAW,J=!j.dynamic,o.__inittedArrays){var ja=B=x=void 0,C=void 0,N=ja=void 0,M=void 0,qa=void 0,L=void 0,S=F=E=t=X=y=v=u=w=void 0,G=C=L=C=qa=M=void 0,A=void 0,O=A=G=M=void 0,W=void 0,R=O=A=G=ja=ja=N=L=C=O=A=G=W=O=A=G=W=O=A=G=void 0,P=0,ka=0,Y=0,T=0,V=0,da=0,U=0,ia=0,fa=0,Q=0,Z=0,O=G=0,O=void 0,$=o.__vertexArray,ga=o.__uvArray,ha=o.__uv2Array,ea=o.__normalArray,ma=o.__tangentArray,la=o.__colorArray,aa=o.__skinVertexAArray,ca=o.__skinVertexBArray,ua=o.__skinIndexArray,va=o.__skinWeightArray,
|
||||
ta=o.__morphTargetsArrays,na=o.__webglCustomAttributes,A=void 0,ra=o.__faceArray,oa=o.__lineArray,za=o.__needsSmoothNormals,u=o.__vertexColorType,w=o.__uvType,v=o.__normalType,xa=h.geometry,Ga=xa.__dirtyVertices,wa=xa.__dirtyElements,ya=xa.__dirtyUvs,Ba=xa.__dirtyNormals,Ja=xa.__dirtyTangents,Ka=xa.__dirtyColors,Ea=xa.__dirtyMorphTargets,Qa=xa.vertices,Ha=o.faces,Ua=xa.faces,bb=xa.faceVertexUvs[0],cb=xa.faceVertexUvs[1],Ra=xa.skinVerticesA,Sa=xa.skinVerticesB,Ta=xa.skinIndices,Ia=xa.skinWeights,Fa=
|
||||
xa.morphTargets;if(na)for(R in na)na[R].offset=0,na[R].offsetSrc=0;x=0;for(B=Ha.length;x<B;x++)if(ja=Ha[x],C=Ua[ja],bb&&(y=bb[ja]),cb&&(X=cb[ja]),ja=C.vertexNormals,N=C.normal,M=C.vertexColors,qa=C.color,L=C.vertexTangents,C instanceof THREE.Face3){if(Ga)t=Qa[C.a].position,E=Qa[C.b].position,F=Qa[C.c].position,$[ka]=t.x,$[ka+1]=t.y,$[ka+2]=t.z,$[ka+3]=E.x,$[ka+4]=E.y,$[ka+5]=E.z,$[ka+6]=F.x,$[ka+7]=F.y,$[ka+8]=F.z,ka+=9;if(na)for(R in na)if(A=na[R],A.__original.needsUpdate)G=A.offset,O=A.offsetSrc,
|
||||
A.size===1?(A.boundTo===void 0||A.boundTo==="vertices"?(A.array[G]=A.value[C.a],A.array[G+1]=A.value[C.b],A.array[G+2]=A.value[C.c]):A.boundTo==="faces"?(O=A.value[O],A.array[G]=O,A.array[G+1]=O,A.array[G+2]=O,A.offsetSrc++):A.boundTo==="faceVertices"&&(A.array[G]=A.value[O],A.array[G+1]=A.value[O+1],A.array[G+2]=A.value[O+2],A.offsetSrc+=3),A.offset+=3):(A.boundTo===void 0||A.boundTo==="vertices"?(t=A.value[C.a],E=A.value[C.b],F=A.value[C.c]):A.boundTo==="faces"?(F=E=t=O=A.value[O],A.offsetSrc++):
|
||||
A.boundTo==="faceVertices"&&(t=A.value[O],E=A.value[O+1],F=A.value[O+2],A.offsetSrc+=3),A.size===2?(A.array[G]=t.x,A.array[G+1]=t.y,A.array[G+2]=E.x,A.array[G+3]=E.y,A.array[G+4]=F.x,A.array[G+5]=F.y,A.offset+=6):A.size===3?(A.type==="c"?(A.array[G]=t.r,A.array[G+1]=t.g,A.array[G+2]=t.b,A.array[G+3]=E.r,A.array[G+4]=E.g,A.array[G+5]=E.b,A.array[G+6]=F.r,A.array[G+7]=F.g,A.array[G+8]=F.b):(A.array[G]=t.x,A.array[G+1]=t.y,A.array[G+2]=t.z,A.array[G+3]=E.x,A.array[G+4]=E.y,A.array[G+5]=E.z,A.array[G+
|
||||
6]=F.x,A.array[G+7]=F.y,A.array[G+8]=F.z),A.offset+=9):(A.array[G]=t.x,A.array[G+1]=t.y,A.array[G+2]=t.z,A.array[G+3]=t.w,A.array[G+4]=E.x,A.array[G+5]=E.y,A.array[G+6]=E.z,A.array[G+7]=E.w,A.array[G+8]=F.x,A.array[G+9]=F.y,A.array[G+10]=F.z,A.array[G+11]=F.w,A.offset+=12));if(Ea){G=0;for(A=Fa.length;G<A;G++)t=Fa[G].vertices[C.a].position,E=Fa[G].vertices[C.b].position,F=Fa[G].vertices[C.c].position,O=ta[G],O[Z]=t.x,O[Z+1]=t.y,O[Z+2]=t.z,O[Z+3]=E.x,O[Z+4]=E.y,O[Z+5]=E.z,O[Z+6]=F.x,O[Z+7]=F.y,O[Z+
|
||||
8]=F.z;Z+=9}if(Ia.length)G=Ia[C.a],A=Ia[C.b],O=Ia[C.c],va[Q]=G.x,va[Q+1]=G.y,va[Q+2]=G.z,va[Q+3]=G.w,va[Q+4]=A.x,va[Q+5]=A.y,va[Q+6]=A.z,va[Q+7]=A.w,va[Q+8]=O.x,va[Q+9]=O.y,va[Q+10]=O.z,va[Q+11]=O.w,G=Ta[C.a],A=Ta[C.b],O=Ta[C.c],ua[Q]=G.x,ua[Q+1]=G.y,ua[Q+2]=G.z,ua[Q+3]=G.w,ua[Q+4]=A.x,ua[Q+5]=A.y,ua[Q+6]=A.z,ua[Q+7]=A.w,ua[Q+8]=O.x,ua[Q+9]=O.y,ua[Q+10]=O.z,ua[Q+11]=O.w,G=Ra[C.a],A=Ra[C.b],O=Ra[C.c],aa[Q]=G.x,aa[Q+1]=G.y,aa[Q+2]=G.z,aa[Q+3]=1,aa[Q+4]=A.x,aa[Q+5]=A.y,aa[Q+6]=A.z,aa[Q+7]=1,aa[Q+8]=
|
||||
O.x,aa[Q+9]=O.y,aa[Q+10]=O.z,aa[Q+11]=1,G=Sa[C.a],A=Sa[C.b],O=Sa[C.c],ca[Q]=G.x,ca[Q+1]=G.y,ca[Q+2]=G.z,ca[Q+3]=1,ca[Q+4]=A.x,ca[Q+5]=A.y,ca[Q+6]=A.z,ca[Q+7]=1,ca[Q+8]=O.x,ca[Q+9]=O.y,ca[Q+10]=O.z,ca[Q+11]=1,Q+=12;if(Ka&&u)M.length==3&&u==THREE.VertexColors?(C=M[0],G=M[1],A=M[2]):A=G=C=qa,la[fa]=C.r,la[fa+1]=C.g,la[fa+2]=C.b,la[fa+3]=G.r,la[fa+4]=G.g,la[fa+5]=G.b,la[fa+6]=A.r,la[fa+7]=A.g,la[fa+8]=A.b,fa+=9;if(Ja&&xa.hasTangents)M=L[0],qa=L[1],C=L[2],ma[U]=M.x,ma[U+1]=M.y,ma[U+2]=M.z,ma[U+3]=M.w,
|
||||
ma[U+4]=qa.x,ma[U+5]=qa.y,ma[U+6]=qa.z,ma[U+7]=qa.w,ma[U+8]=C.x,ma[U+9]=C.y,ma[U+10]=C.z,ma[U+11]=C.w,U+=12;if(Ba&&v)if(ja.length==3&&za)for(L=0;L<3;L++)N=ja[L],ea[da]=N.x,ea[da+1]=N.y,ea[da+2]=N.z,da+=3;else for(L=0;L<3;L++)ea[da]=N.x,ea[da+1]=N.y,ea[da+2]=N.z,da+=3;if(ya&&y!==void 0&&w)for(L=0;L<3;L++)ja=y[L],ga[Y]=ja.u,ga[Y+1]=ja.v,Y+=2;if(ya&&X!==void 0&&w)for(L=0;L<3;L++)ja=X[L],ha[T]=ja.u,ha[T+1]=ja.v,T+=2;wa&&(ra[V]=P,ra[V+1]=P+1,ra[V+2]=P+2,V+=3,oa[ia]=P,oa[ia+1]=P+1,oa[ia+2]=P,oa[ia+3]=P+
|
||||
2,oa[ia+4]=P+1,oa[ia+5]=P+2,ia+=6,P+=3)}else if(C instanceof THREE.Face4){if(Ga)t=Qa[C.a].position,E=Qa[C.b].position,F=Qa[C.c].position,S=Qa[C.d].position,$[ka]=t.x,$[ka+1]=t.y,$[ka+2]=t.z,$[ka+3]=E.x,$[ka+4]=E.y,$[ka+5]=E.z,$[ka+6]=F.x,$[ka+7]=F.y,$[ka+8]=F.z,$[ka+9]=S.x,$[ka+10]=S.y,$[ka+11]=S.z,ka+=12;if(na)for(R in na)if(A=na[R],A.__original.needsUpdate)G=A.offset,O=A.offsetSrc,A.size===1?(A.boundTo===void 0||A.boundTo==="vertices"?(A.array[G]=A.value[C.a],A.array[G+1]=A.value[C.b],A.array[G+
|
||||
2]=A.value[C.c],A.array[G+3]=A.value[C.d]):A.boundTo==="faces"?(O=A.value[O],A.array[G]=O,A.array[G+1]=O,A.array[G+2]=O,A.array[G+3]=O,A.offsetSrc++):A.boundTo==="faceVertices"&&(A.array[G]=A.value[O],A.array[G+1]=A.value[O+1],A.array[G+2]=A.value[O+2],A.array[G+3]=A.value[O+3],A.offsetSrc+=4),A.offset+=4):(A.boundTo===void 0||A.boundTo==="vertices"?(t=A.value[C.a],E=A.value[C.b],F=A.value[C.c],S=A.value[C.d]):A.boundTo==="faces"?(S=F=E=t=O=A.value[O],A.offsetSrc++):A.boundTo==="faceVertices"&&(t=
|
||||
A.value[O],E=A.value[O+1],F=A.value[O+2],S=A.value[O+3],A.offsetSrc+=4),A.size===2?(A.array[G]=t.x,A.array[G+1]=t.y,A.array[G+2]=E.x,A.array[G+3]=E.y,A.array[G+4]=F.x,A.array[G+5]=F.y,A.array[G+6]=S.x,A.array[G+7]=S.y,A.offset+=8):A.size===3?(A.type==="c"?(A.array[G]=t.r,A.array[G+1]=t.g,A.array[G+2]=t.b,A.array[G+3]=E.r,A.array[G+4]=E.g,A.array[G+5]=E.b,A.array[G+6]=F.r,A.array[G+7]=F.g,A.array[G+8]=F.b,A.array[G+9]=S.r,A.array[G+10]=S.g,A.array[G+11]=S.b):(A.array[G]=t.x,A.array[G+1]=t.y,A.array[G+
|
||||
2]=t.z,A.array[G+3]=E.x,A.array[G+4]=E.y,A.array[G+5]=E.z,A.array[G+6]=F.x,A.array[G+7]=F.y,A.array[G+8]=F.z,A.array[G+9]=S.x,A.array[G+10]=S.y,A.array[G+11]=S.z),A.offset+=12):(A.array[G]=t.x,A.array[G+1]=t.y,A.array[G+2]=t.z,A.array[G+3]=t.w,A.array[G+4]=E.x,A.array[G+5]=E.y,A.array[G+6]=E.z,A.array[G+7]=E.w,A.array[G+8]=F.x,A.array[G+9]=F.y,A.array[G+10]=F.z,A.array[G+11]=F.w,A.array[G+12]=S.x,A.array[G+13]=S.y,A.array[G+14]=S.z,A.array[G+15]=S.w,A.offset+=16));if(Ea){G=0;for(A=Fa.length;G<A;G++)t=
|
||||
Fa[G].vertices[C.a].position,E=Fa[G].vertices[C.b].position,F=Fa[G].vertices[C.c].position,S=Fa[G].vertices[C.d].position,O=ta[G],O[Z]=t.x,O[Z+1]=t.y,O[Z+2]=t.z,O[Z+3]=E.x,O[Z+4]=E.y,O[Z+5]=E.z,O[Z+6]=F.x,O[Z+7]=F.y,O[Z+8]=F.z,O[Z+9]=S.x,O[Z+10]=S.y,O[Z+11]=S.z;Z+=12}if(Ia.length)G=Ia[C.a],A=Ia[C.b],O=Ia[C.c],W=Ia[C.d],va[Q]=G.x,va[Q+1]=G.y,va[Q+2]=G.z,va[Q+3]=G.w,va[Q+4]=A.x,va[Q+5]=A.y,va[Q+6]=A.z,va[Q+7]=A.w,va[Q+8]=O.x,va[Q+9]=O.y,va[Q+10]=O.z,va[Q+11]=O.w,va[Q+12]=W.x,va[Q+13]=W.y,va[Q+14]=W.z,
|
||||
va[Q+15]=W.w,G=Ta[C.a],A=Ta[C.b],O=Ta[C.c],W=Ta[C.d],ua[Q]=G.x,ua[Q+1]=G.y,ua[Q+2]=G.z,ua[Q+3]=G.w,ua[Q+4]=A.x,ua[Q+5]=A.y,ua[Q+6]=A.z,ua[Q+7]=A.w,ua[Q+8]=O.x,ua[Q+9]=O.y,ua[Q+10]=O.z,ua[Q+11]=O.w,ua[Q+12]=W.x,ua[Q+13]=W.y,ua[Q+14]=W.z,ua[Q+15]=W.w,G=Ra[C.a],A=Ra[C.b],O=Ra[C.c],W=Ra[C.d],aa[Q]=G.x,aa[Q+1]=G.y,aa[Q+2]=G.z,aa[Q+3]=1,aa[Q+4]=A.x,aa[Q+5]=A.y,aa[Q+6]=A.z,aa[Q+7]=1,aa[Q+8]=O.x,aa[Q+9]=O.y,aa[Q+10]=O.z,aa[Q+11]=1,aa[Q+12]=W.x,aa[Q+13]=W.y,aa[Q+14]=W.z,aa[Q+15]=1,G=Sa[C.a],A=Sa[C.b],O=Sa[C.c],
|
||||
C=Sa[C.d],ca[Q]=G.x,ca[Q+1]=G.y,ca[Q+2]=G.z,ca[Q+3]=1,ca[Q+4]=A.x,ca[Q+5]=A.y,ca[Q+6]=A.z,ca[Q+7]=1,ca[Q+8]=O.x,ca[Q+9]=O.y,ca[Q+10]=O.z,ca[Q+11]=1,ca[Q+12]=C.x,ca[Q+13]=C.y,ca[Q+14]=C.z,ca[Q+15]=1,Q+=16;if(Ka&&u)M.length==4&&u==THREE.VertexColors?(C=M[0],G=M[1],A=M[2],M=M[3]):M=A=G=C=qa,la[fa]=C.r,la[fa+1]=C.g,la[fa+2]=C.b,la[fa+3]=G.r,la[fa+4]=G.g,la[fa+5]=G.b,la[fa+6]=A.r,la[fa+7]=A.g,la[fa+8]=A.b,la[fa+9]=M.r,la[fa+10]=M.g,la[fa+11]=M.b,fa+=12;if(Ja&&xa.hasTangents)M=L[0],qa=L[1],C=L[2],L=L[3],
|
||||
ma[U]=M.x,ma[U+1]=M.y,ma[U+2]=M.z,ma[U+3]=M.w,ma[U+4]=qa.x,ma[U+5]=qa.y,ma[U+6]=qa.z,ma[U+7]=qa.w,ma[U+8]=C.x,ma[U+9]=C.y,ma[U+10]=C.z,ma[U+11]=C.w,ma[U+12]=L.x,ma[U+13]=L.y,ma[U+14]=L.z,ma[U+15]=L.w,U+=16;if(Ba&&v)if(ja.length==4&&za)for(L=0;L<4;L++)N=ja[L],ea[da]=N.x,ea[da+1]=N.y,ea[da+2]=N.z,da+=3;else for(L=0;L<4;L++)ea[da]=N.x,ea[da+1]=N.y,ea[da+2]=N.z,da+=3;if(ya&&y!==void 0&&w)for(L=0;L<4;L++)ja=y[L],ga[Y]=ja.u,ga[Y+1]=ja.v,Y+=2;if(ya&&X!==void 0&&w)for(L=0;L<4;L++)ja=X[L],ha[T]=ja.u,ha[T+
|
||||
1]=ja.v,T+=2;wa&&(ra[V]=P,ra[V+1]=P+1,ra[V+2]=P+3,ra[V+3]=P+1,ra[V+4]=P+2,ra[V+5]=P+3,V+=6,oa[ia]=P,oa[ia+1]=P+1,oa[ia+2]=P,oa[ia+3]=P+3,oa[ia+4]=P+1,oa[ia+5]=P+2,oa[ia+6]=P+2,oa[ia+7]=P+3,ia+=8,P+=4)}Ga&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglVertexBuffer),n.bufferData(n.ARRAY_BUFFER,$,p));if(na)for(R in na)A=na[R],A.__original.needsUpdate&&(n.bindBuffer(n.ARRAY_BUFFER,A.buffer),n.bufferData(n.ARRAY_BUFFER,A.array,p));if(Ea){G=0;for(A=Fa.length;G<A;G++)n.bindBuffer(n.ARRAY_BUFFER,o.__webglMorphTargetsBuffers[G]),
|
||||
n.bufferData(n.ARRAY_BUFFER,ta[G],p)}Ka&&fa>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglColorBuffer),n.bufferData(n.ARRAY_BUFFER,la,p));Ba&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglNormalBuffer),n.bufferData(n.ARRAY_BUFFER,ea,p));Ja&&xa.hasTangents&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglTangentBuffer),n.bufferData(n.ARRAY_BUFFER,ma,p));ya&&Y>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUVBuffer),n.bufferData(n.ARRAY_BUFFER,ga,p));ya&&T>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUV2Buffer),n.bufferData(n.ARRAY_BUFFER,
|
||||
ha,p));wa&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,o.__webglFaceBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,ra,p),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,oa,p));Q>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexABuffer),n.bufferData(n.ARRAY_BUFFER,aa,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexBBuffer),n.bufferData(n.ARRAY_BUFFER,ca,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinIndicesBuffer),n.bufferData(n.ARRAY_BUFFER,ua,p),n.bindBuffer(n.ARRAY_BUFFER,
|
||||
o.__webglSkinWeightsBuffer),n.bufferData(n.ARRAY_BUFFER,va,p));J&&(delete o.__inittedArrays,delete o.__colorArray,delete o.__normalArray,delete o.__tangentArray,delete o.__uvArray,delete o.__uv2Array,delete o.__faceArray,delete o.__vertexArray,delete o.__lineArray,delete o.__skinVertexAArray,delete o.__skinVertexBArray,delete o.__skinIndexArray,delete o.__skinWeightArray)}j.__dirtyVertices=!1;j.__dirtyMorphTargets=!1;j.__dirtyElements=!1;j.__dirtyUvs=!1;j.__dirtyNormals=!1;j.__dirtyTangents=!1;j.__dirtyColors=
|
||||
!1;H(m)}else if(h instanceof THREE.Ribbon){j=h.geometry;if(j.__dirtyVertices||j.__dirtyColors){h=j;k=n.DYNAMIC_DRAW;m=B=x=x=void 0;w=h.vertices;o=h.colors;u=w.length;p=o.length;v=h.__vertexArray;J=h.__colorArray;y=h.__dirtyColors;if(h.__dirtyVertices){for(x=0;x<u;x++)B=w[x].position,m=x*3,v[m]=B.x,v[m+1]=B.y,v[m+2]=B.z;n.bindBuffer(n.ARRAY_BUFFER,h.__webglVertexBuffer);n.bufferData(n.ARRAY_BUFFER,v,k)}if(y){for(x=0;x<p;x++)color=o[x],m=x*3,J[m]=color.r,J[m+1]=color.g,J[m+2]=color.b;n.bindBuffer(n.ARRAY_BUFFER,
|
||||
h.__webglColorBuffer);n.bufferData(n.ARRAY_BUFFER,J,k)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(h instanceof THREE.Line){j=h.geometry;if(j.__dirtyVertices||j.__dirtyColors){h=j;k=n.DYNAMIC_DRAW;m=B=x=x=void 0;w=h.vertices;o=h.colors;u=w.length;p=o.length;v=h.__vertexArray;J=h.__colorArray;y=h.__dirtyColors;if(h.__dirtyVertices){for(x=0;x<u;x++)B=w[x].position,m=x*3,v[m]=B.x,v[m+1]=B.y,v[m+2]=B.z;n.bindBuffer(n.ARRAY_BUFFER,h.__webglVertexBuffer);n.bufferData(n.ARRAY_BUFFER,v,k)}if(y){for(x=
|
||||
0;x<p;x++)color=o[x],m=x*3,J[m]=color.r,J[m+1]=color.g,J[m+2]=color.b;n.bindBuffer(n.ARRAY_BUFFER,h.__webglColorBuffer);n.bufferData(n.ARRAY_BUFFER,J,k)}}j.__dirtyVertices=!1;j.__dirtyColors=!1}else if(h instanceof THREE.ParticleSystem)j=h.geometry,o=z(j),(j.__dirtyVertices||j.__dirtyColors||h.sortParticles||o)&&c(j,n.DYNAMIC_DRAW,h),j.__dirtyVertices=!1,j.__dirtyColors=!1,H(j)};this.setFaceCulling=function(b,c){b?(!c||c=="ccw"?n.frontFace(n.CCW):n.frontFace(n.CW),b=="back"?n.cullFace(n.BACK):b==
|
||||
"front"?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK),n.enable(n.CULL_FACE)):n.disable(n.CULL_FACE)};this.supportsVertexTextures=function(){return ta}};
|
||||
[];o=0;for(p=m.numMorphTargets;o<p;o++)m.__webglMorphTargetsBuffers.push(n.createBuffer())}for(var m=k,o=e,t=void 0,v=void 0,u=void 0,w=u=void 0,x=void 0,y=void 0,B=y=p=0,Z=u=v=void 0,I=Z=v=t=void 0,u=void 0,w=o.geometry,x=w.faces,Z=m.faces,t=0,v=Z.length;t<v;t++)u=Z[t],u=x[u],u instanceof THREE.Face3?(p+=3,y+=1,B+=3):u instanceof THREE.Face4&&(p+=4,y+=2,B+=4);for(var t=m,v=o,F=Z=x=void 0,G=void 0,F=void 0,u=[],x=0,Z=v.materials.length;x<Z;x++)if(F=v.materials[x],F instanceof THREE.MeshFaceMaterial){F=
|
||||
0;for(l=t.materials.length;F<l;F++)(G=t.materials[F])&&u.push(G)}else(G=F)&&u.push(G);t=u;m.__materials=t;a:{x=v=void 0;Z=t.length;for(v=0;v<Z;v++)if(x=t[v],x.map||x.lightMap||x instanceof THREE.MeshShaderMaterial){v=!0;break a}v=!1}a:{Z=x=void 0;u=t.length;for(x=0;x<u;x++)if(Z=t[x],!(Z instanceof THREE.MeshBasicMaterial&&!Z.envMap||Z instanceof THREE.MeshDepthMaterial)){Z=Z&&Z.shading!=void 0&&Z.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}Z=!1}a:{u=x=void 0;F=t.length;
|
||||
for(x=0;x<F;x++)if(u=t[x],u.vertexColors){u=u.vertexColors;break a}u=!1}m.__vertexArray=new Float32Array(p*3);if(Z)m.__normalArray=new Float32Array(p*3);if(w.hasTangents)m.__tangentArray=new Float32Array(p*4);if(u)m.__colorArray=new Float32Array(p*3);if(v){if(w.faceUvs.length>0||w.faceVertexUvs.length>0)m.__uvArray=new Float32Array(p*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(p*2)}if(o.geometry.skinWeights.length&&o.geometry.skinIndices.length)m.__skinVertexAArray=
|
||||
new Float32Array(p*4),m.__skinVertexBArray=new Float32Array(p*4),m.__skinIndexArray=new Float32Array(p*4),m.__skinWeightArray=new Float32Array(p*4);m.__faceArray=new Uint16Array(y*3+(o.geometry.edgeFaces?o.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(B*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];w=0;for(x=m.numMorphTargets;w<x;w++)m.__morphTargetsArrays.push(new Float32Array(p*3))}m.__needsSmoothNormals=Z==THREE.SmoothShading;m.__uvType=v;m.__vertexColorType=u;m.__normalType=
|
||||
Z;m.__webglFaceCount=y*3+(o.geometry.edgeFaces?o.geometry.edgeFaces.length*6:0);m.__webglLineCount=B*2;w=0;for(x=t.length;w<x;w++)if(v=t[w],v.attributes){if(m.__webglCustomAttributes===void 0)m.__webglCustomAttributes={};for(a in v.attributes){u=v.attributes[a];Z={};for(I in u)Z[I]=u[I];if(!Z.__webglInitialized||Z.createUniqueBuffers)Z.__webglInitialized=!0,y=1,Z.type==="v2"?y=2:Z.type==="v3"?y=3:Z.type==="v4"?y=4:Z.type==="c"&&(y=3),Z.size=y,Z.array=new Float32Array(p*y),Z.buffer=n.createBuffer(),
|
||||
Z.buffer.belongsToAttribute=a,u.needsUpdate=!0,Z.__original=u;m.__webglCustomAttributes[a]=Z}}m.__inittedArrays=!0;h.__dirtyVertices=!0;h.__dirtyMorphTargets=!0;h.__dirtyElements=!0;h.__dirtyUvs=!0;h.__dirtyNormals=!0;h.__dirtyTangents=!0;h.__dirtyColors=!0}J(f.__webglObjects,k,e)}else if(e instanceof THREE.Ribbon){h=e.geometry;if(!h.__webglVertexBuffer)j=h,j.__webglVertexBuffer=n.createBuffer(),j.__webglColorBuffer=n.createBuffer(),j=h,k=j.vertices.length,j.__vertexArray=new Float32Array(k*3),j.__colorArray=
|
||||
new Float32Array(k*3),j.__webglVertexCount=k,h.__dirtyVertices=!0,h.__dirtyColors=!0;J(f.__webglObjects,h,e)}else if(e instanceof THREE.Line){h=e.geometry;if(!h.__webglVertexBuffer)j=h,j.__webglVertexBuffer=n.createBuffer(),j.__webglColorBuffer=n.createBuffer(),j=h,k=j.vertices.length,j.__vertexArray=new Float32Array(k*3),j.__colorArray=new Float32Array(k*3),j.__webglLineCount=k,h.__dirtyVertices=!0,h.__dirtyColors=!0;J(f.__webglObjects,h,e)}else if(e instanceof THREE.ParticleSystem){h=e.geometry;
|
||||
if(!h.__webglVertexBuffer){j=h;j.__webglVertexBuffer=n.createBuffer();j.__webglColorBuffer=n.createBuffer();j=h;k=e;m=j.vertices.length;j.__vertexArray=new Float32Array(m*3);j.__colorArray=new Float32Array(m*3);j.__sortArray=[];j.__webglParticleCount=m;j.__materials=k.materials;I=p=o=void 0;o=0;for(p=k.materials.length;o<p;o++)if(I=k.materials[o],I.attributes){if(j.__webglCustomAttributes===void 0)j.__webglCustomAttributes={};for(a in I.attributes){originalAttribute=I.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=
|
||||
originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(m*size),attribute.buffer=n.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;j.__webglCustomAttributes[a]=attribute}}h.__dirtyVertices=
|
||||
!0;h.__dirtyColors=!0}J(f.__webglObjects,h,e)}else THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes?f.__webglObjectsImmediate.push({object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}}):e instanceof THREE.Sprite&&f.__webglSprites.push(e);b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){f=b.__objectsRemoved[0];e=b;if(f instanceof THREE.Mesh||f instanceof THREE.ParticleSystem||f instanceof THREE.Ribbon||f instanceof THREE.Line)C(e.__webglObjects,f);else if(f instanceof
|
||||
THREE.Sprite){e=e.__webglSprites;h=void 0;for(h=e.length-1;h>=0;h--)e[h]==f&&e.splice(h,1)}else f instanceof THREE.MarchingCubes&&C(e.__webglObjectsImmediate,f);b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e<f;e++)if(j=b.__webglObjects[e].object,o=m=h=k=void 0,j instanceof THREE.Mesh){h=j.geometry;for(k in h.geometryGroups)if(m=h.geometryGroups[k],o=z(m),h.__dirtyVertices||h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||
|
||||
o)if(o=m,p=n.DYNAMIC_DRAW,I=!h.dynamic,o.__inittedArrays){var K=B=y=void 0,N=void 0,O=K=void 0,M=void 0,ra=void 0,L=void 0,la=G=F=u=Z=x=v=t=w=void 0,H=N=L=N=ra=M=void 0,A=void 0,P=A=H=M=void 0,X=void 0,ca=P=A=H=K=K=O=L=N=P=A=H=X=P=A=H=X=P=A=H=void 0,Q=0,S=0,Y=0,T=0,V=0,ga=0,U=0,ka=0,sa=0,R=0,ia=0,P=H=0,P=void 0,$=o.__vertexArray,ha=o.__uvArray,ja=o.__uv2Array,fa=o.__normalArray,aa=o.__tangentArray,ma=o.__colorArray,da=o.__skinVertexAArray,ea=o.__skinVertexBArray,oa=o.__skinIndexArray,ua=o.__skinWeightArray,
|
||||
Ha=o.__morphTargetsArrays,pa=o.__webglCustomAttributes,A=void 0,ta=o.__faceArray,na=o.__lineArray,wa=o.__needsSmoothNormals,t=o.__vertexColorType,w=o.__uvType,v=o.__normalType,va=j.geometry,xa=va.__dirtyVertices,Ja=va.__dirtyElements,Da=va.__dirtyUvs,ya=va.__dirtyNormals,Aa=va.__dirtyTangents,Ea=va.__dirtyColors,Fa=va.__dirtyMorphTargets,Pa=va.vertices,$a=o.faces,cb=va.faces,ab=va.faceVertexUvs[0],bb=va.faceVertexUvs[1],Qa=va.skinVerticesA,Ra=va.skinVerticesB,Sa=va.skinIndices,Ia=va.skinWeights,Ga=
|
||||
va.morphTargets;if(pa)for(ca in pa)pa[ca].offset=0,pa[ca].offsetSrc=0;y=0;for(B=$a.length;y<B;y++)if(K=$a[y],N=cb[K],ab&&(x=ab[K]),bb&&(Z=bb[K]),K=N.vertexNormals,O=N.normal,M=N.vertexColors,ra=N.color,L=N.vertexTangents,N instanceof THREE.Face3){if(xa)u=Pa[N.a].position,F=Pa[N.b].position,G=Pa[N.c].position,$[S]=u.x,$[S+1]=u.y,$[S+2]=u.z,$[S+3]=F.x,$[S+4]=F.y,$[S+5]=F.z,$[S+6]=G.x,$[S+7]=G.y,$[S+8]=G.z,S+=9;if(pa)for(ca in pa)if(A=pa[ca],A.__original.needsUpdate)H=A.offset,P=A.offsetSrc,A.size===
|
||||
1?(A.boundTo===void 0||A.boundTo==="vertices"?(A.array[H]=A.value[N.a],A.array[H+1]=A.value[N.b],A.array[H+2]=A.value[N.c]):A.boundTo==="faces"?(P=A.value[P],A.array[H]=P,A.array[H+1]=P,A.array[H+2]=P,A.offsetSrc++):A.boundTo==="faceVertices"&&(A.array[H]=A.value[P],A.array[H+1]=A.value[P+1],A.array[H+2]=A.value[P+2],A.offsetSrc+=3),A.offset+=3):(A.boundTo===void 0||A.boundTo==="vertices"?(u=A.value[N.a],F=A.value[N.b],G=A.value[N.c]):A.boundTo==="faces"?(G=F=u=P=A.value[P],A.offsetSrc++):A.boundTo===
|
||||
"faceVertices"&&(u=A.value[P],F=A.value[P+1],G=A.value[P+2],A.offsetSrc+=3),A.size===2?(A.array[H]=u.x,A.array[H+1]=u.y,A.array[H+2]=F.x,A.array[H+3]=F.y,A.array[H+4]=G.x,A.array[H+5]=G.y,A.offset+=6):A.size===3?(A.type==="c"?(A.array[H]=u.r,A.array[H+1]=u.g,A.array[H+2]=u.b,A.array[H+3]=F.r,A.array[H+4]=F.g,A.array[H+5]=F.b,A.array[H+6]=G.r,A.array[H+7]=G.g,A.array[H+8]=G.b):(A.array[H]=u.x,A.array[H+1]=u.y,A.array[H+2]=u.z,A.array[H+3]=F.x,A.array[H+4]=F.y,A.array[H+5]=F.z,A.array[H+6]=G.x,A.array[H+
|
||||
7]=G.y,A.array[H+8]=G.z),A.offset+=9):(A.array[H]=u.x,A.array[H+1]=u.y,A.array[H+2]=u.z,A.array[H+3]=u.w,A.array[H+4]=F.x,A.array[H+5]=F.y,A.array[H+6]=F.z,A.array[H+7]=F.w,A.array[H+8]=G.x,A.array[H+9]=G.y,A.array[H+10]=G.z,A.array[H+11]=G.w,A.offset+=12));if(Fa){H=0;for(A=Ga.length;H<A;H++)u=Ga[H].vertices[N.a].position,F=Ga[H].vertices[N.b].position,G=Ga[H].vertices[N.c].position,P=Ha[H],P[ia]=u.x,P[ia+1]=u.y,P[ia+2]=u.z,P[ia+3]=F.x,P[ia+4]=F.y,P[ia+5]=F.z,P[ia+6]=G.x,P[ia+7]=G.y,P[ia+8]=G.z;ia+=
|
||||
9}if(Ia.length)H=Ia[N.a],A=Ia[N.b],P=Ia[N.c],ua[R]=H.x,ua[R+1]=H.y,ua[R+2]=H.z,ua[R+3]=H.w,ua[R+4]=A.x,ua[R+5]=A.y,ua[R+6]=A.z,ua[R+7]=A.w,ua[R+8]=P.x,ua[R+9]=P.y,ua[R+10]=P.z,ua[R+11]=P.w,H=Sa[N.a],A=Sa[N.b],P=Sa[N.c],oa[R]=H.x,oa[R+1]=H.y,oa[R+2]=H.z,oa[R+3]=H.w,oa[R+4]=A.x,oa[R+5]=A.y,oa[R+6]=A.z,oa[R+7]=A.w,oa[R+8]=P.x,oa[R+9]=P.y,oa[R+10]=P.z,oa[R+11]=P.w,H=Qa[N.a],A=Qa[N.b],P=Qa[N.c],da[R]=H.x,da[R+1]=H.y,da[R+2]=H.z,da[R+3]=1,da[R+4]=A.x,da[R+5]=A.y,da[R+6]=A.z,da[R+7]=1,da[R+8]=P.x,da[R+9]=
|
||||
P.y,da[R+10]=P.z,da[R+11]=1,H=Ra[N.a],A=Ra[N.b],P=Ra[N.c],ea[R]=H.x,ea[R+1]=H.y,ea[R+2]=H.z,ea[R+3]=1,ea[R+4]=A.x,ea[R+5]=A.y,ea[R+6]=A.z,ea[R+7]=1,ea[R+8]=P.x,ea[R+9]=P.y,ea[R+10]=P.z,ea[R+11]=1,R+=12;if(Ea&&t)M.length==3&&t==THREE.VertexColors?(N=M[0],H=M[1],A=M[2]):A=H=N=ra,ma[sa]=N.r,ma[sa+1]=N.g,ma[sa+2]=N.b,ma[sa+3]=H.r,ma[sa+4]=H.g,ma[sa+5]=H.b,ma[sa+6]=A.r,ma[sa+7]=A.g,ma[sa+8]=A.b,sa+=9;if(Aa&&va.hasTangents)M=L[0],ra=L[1],N=L[2],aa[U]=M.x,aa[U+1]=M.y,aa[U+2]=M.z,aa[U+3]=M.w,aa[U+4]=ra.x,
|
||||
aa[U+5]=ra.y,aa[U+6]=ra.z,aa[U+7]=ra.w,aa[U+8]=N.x,aa[U+9]=N.y,aa[U+10]=N.z,aa[U+11]=N.w,U+=12;if(ya&&v)if(K.length==3&&wa)for(L=0;L<3;L++)O=K[L],fa[ga]=O.x,fa[ga+1]=O.y,fa[ga+2]=O.z,ga+=3;else for(L=0;L<3;L++)fa[ga]=O.x,fa[ga+1]=O.y,fa[ga+2]=O.z,ga+=3;if(Da&&x!==void 0&&w)for(L=0;L<3;L++)K=x[L],ha[Y]=K.u,ha[Y+1]=K.v,Y+=2;if(Da&&Z!==void 0&&w)for(L=0;L<3;L++)K=Z[L],ja[T]=K.u,ja[T+1]=K.v,T+=2;Ja&&(ta[V]=Q,ta[V+1]=Q+1,ta[V+2]=Q+2,V+=3,na[ka]=Q,na[ka+1]=Q+1,na[ka+2]=Q,na[ka+3]=Q+2,na[ka+4]=Q+1,na[ka+
|
||||
5]=Q+2,ka+=6,Q+=3)}else if(N instanceof THREE.Face4){if(xa)u=Pa[N.a].position,F=Pa[N.b].position,G=Pa[N.c].position,la=Pa[N.d].position,$[S]=u.x,$[S+1]=u.y,$[S+2]=u.z,$[S+3]=F.x,$[S+4]=F.y,$[S+5]=F.z,$[S+6]=G.x,$[S+7]=G.y,$[S+8]=G.z,$[S+9]=la.x,$[S+10]=la.y,$[S+11]=la.z,S+=12;if(pa)for(ca in pa)if(A=pa[ca],A.__original.needsUpdate)H=A.offset,P=A.offsetSrc,A.size===1?(A.boundTo===void 0||A.boundTo==="vertices"?(A.array[H]=A.value[N.a],A.array[H+1]=A.value[N.b],A.array[H+2]=A.value[N.c],A.array[H+3]=
|
||||
A.value[N.d]):A.boundTo==="faces"?(P=A.value[P],A.array[H]=P,A.array[H+1]=P,A.array[H+2]=P,A.array[H+3]=P,A.offsetSrc++):A.boundTo==="faceVertices"&&(A.array[H]=A.value[P],A.array[H+1]=A.value[P+1],A.array[H+2]=A.value[P+2],A.array[H+3]=A.value[P+3],A.offsetSrc+=4),A.offset+=4):(A.boundTo===void 0||A.boundTo==="vertices"?(u=A.value[N.a],F=A.value[N.b],G=A.value[N.c],la=A.value[N.d]):A.boundTo==="faces"?(la=G=F=u=P=A.value[P],A.offsetSrc++):A.boundTo==="faceVertices"&&(u=A.value[P],F=A.value[P+1],
|
||||
G=A.value[P+2],la=A.value[P+3],A.offsetSrc+=4),A.size===2?(A.array[H]=u.x,A.array[H+1]=u.y,A.array[H+2]=F.x,A.array[H+3]=F.y,A.array[H+4]=G.x,A.array[H+5]=G.y,A.array[H+6]=la.x,A.array[H+7]=la.y,A.offset+=8):A.size===3?(A.type==="c"?(A.array[H]=u.r,A.array[H+1]=u.g,A.array[H+2]=u.b,A.array[H+3]=F.r,A.array[H+4]=F.g,A.array[H+5]=F.b,A.array[H+6]=G.r,A.array[H+7]=G.g,A.array[H+8]=G.b,A.array[H+9]=la.r,A.array[H+10]=la.g,A.array[H+11]=la.b):(A.array[H]=u.x,A.array[H+1]=u.y,A.array[H+2]=u.z,A.array[H+
|
||||
3]=F.x,A.array[H+4]=F.y,A.array[H+5]=F.z,A.array[H+6]=G.x,A.array[H+7]=G.y,A.array[H+8]=G.z,A.array[H+9]=la.x,A.array[H+10]=la.y,A.array[H+11]=la.z),A.offset+=12):(A.array[H]=u.x,A.array[H+1]=u.y,A.array[H+2]=u.z,A.array[H+3]=u.w,A.array[H+4]=F.x,A.array[H+5]=F.y,A.array[H+6]=F.z,A.array[H+7]=F.w,A.array[H+8]=G.x,A.array[H+9]=G.y,A.array[H+10]=G.z,A.array[H+11]=G.w,A.array[H+12]=la.x,A.array[H+13]=la.y,A.array[H+14]=la.z,A.array[H+15]=la.w,A.offset+=16));if(Fa){H=0;for(A=Ga.length;H<A;H++)u=Ga[H].vertices[N.a].position,
|
||||
F=Ga[H].vertices[N.b].position,G=Ga[H].vertices[N.c].position,la=Ga[H].vertices[N.d].position,P=Ha[H],P[ia]=u.x,P[ia+1]=u.y,P[ia+2]=u.z,P[ia+3]=F.x,P[ia+4]=F.y,P[ia+5]=F.z,P[ia+6]=G.x,P[ia+7]=G.y,P[ia+8]=G.z,P[ia+9]=la.x,P[ia+10]=la.y,P[ia+11]=la.z;ia+=12}if(Ia.length)H=Ia[N.a],A=Ia[N.b],P=Ia[N.c],X=Ia[N.d],ua[R]=H.x,ua[R+1]=H.y,ua[R+2]=H.z,ua[R+3]=H.w,ua[R+4]=A.x,ua[R+5]=A.y,ua[R+6]=A.z,ua[R+7]=A.w,ua[R+8]=P.x,ua[R+9]=P.y,ua[R+10]=P.z,ua[R+11]=P.w,ua[R+12]=X.x,ua[R+13]=X.y,ua[R+14]=X.z,ua[R+15]=
|
||||
X.w,H=Sa[N.a],A=Sa[N.b],P=Sa[N.c],X=Sa[N.d],oa[R]=H.x,oa[R+1]=H.y,oa[R+2]=H.z,oa[R+3]=H.w,oa[R+4]=A.x,oa[R+5]=A.y,oa[R+6]=A.z,oa[R+7]=A.w,oa[R+8]=P.x,oa[R+9]=P.y,oa[R+10]=P.z,oa[R+11]=P.w,oa[R+12]=X.x,oa[R+13]=X.y,oa[R+14]=X.z,oa[R+15]=X.w,H=Qa[N.a],A=Qa[N.b],P=Qa[N.c],X=Qa[N.d],da[R]=H.x,da[R+1]=H.y,da[R+2]=H.z,da[R+3]=1,da[R+4]=A.x,da[R+5]=A.y,da[R+6]=A.z,da[R+7]=1,da[R+8]=P.x,da[R+9]=P.y,da[R+10]=P.z,da[R+11]=1,da[R+12]=X.x,da[R+13]=X.y,da[R+14]=X.z,da[R+15]=1,H=Ra[N.a],A=Ra[N.b],P=Ra[N.c],N=Ra[N.d],
|
||||
ea[R]=H.x,ea[R+1]=H.y,ea[R+2]=H.z,ea[R+3]=1,ea[R+4]=A.x,ea[R+5]=A.y,ea[R+6]=A.z,ea[R+7]=1,ea[R+8]=P.x,ea[R+9]=P.y,ea[R+10]=P.z,ea[R+11]=1,ea[R+12]=N.x,ea[R+13]=N.y,ea[R+14]=N.z,ea[R+15]=1,R+=16;if(Ea&&t)M.length==4&&t==THREE.VertexColors?(N=M[0],H=M[1],A=M[2],M=M[3]):M=A=H=N=ra,ma[sa]=N.r,ma[sa+1]=N.g,ma[sa+2]=N.b,ma[sa+3]=H.r,ma[sa+4]=H.g,ma[sa+5]=H.b,ma[sa+6]=A.r,ma[sa+7]=A.g,ma[sa+8]=A.b,ma[sa+9]=M.r,ma[sa+10]=M.g,ma[sa+11]=M.b,sa+=12;if(Aa&&va.hasTangents)M=L[0],ra=L[1],N=L[2],L=L[3],aa[U]=M.x,
|
||||
aa[U+1]=M.y,aa[U+2]=M.z,aa[U+3]=M.w,aa[U+4]=ra.x,aa[U+5]=ra.y,aa[U+6]=ra.z,aa[U+7]=ra.w,aa[U+8]=N.x,aa[U+9]=N.y,aa[U+10]=N.z,aa[U+11]=N.w,aa[U+12]=L.x,aa[U+13]=L.y,aa[U+14]=L.z,aa[U+15]=L.w,U+=16;if(ya&&v)if(K.length==4&&wa)for(L=0;L<4;L++)O=K[L],fa[ga]=O.x,fa[ga+1]=O.y,fa[ga+2]=O.z,ga+=3;else for(L=0;L<4;L++)fa[ga]=O.x,fa[ga+1]=O.y,fa[ga+2]=O.z,ga+=3;if(Da&&x!==void 0&&w)for(L=0;L<4;L++)K=x[L],ha[Y]=K.u,ha[Y+1]=K.v,Y+=2;if(Da&&Z!==void 0&&w)for(L=0;L<4;L++)K=Z[L],ja[T]=K.u,ja[T+1]=K.v,T+=2;Ja&&(ta[V]=
|
||||
Q,ta[V+1]=Q+1,ta[V+2]=Q+3,ta[V+3]=Q+1,ta[V+4]=Q+2,ta[V+5]=Q+3,V+=6,na[ka]=Q,na[ka+1]=Q+1,na[ka+2]=Q,na[ka+3]=Q+3,na[ka+4]=Q+1,na[ka+5]=Q+2,na[ka+6]=Q+2,na[ka+7]=Q+3,ka+=8,Q+=4)}xa&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglVertexBuffer),n.bufferData(n.ARRAY_BUFFER,$,p));if(pa)for(ca in pa)A=pa[ca],A.__original.needsUpdate&&(n.bindBuffer(n.ARRAY_BUFFER,A.buffer),n.bufferData(n.ARRAY_BUFFER,A.array,p));if(Fa){H=0;for(A=Ga.length;H<A;H++)n.bindBuffer(n.ARRAY_BUFFER,o.__webglMorphTargetsBuffers[H]),n.bufferData(n.ARRAY_BUFFER,
|
||||
Ha[H],p)}Ea&&sa>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglColorBuffer),n.bufferData(n.ARRAY_BUFFER,ma,p));ya&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglNormalBuffer),n.bufferData(n.ARRAY_BUFFER,fa,p));Aa&&va.hasTangents&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglTangentBuffer),n.bufferData(n.ARRAY_BUFFER,aa,p));Da&&Y>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUVBuffer),n.bufferData(n.ARRAY_BUFFER,ha,p));Da&&T>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUV2Buffer),n.bufferData(n.ARRAY_BUFFER,ja,p));Ja&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,
|
||||
o.__webglFaceBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,ta,p),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,na,p));R>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexABuffer),n.bufferData(n.ARRAY_BUFFER,da,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexBBuffer),n.bufferData(n.ARRAY_BUFFER,ea,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinIndicesBuffer),n.bufferData(n.ARRAY_BUFFER,oa,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinWeightsBuffer),n.bufferData(n.ARRAY_BUFFER,
|
||||
ua,p));I&&(delete o.__inittedArrays,delete o.__colorArray,delete o.__normalArray,delete o.__tangentArray,delete o.__uvArray,delete o.__uv2Array,delete o.__faceArray,delete o.__vertexArray,delete o.__lineArray,delete o.__skinVertexAArray,delete o.__skinVertexBArray,delete o.__skinIndexArray,delete o.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;D(m)}else if(j instanceof THREE.Ribbon){h=
|
||||
j.geometry;if(h.__dirtyVertices||h.__dirtyColors){j=h;k=n.DYNAMIC_DRAW;m=B=y=y=void 0;w=j.vertices;o=j.colors;t=w.length;p=o.length;v=j.__vertexArray;I=j.__colorArray;x=j.__dirtyColors;if(j.__dirtyVertices){for(y=0;y<t;y++)B=w[y].position,m=y*3,v[m]=B.x,v[m+1]=B.y,v[m+2]=B.z;n.bindBuffer(n.ARRAY_BUFFER,j.__webglVertexBuffer);n.bufferData(n.ARRAY_BUFFER,v,k)}if(x){for(y=0;y<p;y++)color=o[y],m=y*3,I[m]=color.r,I[m+1]=color.g,I[m+2]=color.b;n.bindBuffer(n.ARRAY_BUFFER,j.__webglColorBuffer);n.bufferData(n.ARRAY_BUFFER,
|
||||
I,k)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(j instanceof THREE.Line){h=j.geometry;if(h.__dirtyVertices||h.__dirtyColors){j=h;k=n.DYNAMIC_DRAW;m=B=y=y=void 0;w=j.vertices;o=j.colors;t=w.length;p=o.length;v=j.__vertexArray;I=j.__colorArray;x=j.__dirtyColors;if(j.__dirtyVertices){for(y=0;y<t;y++)B=w[y].position,m=y*3,v[m]=B.x,v[m+1]=B.y,v[m+2]=B.z;n.bindBuffer(n.ARRAY_BUFFER,j.__webglVertexBuffer);n.bufferData(n.ARRAY_BUFFER,v,k)}if(x){for(y=0;y<p;y++)color=o[y],m=y*3,I[m]=color.r,I[m+1]=color.g,
|
||||
I[m+2]=color.b;n.bindBuffer(n.ARRAY_BUFFER,j.__webglColorBuffer);n.bufferData(n.ARRAY_BUFFER,I,k)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem)h=j.geometry,o=z(h),(h.__dirtyVertices||h.__dirtyColors||j.sortParticles||o)&&c(h,n.DYNAMIC_DRAW,j),h.__dirtyVertices=!1,h.__dirtyColors=!1,D(h)};this.setFaceCulling=function(b,e){b?(!e||e=="ccw"?n.frontFace(n.CCW):n.frontFace(n.CW),b=="back"?n.cullFace(n.BACK):b=="front"?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK),
|
||||
n.enable(n.CULL_FACE)):n.disable(n.CULL_FACE)};this.supportsVertexTextures=function(){return na}};
|
||||
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.WebGLRenderTarget.prototype.clone=function(){var b=new THREE.WebGLRenderTarget(this.width,this.height);b.wrapS=this.wrapS;b.wrapT=this.wrapT;b.magFilter=this.magFilter;b.minFilter=this.minFilter;b.offset.copy(this.offset);b.repeat.copy(this.repeat);b.format=this.format;b.type=this.type;b.depthBuffer=this.depthBuffer;b.stencilBuffer=this.stencilBuffer;return b};THREE.WebGLRenderTargetCube=function(b,c,e){THREE.WebGLRenderTarget.call(this,b,c,e);this.activeCubeFace=0};
|
||||
@@ -340,18 +340,18 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new
|
||||
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,e,f){var h=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,h);h.h=THREE.ColorUtils.clamp(h.h+c,0,1);h.s=THREE.ColorUtils.clamp(h.s+e,0,1);h.v=THREE.ColorUtils.clamp(h.v+f,0,1);b.setHSV(h.h,h.s,h.v)},rgbToHsv:function(b,c){var e=b.r,f=b.g,h=b.b,k=Math.max(Math.max(e,f),h),j=Math.min(Math.min(e,f),h);if(j==k)j=e=0;else{var m=k-j,j=m/k,e=e==k?(f-h)/m:f==k?2+(h-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=j;c.v=k;return c},
|
||||
clamp:function(b,c,e){return b<c?c:b>e?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
|
||||
THREE.GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,h=e?c.geometry:c,k=b.vertices,j=h.vertices,m=b.faces,o=h.faces,t=b.faceVertexUvs[0],h=h.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var p=0,v=j.length;p<v;p++){var w=new THREE.Vertex(j[p].position.clone());e&&c.matrix.multiplyVector3(w.position);k.push(w)}p=0;for(v=o.length;p<v;p++){var j=o[p],u,y,x=j.vertexNormals,w=j.vertexColors;j instanceof THREE.Face3?u=new THREE.Face3(j.a+f,j.b+f,j.c+
|
||||
f):j instanceof THREE.Face4&&(u=new THREE.Face4(j.a+f,j.b+f,j.c+f,j.d+f));u.normal.copy(j.normal);e=0;for(k=x.length;e<k;e++)y=x[e],u.vertexNormals.push(y.clone());u.color.copy(j.color);e=0;for(k=w.length;e<k;e++)y=w[e],u.vertexColors.push(y.clone());u.materials=j.materials.slice();u.centroid.copy(j.centroid);m.push(u)}p=0;for(v=h.length;p<v;p++){f=h[p];m=[];e=0;for(k=f.length;e<k;e++)m.push(new THREE.UV(f[e].u,f[e].v));t.push(m)}},clone:function(b){var c=new THREE.Geometry,e,f=b.vertices,h=b.faces,
|
||||
k=b.faceVertexUvs[0],b=0;for(e=f.length;b<e;b++){var j=new THREE.Vertex(f[b].position.clone());c.vertices.push(j)}b=0;for(e=h.length;b<e;b++){var m=h[b],o,t,p=m.vertexNormals,v=m.vertexColors;m instanceof THREE.Face3?o=new THREE.Face3(m.a,m.b,m.c):m instanceof THREE.Face4&&(o=new THREE.Face4(m.a,m.b,m.c,m.d));o.normal.copy(m.normal);f=0;for(j=p.length;f<j;f++)t=p[f],o.vertexNormals.push(t.clone());o.color.copy(m.color);f=0;for(j=v.length;f<j;f++)t=v[f],o.vertexColors.push(t.clone());o.materials=m.materials.slice();
|
||||
o.centroid.copy(m.centroid);c.faces.push(o)}b=0;for(e=k.length;b<e;b++){h=k[b];o=[];f=0;for(j=h.length;f<j;f++)o.push(new THREE.UV(h[f].u,h[f].v));c.faceVertexUvs[0].push(o)}return c},randomPointInTriangle:function(b,c,e){var f,h,k,j=new THREE.Vector3,m=THREE.GeometryUtils.__v1;f=THREE.GeometryUtils.random();h=THREE.GeometryUtils.random();f+h>1&&(f=1-f,h=1-h);k=1-f-h;j.copy(b);j.multiplyScalar(f);m.copy(c);m.multiplyScalar(h);j.addSelf(m);m.copy(e);m.multiplyScalar(k);j.addSelf(m);return j},randomPointInFace:function(b,
|
||||
THREE.GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,h=e?c.geometry:c,k=b.vertices,j=h.vertices,m=b.faces,p=h.faces,o=b.faceVertexUvs[0],h=h.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var t=0,v=j.length;t<v;t++){var w=new THREE.Vertex(j[t].position.clone());e&&c.matrix.multiplyVector3(w.position);k.push(w)}t=0;for(v=p.length;t<v;t++){var j=p[t],u,y,x=j.vertexNormals,w=j.vertexColors;j instanceof THREE.Face3?u=new THREE.Face3(j.a+f,j.b+f,j.c+
|
||||
f):j instanceof THREE.Face4&&(u=new THREE.Face4(j.a+f,j.b+f,j.c+f,j.d+f));u.normal.copy(j.normal);e=0;for(k=x.length;e<k;e++)y=x[e],u.vertexNormals.push(y.clone());u.color.copy(j.color);e=0;for(k=w.length;e<k;e++)y=w[e],u.vertexColors.push(y.clone());u.materials=j.materials.slice();u.centroid.copy(j.centroid);m.push(u)}t=0;for(v=h.length;t<v;t++){f=h[t];m=[];e=0;for(k=f.length;e<k;e++)m.push(new THREE.UV(f[e].u,f[e].v));o.push(m)}},clone:function(b){var c=new THREE.Geometry,e,f=b.vertices,h=b.faces,
|
||||
k=b.faceVertexUvs[0],b=0;for(e=f.length;b<e;b++){var j=new THREE.Vertex(f[b].position.clone());c.vertices.push(j)}b=0;for(e=h.length;b<e;b++){var m=h[b],p,o,t=m.vertexNormals,v=m.vertexColors;m instanceof THREE.Face3?p=new THREE.Face3(m.a,m.b,m.c):m instanceof THREE.Face4&&(p=new THREE.Face4(m.a,m.b,m.c,m.d));p.normal.copy(m.normal);f=0;for(j=t.length;f<j;f++)o=t[f],p.vertexNormals.push(o.clone());p.color.copy(m.color);f=0;for(j=v.length;f<j;f++)o=v[f],p.vertexColors.push(o.clone());p.materials=m.materials.slice();
|
||||
p.centroid.copy(m.centroid);c.faces.push(p)}b=0;for(e=k.length;b<e;b++){h=k[b];p=[];f=0;for(j=h.length;f<j;f++)p.push(new THREE.UV(h[f].u,h[f].v));c.faceVertexUvs[0].push(p)}return c},randomPointInTriangle:function(b,c,e){var f,h,k,j=new THREE.Vector3,m=THREE.GeometryUtils.__v1;f=THREE.GeometryUtils.random();h=THREE.GeometryUtils.random();f+h>1&&(f=1-f,h=1-h);k=1-f-h;j.copy(b);j.multiplyScalar(f);m.copy(c);m.multiplyScalar(h);j.addSelf(m);m.copy(e);m.multiplyScalar(k);j.addSelf(m);return j},randomPointInFace:function(b,
|
||||
c,e){var f,h,k;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,h=c.vertices[b.b].position,k=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,h,k);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;h=c.vertices[b.b].position;k=c.vertices[b.c].position;var c=c.vertices[b.d].position,j;e?b._area1&&b._area2?(e=b._area1,j=b._area2):(e=THREE.GeometryUtils.triangleArea(f,h,c),j=THREE.GeometryUtils.triangleArea(h,k,c),b._area1=e,b._area2=j):(e=THREE.GeometryUtils.triangleArea(f,
|
||||
h,c),j=THREE.GeometryUtils.triangleArea(h,k,c));return THREE.GeometryUtils.random()*(e+j)<e?THREE.GeometryUtils.randomPointInTriangle(f,h,c):THREE.GeometryUtils.randomPointInTriangle(h,k,c)}},randomPointsInGeometry:function(b,c){function e(b){function c(e,f){if(f<e)return e;var h=e+Math.floor((f-e)/2);return t[h]>b?c(e,h-1):t[h]<b?c(h+1,f):h}return c(0,t.length-1)}var f,h,k=b.faces,j=b.vertices,m=k.length,o=0,t=[],p,v,w,u;for(h=0;h<m;h++){f=k[h];if(f instanceof THREE.Face3)p=j[f.a].position,v=j[f.b].position,
|
||||
w=j[f.c].position,f._area=THREE.GeometryUtils.triangleArea(p,v,w);else if(f instanceof THREE.Face4)p=j[f.a].position,v=j[f.b].position,w=j[f.c].position,u=j[f.d].position,f._area1=THREE.GeometryUtils.triangleArea(p,v,u),f._area2=THREE.GeometryUtils.triangleArea(v,w,u),f._area=f._area1+f._area2;o+=f._area;t[h]=o}f=[];j={};for(h=0;h<c;h++)m=THREE.GeometryUtils.random()*o,m=e(m),f[h]=THREE.GeometryUtils.randomPointInFace(k[m],b,!0),j[m]?j[m]+=1:j[m]=1;return f},triangleArea:function(b,c,e){var f,h=THREE.GeometryUtils.__v1;
|
||||
h,c),j=THREE.GeometryUtils.triangleArea(h,k,c));return THREE.GeometryUtils.random()*(e+j)<e?THREE.GeometryUtils.randomPointInTriangle(f,h,c):THREE.GeometryUtils.randomPointInTriangle(h,k,c)}},randomPointsInGeometry:function(b,c){function e(b){function e(c,f){if(f<c)return c;var j=c+Math.floor((f-c)/2);return o[j]>b?e(c,j-1):o[j]<b?e(j+1,f):j}return e(0,o.length-1)}var f,h,k=b.faces,j=b.vertices,m=k.length,p=0,o=[],t,v,w,u;for(h=0;h<m;h++){f=k[h];if(f instanceof THREE.Face3)t=j[f.a].position,v=j[f.b].position,
|
||||
w=j[f.c].position,f._area=THREE.GeometryUtils.triangleArea(t,v,w);else if(f instanceof THREE.Face4)t=j[f.a].position,v=j[f.b].position,w=j[f.c].position,u=j[f.d].position,f._area1=THREE.GeometryUtils.triangleArea(t,v,u),f._area2=THREE.GeometryUtils.triangleArea(v,w,u),f._area=f._area1+f._area2;p+=f._area;o[h]=p}f=[];j={};for(h=0;h<c;h++)m=THREE.GeometryUtils.random()*p,m=e(m),f[h]=THREE.GeometryUtils.randomPointInFace(k[m],b,!0),j[m]?j[m]+=1:j[m]=1;return f},triangleArea:function(b,c,e){var f,h=THREE.GeometryUtils.__v1;
|
||||
h.sub(b,c);f=h.length();h.sub(b,e);b=h.length();h.sub(c,e);e=h.length();c=0.5*(f+b+e);return Math.sqrt(c*(c-f)*(c-b)*(c-e))},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.GeometryUtils.random=THREE.GeometryUtils.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
|
||||
THREE.ImageUtils={loadTexture:function(b,c,e){var f=new Image,h=new THREE.Texture(f,c);f.onload=function(){h.needsUpdate=!0;e&&e(this)};f.crossOrigin="";f.src=b;return h},loadTextureCube:function(b,c,e){var f,h=[],k=new THREE.Texture(h,c),c=h.loadCount=0;for(f=b.length;c<f;++c)h[c]=new Image,h[c].onload=function(){h.loadCount+=1;if(h.loadCount==6)k.needsUpdate=!0;e&&e(this)},h[c].crossOrigin="",h[c].src=b[c];return k},getNormalMap:function(b,c){var e=function(b){var c=Math.sqrt(b[0]*b[0]+b[1]*b[1]+
|
||||
b[2]*b[2]);return[b[0]/c,b[1]/c,b[2]/c]};c|=1;var f=b.width,h=b.height,k=document.createElement("canvas");k.width=f;k.height=h;var j=k.getContext("2d");j.drawImage(b,0,0);for(var m=j.getImageData(0,0,f,h).data,o=j.createImageData(f,h),t=o.data,p=0;p<f;p++)for(var v=1;v<h;v++){var w=v-1<0?h-1:v-1,u=(v+1)%h,y=p-1<0?f-1:p-1,x=(p+1)%f,B=[],z=[0,0,m[(v*f+p)*4]/255*c];B.push([-1,0,m[(v*f+y)*4]/255*c]);B.push([-1,-1,m[(w*f+y)*4]/255*c]);B.push([0,-1,m[(w*f+p)*4]/255*c]);B.push([1,-1,m[(w*f+x)*4]/255*c]);
|
||||
B.push([1,0,m[(v*f+x)*4]/255*c]);B.push([1,1,m[(u*f+x)*4]/255*c]);B.push([0,1,m[(u*f+p)*4]/255*c]);B.push([-1,1,m[(u*f+y)*4]/255*c]);w=[];y=B.length;for(u=0;u<y;u++){var x=B[u],H=B[(u+1)%y],x=[x[0]-z[0],x[1]-z[1],x[2]-z[2]],H=[H[0]-z[0],H[1]-z[1],H[2]-z[2]];w.push(e([x[1]*H[2]-x[2]*H[1],x[2]*H[0]-x[0]*H[2],x[0]*H[1]-x[1]*H[0]]))}B=[0,0,0];for(u=0;u<w.length;u++)B[0]+=w[u][0],B[1]+=w[u][1],B[2]+=w[u][2];B[0]/=w.length;B[1]/=w.length;B[2]/=w.length;z=(v*f+p)*4;t[z]=(B[0]+1)/2*255|0;t[z+1]=(B[1]+0.5)*
|
||||
255|0;t[z+2]=B[2]*255|0;t[z+3]=255}j.putImageData(o,0,0);return k}};THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,h=b.children.length;for(f=0;f<h;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
|
||||
THREE.ImageUtils={loadTexture:function(b,c,e){var f=new Image,h=new THREE.Texture(f,c);f.onload=function(){h.needsUpdate=!0;e&&e(this)};f.crossOrigin="";f.src=b;return h},loadTextureCube:function(b,c,e){var f,h=[],k=new THREE.Texture(h,c),c=h.loadCount=0;for(f=b.length;c<f;++c)h[c]=new Image,h[c].onload=function(){h.loadCount+=1;if(h.loadCount==6)k.needsUpdate=!0;e&&e(this)},h[c].crossOrigin="",h[c].src=b[c];return k},getNormalMap:function(b,c){var e=function(b){var e=Math.sqrt(b[0]*b[0]+b[1]*b[1]+
|
||||
b[2]*b[2]);return[b[0]/e,b[1]/e,b[2]/e]};c|=1;var f=b.width,h=b.height,k=document.createElement("canvas");k.width=f;k.height=h;var j=k.getContext("2d");j.drawImage(b,0,0);for(var m=j.getImageData(0,0,f,h).data,p=j.createImageData(f,h),o=p.data,t=0;t<f;t++)for(var v=1;v<h;v++){var w=v-1<0?h-1:v-1,u=(v+1)%h,y=t-1<0?f-1:t-1,x=(t+1)%f,B=[],z=[0,0,m[(v*f+t)*4]/255*c];B.push([-1,0,m[(v*f+y)*4]/255*c]);B.push([-1,-1,m[(w*f+y)*4]/255*c]);B.push([0,-1,m[(w*f+t)*4]/255*c]);B.push([1,-1,m[(w*f+x)*4]/255*c]);
|
||||
B.push([1,0,m[(v*f+x)*4]/255*c]);B.push([1,1,m[(u*f+x)*4]/255*c]);B.push([0,1,m[(u*f+t)*4]/255*c]);B.push([-1,1,m[(u*f+y)*4]/255*c]);w=[];y=B.length;for(u=0;u<y;u++){var x=B[u],D=B[(u+1)%y],x=[x[0]-z[0],x[1]-z[1],x[2]-z[2]],D=[D[0]-z[0],D[1]-z[1],D[2]-z[2]];w.push(e([x[1]*D[2]-x[2]*D[1],x[2]*D[0]-x[0]*D[2],x[0]*D[1]-x[1]*D[0]]))}B=[0,0,0];for(u=0;u<w.length;u++)B[0]+=w[u][0],B[1]+=w[u][1],B[2]+=w[u][2];B[0]/=w.length;B[1]/=w.length;B[2]/=w.length;z=(v*f+t)*4;o[z]=(B[0]+1)/2*255|0;o[z+1]=(B[1]+0.5)*
|
||||
255|0;o[z+2]=B[2]*255|0;o[z+3]=255}j.putImageData(p,0,0);return k}};THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,h=b.children.length;for(f=0;f<h;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
|
||||
if(THREE.WebGLRenderer)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:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,{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},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",
|
||||
@@ -359,21 +359,21 @@ value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(
|
||||
THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( 1.0 );\nvec4 mColor = vec4( uDiffuseColor, uOpacity );\nvec4 mSpecular = vec4( uSpecularColor, uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor = gl_FragColor * texture2D( tAO, vUv );\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointTotal = vec4( vec3( 0.0 ), 1.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\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 = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( vec3( 0.0 ), 1.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 + viewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
|
||||
THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:"attribute vec4 tangent;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
|
||||
cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"}}};
|
||||
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 o=0;o<b.hierarchy[e].keys[f].morphTargets.length;o++){var t=b.hierarchy[e].keys[f].morphTargets[o];m[t]=-1}b.hierarchy[e].usedMorphTargets=m;for(f=0;f<b.hierarchy[e].keys.length;f++){var p=
|
||||
{};for(t in m){for(o=0;o<b.hierarchy[e].keys[f].morphTargets.length;o++)if(b.hierarchy[e].keys[f].morphTargets[o]===t){p[t]=b.hierarchy[e].keys[f].morphTargetsInfluences[o];break}o===b.hierarchy[e].keys[f].morphTargets.length&&(p[t]=0)}b.hierarchy[e].keys[f].morphTargetsInfluences=p}}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=
|
||||
THREE.AnimationHandler=function(){var b=[],c={},e={update:function(e){for(var c=0;c<b.length;c++)b[c].update(e)},addToUpdate:function(e){b.indexOf(e)===-1&&b.push(e)},removeFromUpdate:function(e){e=b.indexOf(e);e!==-1&&b.splice(e,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 p=0;p<b.hierarchy[e].keys[f].morphTargets.length;p++){var o=b.hierarchy[e].keys[f].morphTargets[p];m[o]=-1}b.hierarchy[e].usedMorphTargets=m;for(f=0;f<b.hierarchy[e].keys.length;f++){var t=
|
||||
{};for(o in m){for(p=0;p<b.hierarchy[e].keys[f].morphTargets.length;p++)if(b.hierarchy[e].keys[f].morphTargets[p]===o){t[o]=b.hierarchy[e].keys[f].morphTargetsInfluences[p];break}p===b.hierarchy[e].keys[f].morphTargets.length&&(t[o]=0)}b.hierarchy[e].keys[f].morphTargetsInfluences=t}}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 e=[];if(b instanceof THREE.SkinnedMesh)for(var c=0;c<b.bones.length;c++)e.push(b.bones[c]);else f(b,e);return e}},f=function(b,e){e.push(b);for(var c=0;c<b.children.length;c++)f(b.children[c],e)};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,h;for(e=0;e<f;e++){h=this.hierarchy[e];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)h.useQuaternion=!0;h.matrixAutoUpdate=!0;if(h.animationCache===void 0)h.animationCache={},h.animationCache.prevKey={pos:0,rot:0,scl:0},h.animationCache.nextKey={pos:0,rot:0,scl:0},h.animationCache.originalMatrix=h instanceof
|
||||
THREE.Bone?h.skinMatrix:h.matrix;var k=h.animationCache.prevKey;h=h.animationCache.nextKey;k.pos=this.data.hierarchy[e].keys[0];k.rot=this.data.hierarchy[e].keys[0];k.scl=this.data.hierarchy[e].keys[0];h.pos=this.getNextKeyWith("pos",e,1);h.rot=this.getNextKeyWith("rot",e,1);h.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"],e,f,h,k,j,m,o,t,p=this.data.JIT.hierarchy,v,w;this.currentTime+=b*this.timeScale;w=this.currentTime;v=this.currentTime%=this.data.length;t=parseInt(Math.min(v*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,y=this.hierarchy.length;u<y;u++)if(b=this.hierarchy[u],o=b.animationCache,this.JITCompile&&p[u][t]!==void 0)b instanceof THREE.Bone?(b.skinMatrix=p[u][t],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=
|
||||
!1):(b.matrix=p[u][t],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 x=0;x<3;x++){e=c[x];j=o.prevKey[e];m=o.nextKey[e];if(m.time<=w){if(v<w)if(this.loop){j=this.data.hierarchy[u].keys[0];for(m=this.getNextKeyWith(e,u,1);m.time<v;)j=m,m=this.getNextKeyWith(e,u,m.index+1)}else{this.stop();return}else{do j=m,m=this.getNextKeyWith(e,u,m.index+1);while(m.time<
|
||||
v)}o.prevKey[e]=j;o.nextKey[e]=m}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(v-j.time)/(m.time-j.time);h=j[e];k=m[e];if(f<0||f>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
|
||||
THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],e,f,h,k,j,m,p,o,t=this.data.JIT.hierarchy,v,w;this.currentTime+=b*this.timeScale;w=this.currentTime;v=this.currentTime%=this.data.length;o=parseInt(Math.min(v*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,y=this.hierarchy.length;u<y;u++)if(b=this.hierarchy[u],p=b.animationCache,this.JITCompile&&t[u][o]!==void 0)b instanceof THREE.Bone?(b.skinMatrix=t[u][o],b.matrixAutoUpdate=!1,b.matrixWorldNeedsUpdate=
|
||||
!1):(b.matrix=t[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 x=0;x<3;x++){e=c[x];j=p.prevKey[e];m=p.nextKey[e];if(m.time<=w){if(v<w)if(this.loop){j=this.data.hierarchy[u].keys[0];for(m=this.getNextKeyWith(e,u,1);m.time<v;)j=m,m=this.getNextKeyWith(e,u,m.index+1)}else{this.stop();return}else{do j=m,m=this.getNextKeyWith(e,u,m.index+1);while(m.time<
|
||||
v)}p.prevKey[e]=j;p.nextKey[e]=m}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(v-j.time)/(m.time-j.time);h=j[e];k=m[e];if(f<0||f>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f;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]=h,this.points[2]=k,this.points[3]=this.getNextKeyWith("pos",u,m.index+1).pos,f=f*0.33+0.33,h=this.interpolateCatmullRom(this.points,f),e.x=h[0],e.y=h[1],e.z=h[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(h,k,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f}}if(this.JITCompile&&p[0][t]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;u<this.hierarchy.length;u++)p[u][t]=this.hierarchy[u]instanceof THREE.Bone?this.hierarchy[u].skinMatrix.clone():this.hierarchy[u].matrix.clone()}}};
|
||||
THREE.Animation.prototype.interpolateCatmullRom=function(b,c){var e=[],f=[],h,k,j,m,o,t;h=(b.length-1)*c;k=Math.floor(h);h-=k;e[0]=k==0?k:k-1;e[1]=k;e[2]=k>b.length-2?k:k+1;e[3]=k>b.length-3?k:k+2;k=b[e[0]];m=b[e[1]];o=b[e[2]];t=b[e[3]];e=h*h;j=h*e;f[0]=this.interpolate(k[0],m[0],o[0],t[0],h,e,j);f[1]=this.interpolate(k[1],m[1],o[1],t[1],h,e,j);f[2]=this.interpolate(k[2],m[2],o[2],t[2],h,e,j);return f};
|
||||
"rot")THREE.Quaternion.slerp(h,k,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f}}if(this.JITCompile&&t[0][o]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;u<this.hierarchy.length;u++)t[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 e=[],f=[],h,k,j,m,p,o;h=(b.length-1)*c;k=Math.floor(h);h-=k;e[0]=k==0?k:k-1;e[1]=k;e[2]=k>b.length-2?k:k+1;e[3]=k>b.length-3?k:k+2;k=b[e[0]];m=b[e[1]];p=b[e[2]];o=b[e[3]];e=h*h;j=h*e;f[0]=this.interpolate(k[0],m[0],p[0],o[0],h,e,j);f[1]=this.interpolate(k[1],m[1],p[1],o[1],h,e,j);f[2]=this.interpolate(k[2],m[2],p[2],o[2],h,e,j);return f};
|
||||
THREE.Animation.prototype.interpolate=function(b,c,e,f,h,k,j){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*j+(-3*(c-e)-2*b-f)*k+b*h+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.FirstPersonCamera=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=
|
||||
@@ -386,15 +386,15 @@ this.moveRight&&this.translateX(c);this.moveUp&&this.translateY(c);this.moveDown
|
||||
1;this.constrainVertical&&(b=3.14/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;h=this.position;b.x=h.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=h.y+100*Math.cos(this.phi);b.z=h.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.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.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,e,f){var h={name:e,fps:0.6,length:f,hierarchy:[]},j,k=c.getControlPointsArray(),m=c.getLength(),o=k.length,H=0;j=o-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<o-1;j++)H=f*m.chunks[j]/m.total,c.keys[j]={time:H,pos:k[j]};h.hierarchy[0]=c;THREE.AnimationHandler.add(h);return new THREE.Animation(b,e,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,c){var e,
|
||||
f,h=new THREE.Geometry;for(e=0;e<b.points.length*c;e++)f=e/(b.points.length*c),f=b.getPoint(f),h.vertices[e]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return h}function f(b,c){var f=e(c,10),h=e(c,10),j=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,j);particleObj=new THREE.ParticleSystem(h,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);h=new THREE.SphereGeometry(1,
|
||||
16,8);j=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(h,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=
|
||||
THREE.PathCamera=function(b){function c(b,e,c,f){var j={name:c,fps:0.6,length:f,hierarchy:[]},h,k=e.getControlPointsArray(),m=e.getLength(),p=k.length,D=0;h=p-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:k[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[h]={time:f,pos:k[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<p-1;h++)D=f*m.chunks[h]/m.total,e.keys[h]={time:D,pos:k[h]};j.hierarchy[0]=e;THREE.AnimationHandler.add(j);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,e){var c,
|
||||
f,j=new THREE.Geometry;for(c=0;c<b.points.length*e;c++)f=c/(b.points.length*e),f=b.getPoint(f),j.vertices[c]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return j}function f(b,c){var f=e(c,10),j=e(c,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,h);particleObj=new THREE.ParticleSystem(j,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);j=new THREE.SphereGeometry(1,
|
||||
16,8);h=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(j,h),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 h=Math.PI*2,k=Math.PI/180;this.update=function(b,c,e){var f,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)*k;this.theta=this.lon*k;f=this.phi%h;this.phi=f>=0?f:f+h;f=this.verticalAngleMap.srcRange;j=this.verticalAngleMap.dstRange;var m=j[1]-j[0];this.phi=
|
||||
TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[0];f=this.horizontalAngleMap.srcRange;j=this.horizontalAngleMap.dstRange;m=j[1]-j[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[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}),j=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.CubeGeometry(10,10,20),o=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(o,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&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,c){return function(){c.apply(b,arguments)}}(this,this.onMouseMove),
|
||||
window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var h=Math.PI*2,k=Math.PI/180;this.update=function(b,e,c){var f,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)*k;this.theta=this.lon*k;f=this.phi%h;this.phi=f>=0?f:f+h;f=this.verticalAngleMap.srcRange;j=this.verticalAngleMap.dstRange;var m=j[1]-j[0];this.phi=
|
||||
TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[0];f=this.horizontalAngleMap.srcRange;j=this.horizontalAngleMap.dstRange;m=j[1]-j[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[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,e,c)};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}),m=new THREE.CubeGeometry(10,10,20),p=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(p,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&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,e){return function(){e.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=
|
||||
@@ -406,27 +406,27 @@ this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVec
|
||||
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,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 h=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Matrix4,o=!1,t=1,p=0,v=0,w=0,u=0,y=0,x=window.innerWidth/2,B=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*y));b=this.delta*this.movementSpeed;this.translateZ(b*(p>0||this.autoForward&&!(p<0)?1:p));this.translateX(b*v);this.translateY(b*w);o&&(this.roll+=this.rollSpeed*this.delta*t);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
|
||||
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 h=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Matrix4,p=!1,o=1,t=0,v=0,w=0,u=0,y=0,x=window.innerWidth/2,B=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*y));b=this.delta*this.movementSpeed;this.translateZ(b*(t>0||this.autoForward&&!(t<0)?1:t));this.translateX(b*v);this.translateY(b*w);p&&(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);k.set(0,1,0);h.cross(k,j).normalize();k.cross(j,h).normalize();this.matrix.n11=h.x;this.matrix.n12=k.x;this.matrix.n13=j.x;this.matrix.n21=h.y;this.matrix.n22=k.y;this.matrix.n23=j.y;this.matrix.n31=h.z;this.matrix.n32=k.z;this.matrix.n33=j.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){h.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);h.multiplyScalar(b);this.forward.subSelf(h);this.forward.normalize()};this.rotateVertically=function(b){k.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);k.multiplyScalar(b);this.forward.addSelf(k);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
|
||||
function(b){u=(b.clientX-x)/window.innerWidth;y=(b.clientY-B)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:p=1;break;case 2:p=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:p=0;break;case 2:p=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:p=1;break;case 37:case 65:v=-1;break;
|
||||
case 40:case 83:p=-1;break;case 39:case 68:v=1;break;case 81:o=!0;t=1;break;case 69:o=!0;t=-1;break;case 82:w=1;break;case 70:w=-1}},!1);this.domElement.addEventListener("keyup",function(b){switch(b.keyCode){case 38:case 87:p=0;break;case 37:case 65:v=0;break;case 40:case 83:p=0;break;case 39:case 68:v=0;break;case 81:o=!1;break;case 69:o=!1;break;case 82:w=0;break;case 70:w=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
|
||||
function(b){u=(b.clientX-x)/window.innerWidth;y=(b.clientY-B)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:t=1;break;case 2:t=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:t=0;break;case 2:t=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:t=1;break;case 37:case 65:v=-1;break;
|
||||
case 40:case 83:t=-1;break;case 39:case 68:v=1;break;case 81:p=!0;o=1;break;case 69:p=!0;o=-1;break;case 82:w=1;break;case 70:w=-1}},!1);this.domElement.addEventListener("keyup",function(b){switch(b.keyCode){case 38:case 87:t=0;break;case 37:case 65:v=0;break;case 40:case 83:t=0;break;case 39:case 68:v=0;break;case 81:p=!1;break;case 69:p=!1;break;case 82:w=0;break;case 70:w=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 e=!1,f=this.STATE.NONE,h=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Vector2,o=new THREE.Vector2,t=new THREE.Vector2,p=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-
|
||||
!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,h=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Vector2,p=new THREE.Vector2,o=new THREE.Vector2,t=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);h=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(e.y);f.addSelf(this.up.clone().crossSelf(h).setLength(e.x));f.addSelf(h.setLength(e.z));return f};
|
||||
this.rotateCamera=function(){var b=Math.acos(k.dot(j)/k.length()/j.length());if(b){var c=(new THREE.Vector3).cross(k,j).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(h);e.multiplyVector3(this.up);e.multiplyVector3(j);this.staticMoving?k=j:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(k))}};this.zoomCamera=function(){var b=1+(o.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(h.multiplyScalar(b),this.staticMoving?m=o:m.y+=(o.y-m.y)*this.dynamicDampingFactor)};
|
||||
this.panCamera=function(){var b=p.clone().subSelf(t);if(b.lengthSq()){b.multiplyScalar(h.length()*this.panSpeed);var c=h.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?t=p:t.addSelf(b.sub(p,t).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
|
||||
this.rotateCamera=function(){var b=Math.acos(k.dot(j)/k.length()/j.length());if(b){var c=(new THREE.Vector3).cross(k,j).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(h);e.multiplyVector3(this.up);e.multiplyVector3(j);this.staticMoving?k=j:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(k))}};this.zoomCamera=function(){var b=1+(p.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(h.multiplyScalar(b),this.staticMoving?m=p:m.y+=(p.y-m.y)*this.dynamicDampingFactor)};
|
||||
this.panCamera=function(){var b=t.clone().subSelf(o);if(b.lengthSq()){b.multiplyScalar(h.length()*this.panSpeed);var c=h.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=t:o.addSelf(b.sub(t,o).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
|
||||
h.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,h.setLength(this.minDistance))};this.update=function(b,c,e){h=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,h);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&&(k=j=this.getMouseProjectionOnBall(b.clientX,b.clientY),m=o=this.getMouseOnScreen(b.clientX,b.clientY),t=p=this.getMouseOnScreen(b.clientX,b.clientY),e=!1);f!==this.STATE.NONE&&(f===this.STATE.ROTATE?j=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?o=this.getMouseOnScreen(b.clientX,b.clientY):f===this.STATE.PAN&&!this.noPan&&(p=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?k=j=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?m=o=this.getMouseOnScreen(b.clientX,b.clientY):this.noPan||(t=p=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=
|
||||
c(this,function(b){e&&(k=j=this.getMouseProjectionOnBall(b.clientX,b.clientY),m=p=this.getMouseOnScreen(b.clientX,b.clientY),o=t=this.getMouseOnScreen(b.clientX,b.clientY),e=!1);f!==this.STATE.NONE&&(f===this.STATE.ROTATE?j=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?p=this.getMouseOnScreen(b.clientX,b.clientY):f===this.STATE.PAN&&!this.noPan&&(t=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?k=j=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?m=p=this.getMouseOnScreen(b.clientX,b.clientY):this.noPan||(o=t=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.QuakeCamera=THREE.FirstPersonCamera;THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(b){return this.getPoint(this.getUtoTmapping(b))};THREE.Curve.prototype.getPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPoint(c/b));return e};
|
||||
THREE.Curve.prototype.getSpacedPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPointAt(c/b));return e};THREE.Curve.prototype.getLength=function(){var b=this.getLengths();return b[b.length-1]};
|
||||
THREE.Curve.prototype.getLengths=function(b){b||(b=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==b+1)return this.cacheArcLengths;var c=[],e,f=this.getPoint(0),h,k=0;c.push(0);for(h=1;h<=b;h++)e=this.getPoint(h/b),k+=e.distanceTo(f),c.push(k),f=e;return this.cacheArcLengths=c};
|
||||
THREE.Curve.prototype.getUtoTmapping=function(b,c){var e=this.getLengths(),f=0,h=e.length,k;k=c?c:b*e[h-1];time=Date.now();for(var j=0,m=h-1,o;j<=m;)if(f=Math.floor(j+(m-j)/2),o=e[f]-k,o<0)j=f+1;else if(o>0)m=f-1;else{m=f;break}f=m;if(e[f]==k)return f/(h-1);j=e[f];return e=(f+(k-j)/(e[f+1]-j))/(h-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)};
|
||||
THREE.Curve.prototype.getUtoTmapping=function(b,c){var e=this.getLengths(),f=0,h=e.length,k;k=c?c:b*e[h-1];time=Date.now();for(var j=0,m=h-1,p;j<=m;)if(f=Math.floor(j+(m-j)/2),p=e[f]-k,p<0)j=f+1;else if(p>0)m=f-1;else{m=f;break}f=m;if(e[f]==k)return f/(h-1);j=e[f];return e=(f+(k-j)/(e[f+1]-j))/(h-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)};
|
||||
THREE.Curve.prototype.getTangent=function(b){var c=b-1.0E-4;b+=1.0E-4;c<0&&(c=0);b>1&&(b=1);var c=this.getPoint(c),b=this.getPoint(b),e=new THREE.Vector2;e.sub(b,c);return e.unit()};THREE.LineCurve=function(b,c){b instanceof THREE.Vector2?(this.v1=b,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(b,c,e,f){this.constructor(new THREE.Vector2(b,c),new THREE.Vector2(e,f))};THREE.LineCurve.prototype=new THREE.Curve;
|
||||
THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(b).addSelf(this.v1);return c};THREE.LineCurve.prototype.getPointAt=function(b){return this.getPoint(b)};THREE.LineCurve.prototype.getTangent=function(){var b=new THREE.Vector2;b.sub(this.v2,this.v1);b.normalize();return b};
|
||||
THREE.QuadraticBezierCurve=function(b,c,e){if(!(c instanceof THREE.Vector2))var f=Array.prototype.slice.call(arguments),b=new THREE.Vector2(f[0],f[1]),c=new THREE.Vector2(f[2],f[3]),e=new THREE.Vector2(f[4],f[5]);this.v0=b;this.v1=c;this.v2=e};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;
|
||||
@@ -441,142 +441,142 @@ THREE.Curve.create=function(b,c){b.prototype=new THREE.Curve;b.prototype.constru
|
||||
THREE.QuadraticBezierCurve3=THREE.Curve.create(function(b,c,e){this.v0=b;this.v1=c;this.v2=e},function(b){var c,e;c=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);e=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);b=THREE.Shape.Utils.b2(b,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,e,b)});THREE.CurvePath=function(){this.curves=[];this.bends=[]};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(b){this.curves.push(b)};
|
||||
THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){};THREE.CurvePath.prototype.getPoint=function(b){for(var c=b*this.getLength(),e=this.getCurveLengths(),b=0;b<e.length;){if(e[b]>=c)return c=e[b]-c,b=this.curves[b],c=1-c/b.getLength(),b.getPointAt(c);b++}return null};THREE.CurvePath.prototype.getLength=function(){var b=this.getCurveLengths();return b[b.length-1]};
|
||||
THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var b=[],c=0,e,f=this.curves.length;for(e=0;e<f;e++)c+=this.curves[e].getLength(),b.push(c);return this.cacheLengths=b};
|
||||
THREE.CurvePath.prototype.getBoundingBox=function(){var b=this.getPoints(),c,e,f,h;c=e=Number.NEGATIVE_INFINITY;f=h=Number.POSITIVE_INFINITY;var k,j,m,o;o=new THREE.Vector2;j=0;for(m=b.length;j<m;j++){k=b[j];if(k.x>c)c=k.x;else if(k.x<f)f=k.x;if(k.y>e)e=k.y;else if(k.y<e)h=k.y;o.addSelf(k.x,k.y)}return{minX:f,minY:h,maxX:c,maxY:e,centroid:o.divideScalar(m)}};THREE.CurvePath.prototype.createPointsGeometry=function(b){return this.createGeometry(this.getPoints(b,!0))};
|
||||
THREE.CurvePath.prototype.getBoundingBox=function(){var b=this.getPoints(),c,e,f,h;c=e=Number.NEGATIVE_INFINITY;f=h=Number.POSITIVE_INFINITY;var k,j,m,p;p=new THREE.Vector2;j=0;for(m=b.length;j<m;j++){k=b[j];if(k.x>c)c=k.x;else if(k.x<f)f=k.x;if(k.y>e)e=k.y;else if(k.y<e)h=k.y;p.addSelf(k.x,k.y)}return{minX:f,minY:h,maxX:c,maxY:e,centroid:p.divideScalar(m)}};THREE.CurvePath.prototype.createPointsGeometry=function(b){return this.createGeometry(this.getPoints(b,!0))};
|
||||
THREE.CurvePath.prototype.createSpacedPointsGeometry=function(b){return this.createGeometry(this.getSpacedPoints(b,!0))};THREE.CurvePath.prototype.createGeometry=function(b){for(var c=new THREE.Geometry,e=0;e<b.length;e++)c.vertices.push(new THREE.Vertex(new THREE.Vector3(b[e].x,b[e].y,0)));return c};THREE.CurvePath.prototype.addWrapPath=function(b){this.bends.push(b)};
|
||||
THREE.CurvePath.prototype.getTransformedPoints=function(b,c){var e=this.getPoints(b),f,h;if(!c)c=this.bends;f=0;for(h=c.length;f<h;f++)e=this.getWrapPoints(e,c[f]);return e};THREE.CurvePath.prototype.getTransformedSpacedPoints=function(b,c){var e=this.getSpacedPoints(b),f,h;if(!c)c=this.bends;f=0;for(h=c.length;f<h;f++)e=this.getWrapPoints(e,c[f]);return e};
|
||||
THREE.CurvePath.prototype.getWrapPoints=function(b,c){var e=this.getBoundingBox(),f,h,k,j,m,o;f=0;for(h=b.length;f<h;f++)k=b[f],j=k.x,m=k.y,o=j/e.maxX,o=c.getUtoTmapping(o,j),j=c.getPoint(o),m=c.getNormalVector(o).multiplyScalar(m),k.x=j.x+m.x,k.y=j.y+m.y;return b};THREE.Path=function(b){THREE.CurvePath.call(this);this.actions=[];b&&this.fromPoints(b)};THREE.Path.prototype=new THREE.CurvePath;THREE.Path.prototype.constructor=THREE.Path;
|
||||
THREE.CurvePath.prototype.getWrapPoints=function(b,c){var e=this.getBoundingBox(),f,h,k,j,m,p;f=0;for(h=b.length;f<h;f++)k=b[f],j=k.x,m=k.y,p=j/e.maxX,p=c.getUtoTmapping(p,j),j=c.getPoint(p),m=c.getNormalVector(p).multiplyScalar(m),k.x=j.x+m.x,k.y=j.y+m.y;return b};THREE.Path=function(b){THREE.CurvePath.call(this);this.actions=[];b&&this.fromPoints(b)};THREE.Path.prototype=new THREE.CurvePath;THREE.Path.prototype.constructor=THREE.Path;
|
||||
THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc"};THREE.Path.prototype.fromPoints=function(b){this.moveTo(b[0].x,b[0].y);var c,e=b.length;for(c=1;c<e;c++)this.lineTo(b[c].x,b[c].y)};THREE.Path.prototype.moveTo=function(){var b=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:b})};
|
||||
THREE.Path.prototype.lineTo=function(b,c){var e=Array.prototype.slice.call(arguments),f=this.actions[this.actions.length-1].args;this.curves.push(new THREE.LineCurve(new THREE.Vector2(f[f.length-2],f[f.length-1]),new THREE.Vector2(b,c)));this.actions.push({action:THREE.PathActions.LINE_TO,args:e})};
|
||||
THREE.Path.prototype.quadraticCurveTo=function(b,c,e,f){var h=Array.prototype.slice.call(arguments),k=this.actions[this.actions.length-1].args;this.curves.push(new THREE.QuadraticBezierCurve(new THREE.Vector2(k[k.length-2],k[k.length-1]),new THREE.Vector2(b,c),new THREE.Vector2(e,f)));this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:h})};
|
||||
THREE.Path.prototype.bezierCurveTo=function(b,c,e,f,h,k){var j=Array.prototype.slice.call(arguments),m=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(m[m.length-2],m[m.length-1]),new THREE.Vector2(b,c),new THREE.Vector2(e,f),new THREE.Vector2(h,k)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:j})};
|
||||
THREE.Path.prototype.splineThru=function(b){var c=Array.prototype.slice.call(arguments),e=this.actions[this.actions.length-1].args,e=[new THREE.Vector2(e[e.length-2],e[e.length-1])],e=e.concat(b);this.curves.push(new THREE.SplineCurve(e));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:c})};THREE.Path.prototype.arc=function(b,c,e,f,h,k){var j=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(b,c,e,f,h,k));this.actions.push({action:THREE.PathActions.ARC,args:j})};
|
||||
THREE.Path.prototype.getSpacedPoints=function(b){b||(b=40);for(var c=[],e=0;e<b;e++)c.push(this.getPoint(e/b));return c};
|
||||
THREE.Path.prototype.getPoints=function(b,c){var b=b||12,e=[],f,h,k,j,m,o,t,p,v,w,u,y,x;f=0;for(h=this.actions.length;f<h;f++)switch(k=this.actions[f],j=k.action,k=k.args,j){case THREE.PathActions.LINE_TO:e.push(new THREE.Vector2(k[0],k[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:m=k[2];o=k[3];v=k[0];w=k[1];e.length>0?(j=e[e.length-1],u=j.x,y=j.y):(j=this.actions[f-1].args,u=j[j.length-2],y=j[j.length-1]);for(j=1;j<=b;j++)x=j/b,k=THREE.Shape.Utils.b2(x,u,v,m),x=THREE.Shape.Utils.b2(x,y,w,
|
||||
o),e.push(new THREE.Vector2(k,x));break;case THREE.PathActions.BEZIER_CURVE_TO:m=k[4];o=k[5];v=k[0];w=k[1];t=k[2];p=k[3];e.length>0?(j=e[e.length-1],u=j.x,y=j.y):(j=this.actions[f-1].args,u=j[j.length-2],y=j[j.length-1]);for(j=1;j<=b;j++)x=j/b,k=THREE.Shape.Utils.b3(x,u,v,t,m),x=THREE.Shape.Utils.b3(x,y,w,p,o),e.push(new THREE.Vector2(k,x));break;case THREE.PathActions.CSPLINE_THRU:j=this.actions[f-1].args;j=[new THREE.Vector2(j[j.length-2],j[j.length-1])];x=b*k[0].length;j=j.concat(k[0]);k=new THREE.SplineCurve(j);
|
||||
for(j=1;j<=x;j++)e.push(k.getPointAt(j/x));break;case THREE.PathActions.ARC:j=this.actions[f-1].args;m=k[0];o=k[1];t=k[2];v=k[3];x=k[4];w=!!k[5];p=j[j.length-2];u=j[j.length-1];j.length==0&&(p=u=0);y=x-v;var B=b*2;for(j=1;j<=B;j++)x=j/B,w||(x=1-x),x=v+x*y,k=p+m+t*Math.cos(x),x=u+o+t*Math.sin(x),e.push(new THREE.Vector2(k,x))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)};
|
||||
THREE.Path.prototype.nltransform=function(b,c,e,f,h,k){var j=this.getPoints(),m,o,t,p,v;m=0;for(o=j.length;m<o;m++)t=j[m],p=t.x,v=t.y,t.x=b*p+c*v+e,t.y=f*v+h*p+k;return j};
|
||||
THREE.Path.prototype.getPoints=function(b,c){var b=b||12,e=[],f,h,k,j,m,p,o,t,v,w,u,y,x;f=0;for(h=this.actions.length;f<h;f++)switch(k=this.actions[f],j=k.action,k=k.args,j){case THREE.PathActions.LINE_TO:e.push(new THREE.Vector2(k[0],k[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:m=k[2];p=k[3];v=k[0];w=k[1];e.length>0?(j=e[e.length-1],u=j.x,y=j.y):(j=this.actions[f-1].args,u=j[j.length-2],y=j[j.length-1]);for(j=1;j<=b;j++)x=j/b,k=THREE.Shape.Utils.b2(x,u,v,m),x=THREE.Shape.Utils.b2(x,y,w,
|
||||
p),e.push(new THREE.Vector2(k,x));break;case THREE.PathActions.BEZIER_CURVE_TO:m=k[4];p=k[5];v=k[0];w=k[1];o=k[2];t=k[3];e.length>0?(j=e[e.length-1],u=j.x,y=j.y):(j=this.actions[f-1].args,u=j[j.length-2],y=j[j.length-1]);for(j=1;j<=b;j++)x=j/b,k=THREE.Shape.Utils.b3(x,u,v,o,m),x=THREE.Shape.Utils.b3(x,y,w,t,p),e.push(new THREE.Vector2(k,x));break;case THREE.PathActions.CSPLINE_THRU:j=this.actions[f-1].args;j=[new THREE.Vector2(j[j.length-2],j[j.length-1])];x=b*k[0].length;j=j.concat(k[0]);k=new THREE.SplineCurve(j);
|
||||
for(j=1;j<=x;j++)e.push(k.getPointAt(j/x));break;case THREE.PathActions.ARC:j=this.actions[f-1].args;m=k[0];p=k[1];o=k[2];v=k[3];x=k[4];w=!!k[5];t=j[j.length-2];u=j[j.length-1];j.length==0&&(t=u=0);y=x-v;var B=b*2;for(j=1;j<=B;j++)x=j/B,w||(x=1-x),x=v+x*y,k=t+m+o*Math.cos(x),x=u+p+o*Math.sin(x),e.push(new THREE.Vector2(k,x))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)};
|
||||
THREE.Path.prototype.nltransform=function(b,c,e,f,h,k){var j=this.getPoints(),m,p,o,t,v;m=0;for(p=j.length;m<p;m++)o=j[m],t=o.x,v=o.y,o.x=b*t+c*v+e,o.y=f*v+h*t+k;return j};
|
||||
THREE.Path.prototype.debug=function(b){var c=this.getBoundingBox();b||(b=document.createElement("canvas"),b.setAttribute("width",c.maxX+100),b.setAttribute("height",c.maxY+100),document.body.appendChild(b));c=b.getContext("2d");c.fillStyle="white";c.fillRect(0,0,b.width,b.height);c.strokeStyle="black";c.beginPath();var e,f,h,b=0;for(e=this.actions.length;b<e;b++)f=this.actions[b],h=f.args,f=f.action,f!=THREE.PathActions.CSPLINE_THRU&&c[f].apply(c,h);c.stroke();c.closePath();c.strokeStyle="red";f=
|
||||
this.getPoints();b=0;for(e=f.length;b<e;b++)h=f[b],c.beginPath(),c.arc(h.x,h.y,1.5,0,Math.PI*2,!1),c.stroke(),c.closePath()};
|
||||
THREE.Path.prototype.toShapes=function(){var b,c,e,f,h=[],k=new THREE.Path;b=0;for(c=this.actions.length;b<c;b++)e=this.actions[b],f=e.args,e=e.action,e==THREE.PathActions.MOVE_TO&&k.actions.length!=0&&(h.push(k),k=new THREE.Path),k[e].apply(k,f);k.actions.length!=0&&h.push(k);if(h.length==0)return[];var j,k=[];if(THREE.Shape.Utils.isClockWise(h[0].getPoints())){b=0;for(c=h.length;b<c;b++)f=h[b],THREE.Shape.Utils.isClockWise(f.getPoints())?(j&&k.push(j),j=new THREE.Shape,j.actions=f.actions,j.curves=
|
||||
f.curves):j.holes.push(f);k.push(j)}else{j=new THREE.Shape;b=0;for(c=h.length;b<c;b++)f=h[b],THREE.Shape.Utils.isClockWise(f.getPoints())?(j.actions=f.actions,j.curves=f.curves,k.push(j),j=new THREE.Shape):j.holes.push(f)}return k};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.extrude=function(b){return new THREE.ExtrudeGeometry(this,b)};
|
||||
THREE.Shape.prototype.getPointsHoles=function(b){var c,e=this.holes.length,f=[];for(c=0;c<e;c++)f[c]=this.holes[c].getTransformedPoints(b,this.bends);return f};THREE.Shape.prototype.getSpacedPointsHoles=function(b){var c,e=this.holes.length,f=[];for(c=0;c<e;c++)f[c]=this.holes[c].getTransformedSpacedPoints(b,this.bends);return f};THREE.Shape.prototype.extractAllPoints=function(b){return{shape:this.getTransformedPoints(b),holes:this.getPointsHoles(b)}};
|
||||
THREE.Shape.prototype.extractAllSpacedPoints=function(b){return{shape:this.getTransformedSpacedPoints(b),holes:this.getSpacedPointsHoles(b)}};
|
||||
THREE.Shape.Utils={removeHoles:function(b,c){var e=b.concat(),f=e.concat(),h,k,j,m,o,t,p,v,w,u,y=[];for(o=0;o<c.length;o++){t=c[o];f=f.concat(t);k=Number.POSITIVE_INFINITY;for(h=0;h<t.length;h++){w=t[h];u=[];for(v=0;v<e.length;v++)p=e[v],p=w.distanceToSquared(p),u.push(p),p<k&&(k=p,j=h,m=v)}h=m-1>=0?m-1:e.length-1;k=j-1>=0?j-1:t.length-1;var x=[t[j],e[m],e[h]];v=THREE.FontUtils.Triangulate.area(x);var B=[t[j],t[k],e[m]];w=THREE.FontUtils.Triangulate.area(B);u=m;p=j;m+=1;j+=-1;m<0&&(m+=e.length);m%=
|
||||
e.length;j<0&&(j+=t.length);j%=t.length;h=m-1>=0?m-1:e.length-1;k=j-1>=0?j-1:t.length-1;x=[t[j],e[m],e[h]];x=THREE.FontUtils.Triangulate.area(x);B=[t[j],t[k],e[m]];B=THREE.FontUtils.Triangulate.area(B);v+w>x+B&&(m=u,j=p,m<0&&(m+=e.length),m%=e.length,j<0&&(j+=t.length),j%=t.length,h=m-1>=0?m-1:e.length-1,k=j-1>=0?j-1:t.length-1);v=e.slice(0,m);w=e.slice(m);u=t.slice(j);p=t.slice(0,j);k=[t[j],t[k],e[m]];y.push([t[j],e[m],e[h]]);y.push(k);e=v.concat(u).concat(p).concat(w)}return{shape:e,isolatedPts:y,
|
||||
allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,h=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),k,j,m,o,t={};k=0;for(j=f.length;k<j;k++)o=f[k].x+":"+f[k].y,t[o]!==void 0&&console.log("Duplicate point",o),t[o]=k;k=0;for(j=e.length;k<j;k++){m=e[k];for(f=0;f<3;f++)o=m[f].x+":"+m[f].y,o=t[o],o!==void 0&&(m[f]=o)}k=0;for(j=h.length;k<j;k++){m=h[k];for(f=0;f<3;f++)o=m[f].x+":"+m[f].y,o=t[o],o!==void 0&&(m[f]=o)}return e.concat(h)},isClockWise:function(b){return THREE.FontUtils.Triangulate.area(b)<
|
||||
THREE.Shape.Utils={removeHoles:function(b,c){var e=b.concat(),f=e.concat(),h,k,j,m,p,o,t,v,w,u,y=[];for(p=0;p<c.length;p++){o=c[p];f=f.concat(o);k=Number.POSITIVE_INFINITY;for(h=0;h<o.length;h++){w=o[h];u=[];for(v=0;v<e.length;v++)t=e[v],t=w.distanceToSquared(t),u.push(t),t<k&&(k=t,j=h,m=v)}h=m-1>=0?m-1:e.length-1;k=j-1>=0?j-1:o.length-1;var x=[o[j],e[m],e[h]];v=THREE.FontUtils.Triangulate.area(x);var B=[o[j],o[k],e[m]];w=THREE.FontUtils.Triangulate.area(B);u=m;t=j;m+=1;j+=-1;m<0&&(m+=e.length);m%=
|
||||
e.length;j<0&&(j+=o.length);j%=o.length;h=m-1>=0?m-1:e.length-1;k=j-1>=0?j-1:o.length-1;x=[o[j],e[m],e[h]];x=THREE.FontUtils.Triangulate.area(x);B=[o[j],o[k],e[m]];B=THREE.FontUtils.Triangulate.area(B);v+w>x+B&&(m=u,j=t,m<0&&(m+=e.length),m%=e.length,j<0&&(j+=o.length),j%=o.length,h=m-1>=0?m-1:e.length-1,k=j-1>=0?j-1:o.length-1);v=e.slice(0,m);w=e.slice(m);u=o.slice(j);t=o.slice(0,j);k=[o[j],o[k],e[m]];y.push([o[j],e[m],e[h]]);y.push(k);e=v.concat(u).concat(t).concat(w)}return{shape:e,isolatedPts:y,
|
||||
allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,h=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),k,j,m,p,o={};k=0;for(j=f.length;k<j;k++)p=f[k].x+":"+f[k].y,o[p]!==void 0&&console.log("Duplicate point",p),o[p]=k;k=0;for(j=e.length;k<j;k++){m=e[k];for(f=0;f<3;f++)p=m[f].x+":"+m[f].y,p=o[p],p!==void 0&&(m[f]=p)}k=0;for(j=h.length;k<j;k++){m=h[k];for(f=0;f<3;f++)p=m[f].x+":"+m[f].y,p=o[p],p!==void 0&&(m[f]=p)}return e.concat(h)},isClockWise:function(b){return THREE.FontUtils.Triangulate.area(b)<
|
||||
0},b2p0:function(b,c){var e=1-b;return e*e*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,h){return this.b3p0(b,c)+this.b3p1(b,e)+this.b3p2(b,f)+this.b3p3(b,h)}};
|
||||
THREE.TextPath=function(b,c){THREE.Path.call(this);this.parameters=c||{};this.set(b)};THREE.TextPath.prototype.set=function(b,c){this.text=b;var c=c||this.parameters,e=c.curveSegments!==void 0?c.curveSegments:4,f=c.font!==void 0?c.font:"helvetiker",h=c.weight!==void 0?c.weight:"normal",k=c.style!==void 0?c.style:"normal";THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=e;THREE.FontUtils.face=f;THREE.FontUtils.weight=h;THREE.FontUtils.style=k};
|
||||
THREE.TextPath.prototype.toShapes=function(){for(var b=THREE.FontUtils.drawText(this.text).paths,c=[],e=0,f=b.length;e<f;e++)c=c.concat(b[e].toShapes());return c};
|
||||
THREE.CubeGeometry=function(b,c,e,f,h,k,j,m,o){function t(b,c,e,j,m,o,t,u){var v,w,y=f||1,x=h||1,L=m/2,N=o/2,P=p.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")v="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")v="y",x=k||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")v="x",y=k||1;var n=y+1,V=x+1;m/=y;var ha=o/x;for(w=0;w<V;w++)for(o=0;o<n;o++){var R=new THREE.Vector3;R[b]=(o*m-L)*e;R[c]=(w*ha-N)*j;R[v]=t;p.vertices.push(new THREE.Vertex(R))}for(w=0;w<x;w++)for(o=0;o<y;o++)p.faces.push(new THREE.Face4(o+n*
|
||||
w+P,o+n*(w+1)+P,o+1+n*(w+1)+P,o+1+n*w+P,null,null,u)),p.faceVertexUvs[0].push([new THREE.UV(o/y,w/x),new THREE.UV(o/y,(w+1)/x),new THREE.UV((o+1)/y,(w+1)/x),new THREE.UV((o+1)/y,w/x)])}THREE.Geometry.call(this);var p=this,v=b/2,w=c/2,u=e/2,m=m?-1:1;if(j!==void 0)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var y=0;y<6;y++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(o!=void 0)for(var x in o)this.sides[x]!=void 0&&(this.sides[x]=
|
||||
o[x]);this.sides.px&&t("z","y",1*m,-1,e,c,-v,this.materials[0]);this.sides.nx&&t("z","y",-1*m,-1,e,c,v,this.materials[1]);this.sides.py&&t("x","z",1*m,1,b,e,w,this.materials[2]);this.sides.ny&&t("x","z",1*m,-1,b,e,-w,this.materials[3]);this.sides.pz&&t("x","y",1*m,-1,b,c,u,this.materials[4]);this.sides.nz&&t("x","y",-1*m,-1,b,c,-u,this.materials[5]);(function(){for(var b=[],c=[],e=0,f=p.vertices.length;e<f;e++){for(var h=p.vertices[e],j=!1,k=0,m=b.length;k<m;k++){var o=b[k];if(h.position.x==o.position.x&&
|
||||
h.position.y==o.position.y&&h.position.z==o.position.z){c[e]=k;j=!0;break}}if(!j)c[e]=b.length,b.push(new THREE.Vertex(h.position.clone()))}e=0;for(f=p.faces.length;e<f;e++)h=p.faces[e],h.a=c[h.a],h.b=c[h.b],h.c=c[h.c],h.d=c[h.d];p.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
|
||||
THREE.CylinderGeometry=function(b,c,e,f,h,k){function j(b,c,e){m.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}THREE.Geometry.call(this);var m=this,o,t=Math.PI*2,p=f/2;for(o=0;o<b;o++)j(Math.sin(t*o/b)*c,Math.cos(t*o/b)*c,-p);for(o=0;o<b;o++)j(Math.sin(t*o/b)*e,Math.cos(t*o/b)*e,p);var v,w,u,y,x=c-e;for(o=0;o<b;o++)v=new THREE.Vector3,v.copy(m.vertices[o].position),v.z=x,v.normalize(),w=new THREE.Vector3,w.copy(m.vertices[o+b].position),w.z=x,w.normalize(),u=new THREE.Vector3,u.copy(m.vertices[b+
|
||||
(o+1)%b].position),u.z=x,u.normalize(),y=new THREE.Vector3,y.copy(m.vertices[(o+1)%b].position),y.z=x,y.normalize(),m.faces.push(new THREE.Face4(o,o+b,b+(o+1)%b,(o+1)%b,[v,w,u,y]));if(e>0){e=new THREE.Vector3(0,0,-1);j(0,0,-p-(k||0));for(o=b;o<b+b/2;o++)m.faces.push(new THREE.Face4(2*b,(2*o-2*b)%b,(2*o-2*b+1)%b,(2*o-2*b+2)%b,[e,e,e,e]))}if(c>0){c=new THREE.Vector3(0,0,1);j(0,0,p+(h||0));for(o=b+b/2;o<2*b;o++)m.faces.push(new THREE.Face4(2*b+1,(2*o-2*b+2)%b+b,(2*o-2*b+1)%b+b,(2*o-2*b)%b+b,[c,c,c,c]))}o=
|
||||
0;for(b=this.faces.length;o<b;o++)h=[],p=this.faces[o],c=this.vertices[p.a],k=this.vertices[p.b],e=this.vertices[p.c],v=this.vertices[p.d],h.push(new THREE.UV(0.5+Math.atan2(c.position.x,c.position.y)/t,0.5+c.position.z/f)),h.push(new THREE.UV(0.5+Math.atan2(k.position.x,k.position.y)/t,0.5+k.position.z/f)),h.push(new THREE.UV(0.5+Math.atan2(e.position.x,e.position.y)/t,0.5+e.position.z/f)),p instanceof THREE.Face4&&h.push(new THREE.UV(0.5+Math.atan2(v.position.x,v.position.y)/t,0.5+v.position.z/
|
||||
THREE.CubeGeometry=function(b,c,e,f,h,k,j,m,p){function o(b,c,e,j,m,o,p,u){var v,w,x=f||1,y=h||1,M=m/2,L=o/2,S=t.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")v="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")v="y",y=k||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")v="x",x=k||1;var n=x+1,V=y+1;m/=x;var fa=o/y;for(w=0;w<V;w++)for(o=0;o<n;o++){var Q=new THREE.Vector3;Q[b]=(o*m-M)*e;Q[c]=(w*fa-L)*j;Q[v]=p;t.vertices.push(new THREE.Vertex(Q))}for(w=0;w<y;w++)for(o=0;o<x;o++)t.faces.push(new THREE.Face4(o+n*
|
||||
w+S,o+n*(w+1)+S,o+1+n*(w+1)+S,o+1+n*w+S,null,null,u)),t.faceVertexUvs[0].push([new THREE.UV(o/x,w/y),new THREE.UV(o/x,(w+1)/y),new THREE.UV((o+1)/x,(w+1)/y),new THREE.UV((o+1)/x,w/y)])}THREE.Geometry.call(this);var t=this,v=b/2,w=c/2,u=e/2,m=m?-1:1;if(j!==void 0)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var y=0;y<6;y++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(p!=void 0)for(var x in p)this.sides[x]!=void 0&&(this.sides[x]=
|
||||
p[x]);this.sides.px&&o("z","y",1*m,-1,e,c,-v,this.materials[0]);this.sides.nx&&o("z","y",-1*m,-1,e,c,v,this.materials[1]);this.sides.py&&o("x","z",1*m,1,b,e,w,this.materials[2]);this.sides.ny&&o("x","z",1*m,-1,b,e,-w,this.materials[3]);this.sides.pz&&o("x","y",1*m,-1,b,c,u,this.materials[4]);this.sides.nz&&o("x","y",-1*m,-1,b,c,-u,this.materials[5]);(function(){for(var b=[],c=[],e=0,f=t.vertices.length;e<f;e++){for(var j=t.vertices[e],h=!1,k=0,m=b.length;k<m;k++){var o=b[k];if(j.position.x==o.position.x&&
|
||||
j.position.y==o.position.y&&j.position.z==o.position.z){c[e]=k;h=!0;break}}if(!h)c[e]=b.length,b.push(new THREE.Vertex(j.position.clone()))}e=0;for(f=t.faces.length;e<f;e++)j=t.faces[e],j.a=c[j.a],j.b=c[j.b],j.c=c[j.c],j.d=c[j.d];t.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
|
||||
THREE.CylinderGeometry=function(b,c,e,f,h,k){function j(b,c,e){m.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}THREE.Geometry.call(this);var m=this,p,o=Math.PI*2,t=f/2;for(p=0;p<b;p++)j(Math.sin(o*p/b)*c,Math.cos(o*p/b)*c,-t);for(p=0;p<b;p++)j(Math.sin(o*p/b)*e,Math.cos(o*p/b)*e,t);var v,w,u,y,x=c-e;for(p=0;p<b;p++)v=new THREE.Vector3,v.copy(m.vertices[p].position),v.z=x,v.normalize(),w=new THREE.Vector3,w.copy(m.vertices[p+b].position),w.z=x,w.normalize(),u=new THREE.Vector3,u.copy(m.vertices[b+
|
||||
(p+1)%b].position),u.z=x,u.normalize(),y=new THREE.Vector3,y.copy(m.vertices[(p+1)%b].position),y.z=x,y.normalize(),m.faces.push(new THREE.Face4(p,p+b,b+(p+1)%b,(p+1)%b,[v,w,u,y]));if(e>0){e=new THREE.Vector3(0,0,-1);j(0,0,-t-(k||0));for(p=b;p<b+b/2;p++)m.faces.push(new THREE.Face4(2*b,(2*p-2*b)%b,(2*p-2*b+1)%b,(2*p-2*b+2)%b,[e,e,e,e]))}if(c>0){c=new THREE.Vector3(0,0,1);j(0,0,t+(h||0));for(p=b+b/2;p<2*b;p++)m.faces.push(new THREE.Face4(2*b+1,(2*p-2*b+2)%b+b,(2*p-2*b+1)%b+b,(2*p-2*b)%b+b,[c,c,c,c]))}p=
|
||||
0;for(b=this.faces.length;p<b;p++)h=[],t=this.faces[p],c=this.vertices[t.a],k=this.vertices[t.b],e=this.vertices[t.c],v=this.vertices[t.d],h.push(new THREE.UV(0.5+Math.atan2(c.position.x,c.position.y)/o,0.5+c.position.z/f)),h.push(new THREE.UV(0.5+Math.atan2(k.position.x,k.position.y)/o,0.5+k.position.z/f)),h.push(new THREE.UV(0.5+Math.atan2(e.position.x,e.position.y)/o,0.5+e.position.z/f)),t instanceof THREE.Face4&&h.push(new THREE.UV(0.5+Math.atan2(v.position.x,v.position.y)/o,0.5+v.position.z/
|
||||
f)),this.faceVertexUvs[0].push(h);this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;THREE.ExtrudeGeometry=function(b,c){if(typeof b!="undefined"){THREE.Geometry.call(this);var b=b instanceof Array?b:[b],e,f=b.length,h;this.shapebb=b[f-1].getBoundingBox();for(e=0;e<f;e++)h=b[e],this.addShape(h,c);this.computeCentroids();this.computeFaceNormals()}};
|
||||
THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
|
||||
THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,c,e){c||console.log("die");return c.clone().multiplyScalar(e).addSelf(b)}function f(b,c,e){var f=THREE.ExtrudeGeometry.__v1,h=THREE.ExtrudeGeometry.__v2,j=THREE.ExtrudeGeometry.__v3,k=THREE.ExtrudeGeometry.__v4,m=THREE.ExtrudeGeometry.__v5,n=THREE.ExtrudeGeometry.__v6;f.set(b.x-c.x,b.y-c.y);h.set(b.x-e.x,b.y-e.y);f=f.normalize();h=h.normalize();j.set(-f.y,f.x);k.set(h.y,-h.x);m.copy(b).addSelf(j);n.copy(b).addSelf(k);if(m.equals(n))return k.clone();
|
||||
m.copy(c).addSelf(j);n.copy(e).addSelf(k);j=f.dot(k);k=n.subSelf(m).dot(k);j==0&&(console.log("Either infinite or no solutions!"),k==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));k/=j;if(k<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(k).addSelf(m).subSelf(b).clone()}function h(b){for(F=b.length;--F>=0;){ea=F;ga=F-1;ga<0&&(ga=b.length-
|
||||
1);for(var c=0,e=u+p*2,c=0;c<e;c++){var f=ha*c,h=ha*(c+1),j=$+ea+f,k=$+ea+h,n=j,f=$+ga+f,h=$+ga+h,t=k;n+=Y;f+=Y;h+=Y;t+=Y;E.faces.push(new THREE.Face4(n,f,h,t,null,null,I));I&&(n=c/e,f=(c+1)/e,h=m+o*2,j=(E.vertices[j].position.z+o)/h,k=(E.vertices[k].position.z+o)/h,E.faceVertexUvs[0].push([new THREE.UV(j,n),new THREE.UV(k,n),new THREE.UV(k,f),new THREE.UV(j,f)]))}}}function k(b,c,e){E.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function j(b,c,e){b+=Y;c+=Y;e+=Y;E.faces.push(new THREE.Face3(b,
|
||||
c,e,null,null,D));if(D){var f=K.maxY,h=K.maxX,j=E.vertices[c].position.x,c=E.vertices[c].position.y,k=E.vertices[e].position.x,e=E.vertices[e].position.y;E.faceVertexUvs[0].push([new THREE.UV(E.vertices[b].position.x/h,E.vertices[b].position.y/f),new THREE.UV(j/h,c/f),new THREE.UV(k/h,e/f)])}}var m=c.amount!==void 0?c.amount:100,o=c.bevelThickness!==void 0?c.bevelThickness:6,t=c.bevelSize!==void 0?c.bevelSize:o-2,p=c.bevelSegments!==void 0?c.bevelSegments:3,v=c.bevelEnabled!==void 0?c.bevelEnabled:
|
||||
!0,w=c.curveSegments!==void 0?c.curveSegments:12,u=c.steps!==void 0?c.steps:1,y=c.bendPath,x=c.extrudePath,B,z=!1,H=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,D=c.material,I=c.extrudeMaterial,K=this.shapebb;if(x)B=x.getPoints(w),u=B.length,z=!0,v=!1;v||(t=o=p=0);var M,C,J,E=this,Y=this.vertices.length;y&&b.addWrapPath(y);w=H?b.extractAllSpacedPoints(w):b.extractAllPoints(w);y=w.shape;w=w.holes;if(x=!THREE.Shape.Utils.isClockWise(y)){y=y.reverse();C=0;for(J=w.length;C<J;C++)M=w[C],THREE.Shape.Utils.isClockWise(M)&&
|
||||
(w[C]=M.reverse());x=!1}x=THREE.Shape.Utils.triangulateShape(y,w);H=y;C=0;for(J=w.length;C<J;C++)M=w[C],y=y.concat(M);var F,L,N,P,n,V,ha=y.length,R=x.length,aa=[];F=0;L=H.length;ea=L-1;for(ga=F+1;F<L;F++,ea++,ga++)ea==L&&(ea=0),ga==L&&(ga=0),aa[F]=f(H[F],H[ea],H[ga]);var Z=[],ia,U=aa.concat();C=0;for(J=w.length;C<J;C++){M=w[C];ia=[];F=0;L=M.length;ea=L-1;for(ga=F+1;F<L;F++,ea++,ga++)ea==L&&(ea=0),ga==L&&(ga=0),ia[F]=f(M[F],M[ea],M[ga]);Z.push(ia);U=U.concat(ia)}for(N=0;N<p;N++){P=N/p;n=o*(1-P);P=
|
||||
t*Math.sin(P*Math.PI/2);F=0;for(L=H.length;F<L;F++)V=e(H[F],aa[F],P),k(V.x,V.y,-n);C=0;for(J=w.length;C<J;C++){M=w[C];ia=Z[C];F=0;for(L=M.length;F<L;F++)V=e(M[F],ia[F],P),k(V.x,V.y,-n)}}P=t;for(F=0;F<ha;F++)V=v?e(y[F],U[F],P):y[F],z?k(V.x,V.y+B[0].y,B[0].x):k(V.x,V.y,0);for(N=1;N<=u;N++)for(F=0;F<ha;F++)V=v?e(y[F],U[F],P):y[F],z?k(V.x,V.y+B[N-1].y,B[N-1].x):k(V.x,V.y,m/u*N);for(N=p-1;N>=0;N--){P=N/p;n=o*(1-P);P=t*Math.sin(P*Math.PI/2);F=0;for(L=H.length;F<L;F++)V=e(H[F],aa[F],P),k(V.x,V.y,m+n);C=
|
||||
0;for(J=w.length;C<J;C++){M=w[C];ia=Z[C];F=0;for(L=M.length;F<L;F++)V=e(M[F],ia[F],P),z?k(V.x,V.y+B[u-1].y,B[u-1].x+n):k(V.x,V.y,m+n)}}if(v){v=ha*0;for(F=0;F<R;F++)t=x[F],j(t[2]+v,t[1]+v,t[0]+v);v=ha*(u+p*2);for(F=0;F<R;F++)t=x[F],j(t[0]+v,t[1]+v,t[2]+v)}else{for(F=0;F<R;F++)t=x[F],j(t[2],t[1],t[0]);for(F=0;F<R;F++)t=x[F],j(t[0]+ha*u,t[1]+ha*u,t[2]+ha*u)}var ea,ga,$=0;h(H);$+=H.length;C=0;for(J=w.length;C<J;C++)M=w[C],h(M),$+=M.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
|
||||
THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,c,e){c||console.log("die");return c.clone().multiplyScalar(e).addSelf(b)}function f(b,c,e){var f=THREE.ExtrudeGeometry.__v1,j=THREE.ExtrudeGeometry.__v2,h=THREE.ExtrudeGeometry.__v3,k=THREE.ExtrudeGeometry.__v4,m=THREE.ExtrudeGeometry.__v5,n=THREE.ExtrudeGeometry.__v6;f.set(b.x-c.x,b.y-c.y);j.set(b.x-e.x,b.y-e.y);f=f.normalize();j=j.normalize();h.set(-f.y,f.x);k.set(j.y,-j.x);m.copy(b).addSelf(h);n.copy(b).addSelf(k);if(m.equals(n))return k.clone();
|
||||
m.copy(c).addSelf(h);n.copy(e).addSelf(k);h=f.dot(k);k=n.subSelf(m).dot(k);h==0&&(console.log("Either infinite or no solutions!"),k==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));k/=h;if(k<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(k).addSelf(m).subSelf(b).clone()}function h(b){for(G=b.length;--G>=0;){aa=G;ja=G-1;ja<0&&(ja=b.length-
|
||||
1);for(var c=0,e=u+t*2,c=0;c<e;c++){var f=fa*c,j=fa*(c+1),h=ha+aa+f,k=ha+aa+j,n=h,f=ha+ja+f,j=ha+ja+j,o=k;n+=Y;f+=Y;j+=Y;o+=Y;F.faces.push(new THREE.Face4(n,f,j,o,null,null,E));E&&(n=c/e,f=(c+1)/e,j=m+p*2,h=(F.vertices[h].position.z+p)/j,k=(F.vertices[k].position.z+p)/j,F.faceVertexUvs[0].push([new THREE.UV(h,n),new THREE.UV(k,n),new THREE.UV(k,f),new THREE.UV(h,f)]))}}}function k(b,c,e){F.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function j(b,c,e){b+=Y;c+=Y;e+=Y;F.faces.push(new THREE.Face3(b,
|
||||
c,e,null,null,C));if(C){var f=J.maxY,j=J.maxX,h=F.vertices[c].position.x,c=F.vertices[c].position.y,k=F.vertices[e].position.x,e=F.vertices[e].position.y;F.faceVertexUvs[0].push([new THREE.UV(F.vertices[b].position.x/j,F.vertices[b].position.y/f),new THREE.UV(h/j,c/f),new THREE.UV(k/j,e/f)])}}var m=c.amount!==void 0?c.amount:100,p=c.bevelThickness!==void 0?c.bevelThickness:6,o=c.bevelSize!==void 0?c.bevelSize:p-2,t=c.bevelSegments!==void 0?c.bevelSegments:3,v=c.bevelEnabled!==void 0?c.bevelEnabled:
|
||||
!0,w=c.curveSegments!==void 0?c.curveSegments:12,u=c.steps!==void 0?c.steps:1,y=c.bendPath,x=c.extrudePath,B,z=!1,D=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,C=c.material,E=c.extrudeMaterial,J=this.shapebb;if(x)B=x.getPoints(w),u=B.length,z=!0,v=!1;v||(o=p=t=0);var O,K,I,F=this,Y=this.vertices.length;y&&b.addWrapPath(y);w=D?b.extractAllSpacedPoints(w):b.extractAllPoints(w);y=w.shape;w=w.holes;if(x=!THREE.Shape.Utils.isClockWise(y)){y=y.reverse();K=0;for(I=w.length;K<I;K++)O=w[K],THREE.Shape.Utils.isClockWise(O)&&
|
||||
(w[K]=O.reverse());x=!1}x=THREE.Shape.Utils.triangulateShape(y,w);D=y;K=0;for(I=w.length;K<I;K++)O=w[K],y=y.concat(O);var G,M,L,S,n,V,fa=y.length,Q=x.length,da=[];G=0;M=D.length;aa=M-1;for(ja=G+1;G<M;G++,aa++,ja++)aa==M&&(aa=0),ja==M&&(ja=0),da[G]=f(D[G],D[aa],D[ja]);var $=[],ka,U=da.concat();K=0;for(I=w.length;K<I;K++){O=w[K];ka=[];G=0;M=O.length;aa=M-1;for(ja=G+1;G<M;G++,aa++,ja++)aa==M&&(aa=0),ja==M&&(ja=0),ka[G]=f(O[G],O[aa],O[ja]);$.push(ka);U=U.concat(ka)}for(L=0;L<t;L++){S=L/t;n=p*(1-S);S=
|
||||
o*Math.sin(S*Math.PI/2);G=0;for(M=D.length;G<M;G++)V=e(D[G],da[G],S),k(V.x,V.y,-n);K=0;for(I=w.length;K<I;K++){O=w[K];ka=$[K];G=0;for(M=O.length;G<M;G++)V=e(O[G],ka[G],S),k(V.x,V.y,-n)}}S=o;for(G=0;G<fa;G++)V=v?e(y[G],U[G],S):y[G],z?k(V.x,V.y+B[0].y,B[0].x):k(V.x,V.y,0);for(L=1;L<=u;L++)for(G=0;G<fa;G++)V=v?e(y[G],U[G],S):y[G],z?k(V.x,V.y+B[L-1].y,B[L-1].x):k(V.x,V.y,m/u*L);for(L=t-1;L>=0;L--){S=L/t;n=p*(1-S);S=o*Math.sin(S*Math.PI/2);G=0;for(M=D.length;G<M;G++)V=e(D[G],da[G],S),k(V.x,V.y,m+n);K=
|
||||
0;for(I=w.length;K<I;K++){O=w[K];ka=$[K];G=0;for(M=O.length;G<M;G++)V=e(O[G],ka[G],S),z?k(V.x,V.y+B[u-1].y,B[u-1].x+n):k(V.x,V.y,m+n)}}if(v){v=fa*0;for(G=0;G<Q;G++)o=x[G],j(o[2]+v,o[1]+v,o[0]+v);v=fa*(u+t*2);for(G=0;G<Q;G++)o=x[G],j(o[0]+v,o[1]+v,o[2]+v)}else{for(G=0;G<Q;G++)o=x[G],j(o[2],o[1],o[0]);for(G=0;G<Q;G++)o=x[G],j(o[0]+fa*u,o[1]+fa*u,o[2]+fa*u)}var aa,ja,ha=0;h(D);ha+=D.length;K=0;for(I=w.length;K<I;K++)O=w[K],h(O),ha+=O.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
|
||||
THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
|
||||
THREE.IcosahedronGeometry=function(b){function c(b,c,e){var f=Math.sqrt(b*b+c*c+e*e);return h.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=h.vertices[b].position,j=h.vertices[e].position;return c((f.x+j.x)/2,(f.y+j.y)/2,(f.z+j.z)/2)}var h=this,k=new THREE.Geometry;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,k);e(0,5,1,k);e(0,1,7,k);e(0,7,10,k);e(0,10,11,k);e(1,5,9,k);e(5,11,4,k);e(11,10,2,k);e(10,7,6,k);e(7,1,8,k);e(3,9,4,k);e(3,4,2,k);e(3,2,6,k);e(3,6,8,k);e(3,8,9,k);e(4,9,5,k);e(2,4,11,k);e(6,2,10,k);e(8,6,7,k);e(9,8,1,k);for(var j=0;j<this.subdivisions;j++){var b=new THREE.Geometry,m;for(m in k.faces){var o=f(k.faces[m].a,k.faces[m].b),t=f(k.faces[m].b,k.faces[m].c),p=f(k.faces[m].c,k.faces[m].a);e(k.faces[m].a,o,p,b);e(k.faces[m].b,t,
|
||||
o,b);e(k.faces[m].c,p,t,b);e(o,t,p,b)}k.faces=b.faces}h.faces=k.faces;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
|
||||
THREE.LatheGeometry=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=[],h=[],k=[],j=(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 o=0;o<=this.angle+0.0010;o+=c){for(m=0;m<e.length;m++)o<this.angle?(e[m]=j.multiplyVector3(e[m].clone()),this.vertices.push(new THREE.Vertex(e[m])),h[m]=this.vertices.length-1):h=k;o==0&&(k=f);
|
||||
for(m=0;m<f.length-1;m++)this.faces.push(new THREE.Face4(h[m],h[m+1],f[m+1],f[m])),this.faceVertexUvs[0].push([new THREE.UV(1-o/this.angle,m/b.length),new THREE.UV(1-o/this.angle,(m+1)/b.length),new THREE.UV(1-(o-c)/this.angle,(m+1)/b.length),new THREE.UV(1-(o-c)/this.angle,m/b.length)]);f=h;h=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
|
||||
THREE.PlaneGeometry=function(b,c,e,f){THREE.Geometry.call(this);var h,k=b/2,j=c/2,e=e||1,f=f||1,m=e+1,o=f+1;b/=e;var t=c/f;for(h=0;h<o;h++)for(c=0;c<m;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-k,-(h*t-j),0)));for(h=0;h<f;h++)for(c=0;c<e;c++)this.faces.push(new THREE.Face4(c+m*h,c+m*(h+1),c+1+m*(h+1),c+1+m*h)),this.faceVertexUvs[0].push([new THREE.UV(c/e,h/f),new THREE.UV(c/e,(h+1)/f),new THREE.UV((c+1)/e,(h+1)/f),new THREE.UV((c+1)/e,h/f)]);this.computeCentroids();this.computeFaceNormals()};
|
||||
-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,k);e(0,5,1,k);e(0,1,7,k);e(0,7,10,k);e(0,10,11,k);e(1,5,9,k);e(5,11,4,k);e(11,10,2,k);e(10,7,6,k);e(7,1,8,k);e(3,9,4,k);e(3,4,2,k);e(3,2,6,k);e(3,6,8,k);e(3,8,9,k);e(4,9,5,k);e(2,4,11,k);e(6,2,10,k);e(8,6,7,k);e(9,8,1,k);for(var j=0;j<this.subdivisions;j++){var b=new THREE.Geometry,m;for(m in k.faces){var p=f(k.faces[m].a,k.faces[m].b),o=f(k.faces[m].b,k.faces[m].c),t=f(k.faces[m].c,k.faces[m].a);e(k.faces[m].a,p,t,b);e(k.faces[m].b,o,
|
||||
p,b);e(k.faces[m].c,t,o,b);e(p,o,t,b)}k.faces=b.faces}h.faces=k.faces;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
|
||||
THREE.LatheGeometry=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=[],h=[],k=[],j=(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 p=0;p<=this.angle+0.0010;p+=c){for(m=0;m<e.length;m++)p<this.angle?(e[m]=j.multiplyVector3(e[m].clone()),this.vertices.push(new THREE.Vertex(e[m])),h[m]=this.vertices.length-1):h=k;p==0&&(k=f);
|
||||
for(m=0;m<f.length-1;m++)this.faces.push(new THREE.Face4(h[m],h[m+1],f[m+1],f[m])),this.faceVertexUvs[0].push([new THREE.UV(1-p/this.angle,m/b.length),new THREE.UV(1-p/this.angle,(m+1)/b.length),new THREE.UV(1-(p-c)/this.angle,(m+1)/b.length),new THREE.UV(1-(p-c)/this.angle,m/b.length)]);f=h;h=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
|
||||
THREE.PlaneGeometry=function(b,c,e,f){THREE.Geometry.call(this);var h,k=b/2,j=c/2,e=e||1,f=f||1,m=e+1,p=f+1;b/=e;var o=c/f;for(h=0;h<p;h++)for(c=0;c<m;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-k,-(h*o-j),0)));for(h=0;h<f;h++)for(c=0;c<e;c++)this.faces.push(new THREE.Face4(c+m*h,c+m*(h+1),c+1+m*(h+1),c+1+m*h)),this.faceVertexUvs[0].push([new THREE.UV(c/e,h/f),new THREE.UV(c/e,(h+1)/f),new THREE.UV((c+1)/e,(h+1)/f),new THREE.UV((c+1)/e,h/f)]);this.computeCentroids();this.computeFaceNormals()};
|
||||
THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
|
||||
THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f,h=Math.PI,k=Math.max(3,c||8),j=Math.max(2,e||6),c=[],e=0;e<j+1;e++){f=e/j;var m=b*Math.cos(f*h),o=b*Math.sin(f*h),t=[],p=0;for(f=0;f<k;f++){var v=2*f/k,w=o*Math.sin(v*h),v=o*Math.cos(v*h);(e==0||e==j)&&f>0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,m,w)))-1);t.push(p)}c.push(t)}for(var u,y,x,h=c.length,e=0;e<h;e++)if(k=c[e].length,e>0)for(f=0;f<k;f++){t=f==k-1;j=c[e][t?0:f+1];m=c[e][t?k-1:f];o=c[e-1][t?
|
||||
k-1:f];t=c[e-1][t?0:f+1];w=e/(h-1);u=(e-1)/(h-1);y=(f+1)/k;var v=f/k,p=new THREE.UV(1-y,w),w=new THREE.UV(1-v,w),v=new THREE.UV(1-v,u),B=new THREE.UV(1-y,u);e<c.length-1&&(u=this.vertices[j].position.clone(),y=this.vertices[m].position.clone(),x=this.vertices[o].position.clone(),u.normalize(),y.normalize(),x.normalize(),this.faces.push(new THREE.Face3(j,m,o,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([p,w,v]));e>1&&(u=
|
||||
this.vertices[j].position.clone(),y=this.vertices[o].position.clone(),x=this.vertices[t].position.clone(),u.normalize(),y.normalize(),x.normalize(),this.faces.push(new THREE.Face3(j,o,t,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([p,v,B]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry;
|
||||
THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f,h=Math.PI,k=Math.max(3,c||8),j=Math.max(2,e||6),c=[],e=0;e<j+1;e++){f=e/j;var m=b*Math.cos(f*h),p=b*Math.sin(f*h),o=[],t=0;for(f=0;f<k;f++){var v=2*f/k,w=p*Math.sin(v*h),v=p*Math.cos(v*h);(e==0||e==j)&&f>0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,m,w)))-1);o.push(t)}c.push(o)}for(var u,y,x,h=c.length,e=0;e<h;e++)if(k=c[e].length,e>0)for(f=0;f<k;f++){o=f==k-1;j=c[e][o?0:f+1];m=c[e][o?k-1:f];p=c[e-1][o?
|
||||
k-1:f];o=c[e-1][o?0:f+1];w=e/(h-1);u=(e-1)/(h-1);y=(f+1)/k;var v=f/k,t=new THREE.UV(1-y,w),w=new THREE.UV(1-v,w),v=new THREE.UV(1-v,u),B=new THREE.UV(1-y,u);e<c.length-1&&(u=this.vertices[j].position.clone(),y=this.vertices[m].position.clone(),x=this.vertices[p].position.clone(),u.normalize(),y.normalize(),x.normalize(),this.faces.push(new THREE.Face3(j,m,p,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([t,w,v]));e>1&&(u=
|
||||
this.vertices[j].position.clone(),y=this.vertices[p].position.clone(),x=this.vertices[o].position.clone(),u.normalize(),y.normalize(),x.normalize(),this.faces.push(new THREE.Face3(j,p,o,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([t,v,B]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry;
|
||||
THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
|
||||
THREE.TextGeometry=function(b,c){var e=(new THREE.TextPath(b,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var f=e[e.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(f/2,120),new THREE.Vector2(f,0))}THREE.ExtrudeGeometry.call(this,e,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;
|
||||
THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
|
||||
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},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},drawText:function(b){for(var c=
|
||||
this.getFace(),e=this.size/c.resolution,f=0,h=String(b).split(""),k=h.length,j=[],b=0;b<k;b++){var m=new THREE.Path,m=this.extractGlyphPoints(h[b],c,e,f,m);f+=m.offset;j.push(m.path)}return{paths:j,offset:f/2}},extractGlyphPoints:function(b,c,e,f,h){var k=[],j,m,o,t,p,v,w,u,y,x,B=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(B){if(B.o){c=B._cachedOutline||(B._cachedOutline=B.o.split(" "));o=c.length;for(b=0;b<o;)switch(m=c[b++],m){case "m":m=c[b++]*e+f;t=c[b++]*e;k.push(new THREE.Vector2(m,
|
||||
t));h.moveTo(m,t);break;case "l":m=c[b++]*e+f;t=c[b++]*e;k.push(new THREE.Vector2(m,t));h.lineTo(m,t);break;case "q":m=c[b++]*e+f;t=c[b++]*e;w=c[b++]*e+f;u=c[b++]*e;h.quadraticCurveTo(w,u,m,t);if(j=k[k.length-1]){p=j.x;v=j.y;j=1;for(divisions=this.divisions;j<=divisions;j++){var z=j/divisions,H=THREE.Shape.Utils.b2(z,p,w,m),z=THREE.Shape.Utils.b2(z,v,u,t);k.push(new THREE.Vector2(H,z))}}break;case "b":if(m=c[b++]*e+f,t=c[b++]*e,w=c[b++]*e+f,u=c[b++]*-e,y=c[b++]*e+f,x=c[b++]*-e,h.bezierCurveTo(m,t,
|
||||
w,u,y,x),j=k[k.length-1]){p=j.x;v=j.y;j=1;for(divisions=this.divisions;j<=divisions;j++)z=j/divisions,H=THREE.Shape.Utils.b3(z,p,w,y,m),z=THREE.Shape.Utils.b3(z,v,u,x,t),k.push(new THREE.Vector2(H,z))}}}return{offset:B.ha*e,points:k,path:h}}}};
|
||||
(function(b){var c=function(b){for(var c=b.length,h=0,k=c-1,j=0;j<c;k=j++)h+=b[k].x*b[j].y-b[j].x*b[k].y;return h*0.5};b.Triangulate=function(b,f){var h=b.length;if(h<3)return null;var k=[],j=[],m=[],o,t,p;if(c(b)>0)for(t=0;t<h;t++)j[t]=t;else for(t=0;t<h;t++)j[t]=h-1-t;var v=2*h;for(t=h-1;h>2;){if(v--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return k}o=t;h<=o&&(o=0);t=o+1;h<=t&&(t=0);p=t+1;h<=p&&(p=0);var w;a:{w=b;var u=o,y=t,x=p,B=h,z=j,H=void 0,D=void 0,I=void 0,
|
||||
K=void 0,M=void 0,C=void 0,J=void 0,E=void 0,Y=void 0,D=w[z[u]].x,I=w[z[u]].y,K=w[z[y]].x,M=w[z[y]].y,C=w[z[x]].x,J=w[z[x]].y;if(1.0E-10>(K-D)*(J-I)-(M-I)*(C-D))w=!1;else{for(H=0;H<B;H++)if(!(H==u||H==y||H==x)){var E=w[z[H]].x,Y=w[z[H]].y,F=void 0,L=void 0,N=void 0,P=void 0,n=void 0,V=void 0,ha=void 0,R=void 0,aa=void 0,Z=void 0,ia=void 0,U=void 0,F=N=n=void 0,F=C-K,L=J-M,N=D-C,P=I-J,n=K-D,V=M-I,ha=E-D,R=Y-I,aa=E-K,Z=Y-M,ia=E-C,U=Y-J,F=F*Z-L*aa,n=n*R-V*ha,N=N*U-P*ia;if(F>=0&&N>=0&&n>=0){w=!1;break a}}w=
|
||||
!0}}if(w){k.push([b[j[o]],b[j[t]],b[j[p]]]);m.push([j[o],j[t],j[p]]);o=t;for(p=t+1;p<h;o++,p++)j[o]=j[p];h--;v=2*h}}if(f)return m;return k};b.Triangulate.area=c;return b})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
|
||||
this.getFace(),e=this.size/c.resolution,f=0,h=String(b).split(""),k=h.length,j=[],b=0;b<k;b++){var m=new THREE.Path,m=this.extractGlyphPoints(h[b],c,e,f,m);f+=m.offset;j.push(m.path)}return{paths:j,offset:f/2}},extractGlyphPoints:function(b,c,e,f,h){var k=[],j,m,p,o,t,v,w,u,y,x,B=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(B){if(B.o){c=B._cachedOutline||(B._cachedOutline=B.o.split(" "));p=c.length;for(b=0;b<p;)switch(m=c[b++],m){case "m":m=c[b++]*e+f;o=c[b++]*e;k.push(new THREE.Vector2(m,
|
||||
o));h.moveTo(m,o);break;case "l":m=c[b++]*e+f;o=c[b++]*e;k.push(new THREE.Vector2(m,o));h.lineTo(m,o);break;case "q":m=c[b++]*e+f;o=c[b++]*e;w=c[b++]*e+f;u=c[b++]*e;h.quadraticCurveTo(w,u,m,o);if(j=k[k.length-1]){t=j.x;v=j.y;j=1;for(divisions=this.divisions;j<=divisions;j++){var z=j/divisions,D=THREE.Shape.Utils.b2(z,t,w,m),z=THREE.Shape.Utils.b2(z,v,u,o);k.push(new THREE.Vector2(D,z))}}break;case "b":if(m=c[b++]*e+f,o=c[b++]*e,w=c[b++]*e+f,u=c[b++]*-e,y=c[b++]*e+f,x=c[b++]*-e,h.bezierCurveTo(m,o,
|
||||
w,u,y,x),j=k[k.length-1]){t=j.x;v=j.y;j=1;for(divisions=this.divisions;j<=divisions;j++)z=j/divisions,D=THREE.Shape.Utils.b3(z,t,w,y,m),z=THREE.Shape.Utils.b3(z,v,u,x,o),k.push(new THREE.Vector2(D,z))}}}return{offset:B.ha*e,points:k,path:h}}}};
|
||||
(function(b){var c=function(b){for(var c=b.length,h=0,k=c-1,j=0;j<c;k=j++)h+=b[k].x*b[j].y-b[j].x*b[k].y;return h*0.5};b.Triangulate=function(b,f){var h=b.length;if(h<3)return null;var k=[],j=[],m=[],p,o,t;if(c(b)>0)for(o=0;o<h;o++)j[o]=o;else for(o=0;o<h;o++)j[o]=h-1-o;var v=2*h;for(o=h-1;h>2;){if(v--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return k}p=o;h<=p&&(p=0);o=p+1;h<=o&&(o=0);t=o+1;h<=t&&(t=0);var w;a:{w=b;var u=p,y=o,x=t,B=h,z=j,D=void 0,C=void 0,E=void 0,
|
||||
J=void 0,O=void 0,K=void 0,I=void 0,F=void 0,Y=void 0,C=w[z[u]].x,E=w[z[u]].y,J=w[z[y]].x,O=w[z[y]].y,K=w[z[x]].x,I=w[z[x]].y;if(1.0E-10>(J-C)*(I-E)-(O-E)*(K-C))w=!1;else{for(D=0;D<B;D++)if(!(D==u||D==y||D==x)){var F=w[z[D]].x,Y=w[z[D]].y,G=void 0,M=void 0,L=void 0,S=void 0,n=void 0,V=void 0,fa=void 0,Q=void 0,da=void 0,$=void 0,ka=void 0,U=void 0,G=L=n=void 0,G=K-J,M=I-O,L=C-K,S=E-I,n=J-C,V=O-E,fa=F-C,Q=Y-E,da=F-J,$=Y-O,ka=F-K,U=Y-I,G=G*$-M*da,n=n*Q-V*fa,L=L*U-S*ka;if(G>=0&&L>=0&&n>=0){w=!1;break a}}w=
|
||||
!0}}if(w){k.push([b[j[p]],b[j[o]],b[j[t]]]);m.push([j[p],j[o],j[t]]);p=o;for(t=o+1;t<h;p++,t++)j[p]=j[t];h--;v=2*h}}if(f)return m;return k};b.Triangulate.area=c;return b})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
|
||||
THREE.TorusGeometry=function(b,c,e,f,h){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=e||8;this.segmentsT=f||6;this.arc=h||Math.PI*2;h=new THREE.Vector3;b=[];c=[];for(e=0;e<=this.segmentsR;e++)for(f=0;f<=this.segmentsT;f++){var k=f/this.segmentsT*this.arc,j=e/this.segmentsR*Math.PI*2;h.x=this.radius*Math.cos(k);h.y=this.radius*Math.sin(k);var m=new THREE.Vector3;m.x=(this.radius+this.tube*Math.cos(j))*Math.cos(k);m.y=(this.radius+this.tube*Math.cos(j))*Math.sin(k);m.z=
|
||||
this.tube*Math.sin(j);this.vertices.push(new THREE.Vertex(m));b.push(new THREE.UV(f/this.segmentsT,1-e/this.segmentsR));c.push(m.clone().subSelf(h).normalize())}for(e=1;e<=this.segmentsR;e++)for(f=1;f<=this.segmentsT;f++){var h=(this.segmentsT+1)*e+f-1,k=(this.segmentsT+1)*(e-1)+f-1,j=(this.segmentsT+1)*(e-1)+f,m=(this.segmentsT+1)*e+f,o=new THREE.Face4(h,k,j,m,[c[h],c[k],c[j],c[m]]);o.normal.addSelf(c[h]);o.normal.addSelf(c[k]);o.normal.addSelf(c[j]);o.normal.addSelf(c[m]);o.normal.normalize();this.faces.push(o);
|
||||
this.tube*Math.sin(j);this.vertices.push(new THREE.Vertex(m));b.push(new THREE.UV(f/this.segmentsT,1-e/this.segmentsR));c.push(m.clone().subSelf(h).normalize())}for(e=1;e<=this.segmentsR;e++)for(f=1;f<=this.segmentsT;f++){var h=(this.segmentsT+1)*e+f-1,k=(this.segmentsT+1)*(e-1)+f-1,j=(this.segmentsT+1)*(e-1)+f,m=(this.segmentsT+1)*e+f,p=new THREE.Face4(h,k,j,m,[c[h],c[k],c[j],c[m]]);p.normal.addSelf(c[h]);p.normal.addSelf(c[k]);p.normal.addSelf(c[j]);p.normal.addSelf(c[m]);p.normal.normalize();this.faces.push(p);
|
||||
this.faceVertexUvs[0].push([b[h].clone(),b[k].clone(),b[j].clone(),b[m].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
|
||||
THREE.TorusKnotGeometry=function(b,c,e,f,h,k,j){function m(b,c,e,f,h,j){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(h*(2+e)*0.5*Math.cos(b),h*(2+e)*Math.sin(b)*0.5,j*h*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=h||2;this.q=k||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;k=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
|
||||
this.segmentsT;++c){var o=b/this.segmentsR*2*this.p*Math.PI,j=c/this.segmentsT*2*Math.PI,h=m(o,j,this.q,this.p,this.radius,this.heightScale),o=m(o+0.01,j,this.q,this.p,this.radius,this.heightScale);e.x=o.x-h.x;e.y=o.y-h.y;e.z=o.z-h.z;f.x=o.x+h.x;f.y=o.y+h.y;f.z=o.z+h.z;k.cross(e,f);f.cross(k,e);k.normalize();f.normalize();o=-this.tube*Math.cos(j);j=this.tube*Math.sin(j);h.x+=o*f.x+j*k.x;h.y+=o*f.y+j*k.y;h.z+=o*f.z+j*k.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(h.x,h.y,
|
||||
h.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=0;c<this.segmentsT;++c){var f=(b+1)%this.segmentsR,k=(c+1)%this.segmentsT,h=this.grid[b][c],e=this.grid[f][c],f=this.grid[f][k],k=this.grid[b][k],j=new THREE.UV(b/this.segmentsR,c/this.segmentsT),o=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),t=new THREE.UV((b+1)/this.segmentsR,(c+1)/this.segmentsT),p=new THREE.UV(b/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(h,e,f,k));this.faceVertexUvs[0].push([j,o,t,p])}this.computeCentroids();
|
||||
THREE.TorusKnotGeometry=function(b,c,e,f,h,k,j){function m(b,c,e,f,j,h){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(j*(2+e)*0.5*Math.cos(b),j*(2+e)*Math.sin(b)*0.5,h*j*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=h||2;this.q=k||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;k=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
|
||||
this.segmentsT;++c){var p=b/this.segmentsR*2*this.p*Math.PI,j=c/this.segmentsT*2*Math.PI,h=m(p,j,this.q,this.p,this.radius,this.heightScale),p=m(p+0.01,j,this.q,this.p,this.radius,this.heightScale);e.x=p.x-h.x;e.y=p.y-h.y;e.z=p.z-h.z;f.x=p.x+h.x;f.y=p.y+h.y;f.z=p.z+h.z;k.cross(e,f);f.cross(k,e);k.normalize();f.normalize();p=-this.tube*Math.cos(j);j=this.tube*Math.sin(j);h.x+=p*f.x+j*k.x;h.y+=p*f.y+j*k.y;h.z+=p*f.z+j*k.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(h.x,h.y,
|
||||
h.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=0;c<this.segmentsT;++c){var f=(b+1)%this.segmentsR,k=(c+1)%this.segmentsT,h=this.grid[b][c],e=this.grid[f][c],f=this.grid[f][k],k=this.grid[b][k],j=new THREE.UV(b/this.segmentsR,c/this.segmentsT),p=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),o=new THREE.UV((b+1)/this.segmentsR,(c+1)/this.segmentsT),t=new THREE.UV(b/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(h,e,f,k));this.faceVertexUvs[0].push([j,p,o,t])}this.computeCentroids();
|
||||
this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;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,e){b.materials=[];for(var f=0;f<c.length;++f)b.materials[f]=[THREE.Loader.prototype.createMaterial(c[f],e)]},hasNormals:function(b){var c,e,f=b.materials.length;for(e=0;e<f;e++)if(c=b.materials[e][0],c instanceof THREE.MeshShaderMaterial)return!0;return!1},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}function h(b,e,h,j,k,m){var o=document.createElement("canvas");b[e]=new THREE.Texture(o);b[e].sourceFile=h;if(j){b[e].repeat.set(j[0],j[1]);if(j[0]!=1)b[e].wrapS=THREE.RepeatWrapping;if(j[1]!=
|
||||
1)b[e].wrapT=THREE.RepeatWrapping}k&&b[e].offset.set(k[0],k[1]);if(m){j={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(j[m[0]]!==void 0)b[e].wrapS=j[m[0]];if(j[m[1]]!==void 0)b[e].wrapT=j[m[1]]}f(b[e],c+"/"+h)}function k(b){return(b[0]*255<<16)+(b[1]*255<<8)+b[2]*255}var j,m,o;m="MeshLambertMaterial";j={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?m="MeshPhongMaterial":b.shading=="Basic"&&(m="MeshBasicMaterial"));
|
||||
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}function h(b,e,j,h,k,m){var o=document.createElement("canvas");b[e]=new THREE.Texture(o);b[e].sourceFile=j;if(h){b[e].repeat.set(h[0],h[1]);if(h[0]!=1)b[e].wrapS=THREE.RepeatWrapping;if(h[1]!=
|
||||
1)b[e].wrapT=THREE.RepeatWrapping}k&&b[e].offset.set(k[0],k[1]);if(m){h={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(h[m[0]]!==void 0)b[e].wrapS=h[m[0]];if(h[m[1]]!==void 0)b[e].wrapT=h[m[1]]}f(b[e],c+"/"+j)}function k(b){return(b[0]*255<<16)+(b[1]*255<<8)+b[2]*255}var j,m,p;m="MeshLambertMaterial";j={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?m="MeshPhongMaterial":b.shading=="Basic"&&(m="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.colorDiffuse)j.color=k(b.colorDiffuse);
|
||||
else if(b.DbgColor)j.color=b.DbgColor;if(b.colorSpecular)j.specular=k(b.colorSpecular);if(b.colorAmbient)j.ambient=k(b.colorAmbient);if(b.transparency)j.opacity=b.transparency;if(b.specularCoef)j.shininess=b.specularCoef;b.mapDiffuse&&c&&h(j,"map",b.mapDiffuse,b.mapDiffuseRepeat,b.mapDiffuseOffset,b.mapDiffuseWrap);b.mapLight&&c&&h(j,"lightMap",b.mapLight,b.mapLightRepeat,b.mapLightOffset,b.mapLightWrap);b.mapNormal&&c&&h(j,"normalMap",b.mapNormal,b.mapNormalRepeat,b.mapNormalOffset,b.mapNormalWrap);
|
||||
b.mapSpecular&&c&&h(j,"specularMap",b.mapSpecular,b.mapSpecularRepeat,b.mapSpecularOffset,b.mapSpecularWrap);if(b.mapNormal){var t=THREE.ShaderUtils.lib.normal,p=THREE.UniformsUtils.clone(t.uniforms),v=j.color;m=j.specular;o=j.ambient;var w=j.shininess;p.tNormal.texture=j.normalMap;if(b.mapNormalFactor)p.uNormalScale.value=b.mapNormalFactor;if(j.map)p.tDiffuse.texture=j.map,p.enableDiffuse.value=!0;if(j.specularMap)p.tSpecular.texture=j.specularMap,p.enableSpecular.value=!0;if(j.lightMap)p.tAO.texture=
|
||||
j.lightMap,p.enableAO.value=!0;p.uDiffuseColor.value.setHex(v);p.uSpecularColor.value.setHex(m);p.uAmbientColor.value.setHex(o);p.uShininess.value=w;if(j.opacity)p.uOpacity.value=j.opacity;j=new THREE.MeshShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:p,lights:!0,fog:!0})}else j=new THREE[m](j);return j},constructor:THREE.Loader};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;
|
||||
b.mapSpecular&&c&&h(j,"specularMap",b.mapSpecular,b.mapSpecularRepeat,b.mapSpecularOffset,b.mapSpecularWrap);if(b.mapNormal){var o=THREE.ShaderUtils.lib.normal,t=THREE.UniformsUtils.clone(o.uniforms),v=j.color;m=j.specular;p=j.ambient;var w=j.shininess;t.tNormal.texture=j.normalMap;if(b.mapNormalFactor)t.uNormalScale.value=b.mapNormalFactor;if(j.map)t.tDiffuse.texture=j.map,t.enableDiffuse.value=!0;if(j.specularMap)t.tSpecular.texture=j.specularMap,t.enableSpecular.value=!0;if(j.lightMap)t.tAO.texture=
|
||||
j.lightMap,t.enableAO.value=!0;t.uDiffuseColor.value.setHex(v);t.uSpecularColor.value.setHex(m);t.uAmbientColor.value.setHex(p);t.uShininess.value=w;if(j.opacity)t.uOpacity.value=j.opacity;j=new THREE.MeshShaderMaterial({fragmentShader:o.fragmentShader,vertexShader:o.vertexShader,uniforms:t,lights:!0,fog:!0})}else j=new THREE[m](j);return j},constructor:THREE.Loader};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,h=b.texture_path?b.texture_path:this.extractUrlbase(e),b=new Worker(e);b.onmessage=function(b){c.createModel(b.data,f,h);c.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
|
||||
THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,h=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,h,o,t,p,v,w,u,y,x,B,z,H,D,I=b.faces;v=b.vertices;var K=b.normals,M=b.colors,C=0;for(e=0;e<b.uvs.length;e++)b.uvs[e].length&&C++;for(e=0;e<C;e++)f.faceUvs[e]=[],f.faceVertexUvs[e]=[];t=0;for(p=v.length;t<p;)w=new THREE.Vertex,w.position.x=v[t++]*c,w.position.y=
|
||||
v[t++]*c,w.position.z=v[t++]*c,f.vertices.push(w);t=0;for(p=I.length;t<p;){c=I[t++];v=c&1;o=c&2;e=c&4;h=c&8;u=c&16;w=c&32;x=c&64;c&=128;v?(B=new THREE.Face4,B.a=I[t++],B.b=I[t++],B.c=I[t++],B.d=I[t++],v=4):(B=new THREE.Face3,B.a=I[t++],B.b=I[t++],B.c=I[t++],v=3);if(o)o=I[t++],B.materials=f.materials[o];o=f.faces.length;if(e)for(e=0;e<C;e++)z=b.uvs[e],y=I[t++],D=z[y*2],y=z[y*2+1],f.faceUvs[e][o]=new THREE.UV(D,y);if(h)for(e=0;e<C;e++){z=b.uvs[e];H=[];for(h=0;h<v;h++)y=I[t++],D=z[y*2],y=z[y*2+1],H[h]=
|
||||
new THREE.UV(D,y);f.faceVertexUvs[e][o]=H}if(u)u=I[t++]*3,h=new THREE.Vector3,h.x=K[u++],h.y=K[u++],h.z=K[u],B.normal=h;if(w)for(e=0;e<v;e++)u=I[t++]*3,h=new THREE.Vector3,h.x=K[u++],h.y=K[u++],h.z=K[u],B.vertexNormals.push(h);if(x)w=I[t++],w=new THREE.Color(M[w]),B.color=w;if(c)for(e=0;e<v;e++)w=I[t++],w=new THREE.Color(M[w]),B.vertexColors.push(w);f.faces.push(B)}}})(h);(function(){var c,e,h,o;if(b.skinWeights){c=0;for(e=b.skinWeights.length;c<e;c+=2)h=b.skinWeights[c],o=b.skinWeights[c+1],f.skinWeights.push(new THREE.Vector4(h,
|
||||
o,0,0))}if(b.skinIndices){c=0;for(e=b.skinIndices.length;c<e;c+=2)h=b.skinIndices[c],o=b.skinIndices[c+1],f.skinIndices.push(new THREE.Vector4(h,o,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var e,h,o,t,p,v,w,u,y;e=0;for(h=b.morphTargets.length;e<h;e++){f.morphTargets[e]={};f.morphTargets[e].name=b.morphTargets[e].name;f.morphTargets[e].vertices=[];u=f.morphTargets[e].vertices;y=b.morphTargets[e].vertices;o=0;for(t=y.length;o<t;o+=3)p=y[o]*c,v=y[o+1]*
|
||||
c,w=y[o+2]*c,u.push(new THREE.Vertex(new THREE.Vector3(p,v,w)))}}if(b.morphColors!==void 0){e=0;for(h=b.morphColors.length;e<h;e++){f.morphColors[e]={};f.morphColors[e].name=b.morphColors[e].name;f.morphColors[e].colors=[];t=f.morphColors[e].colors;p=b.morphColors[e].colors;c=0;for(o=p.length;c<o;c+=3)v=new THREE.Color(16755200),v.setRGB(p[c],p[c+1],p[c+2]),t.push(v)}}})(h);(function(){if(b.edges!==void 0){var c,e,h;for(c=0;c<b.edges.length;c+=2)e=b.edges[c],h=b.edges[c+1],f.edges.push(new THREE.Edge(f.vertices[e],
|
||||
THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,h=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,h,p,o,t,v,w,u,y,x,B,z,D,C,E=b.faces;v=b.vertices;var J=b.normals,O=b.colors,K=0;for(e=0;e<b.uvs.length;e++)b.uvs[e].length&&K++;for(e=0;e<K;e++)f.faceUvs[e]=[],f.faceVertexUvs[e]=[];o=0;for(t=v.length;o<t;)w=new THREE.Vertex,w.position.x=v[o++]*c,w.position.y=
|
||||
v[o++]*c,w.position.z=v[o++]*c,f.vertices.push(w);o=0;for(t=E.length;o<t;){c=E[o++];v=c&1;p=c&2;e=c&4;h=c&8;u=c&16;w=c&32;x=c&64;c&=128;v?(B=new THREE.Face4,B.a=E[o++],B.b=E[o++],B.c=E[o++],B.d=E[o++],v=4):(B=new THREE.Face3,B.a=E[o++],B.b=E[o++],B.c=E[o++],v=3);if(p)p=E[o++],B.materials=f.materials[p];p=f.faces.length;if(e)for(e=0;e<K;e++)z=b.uvs[e],y=E[o++],C=z[y*2],y=z[y*2+1],f.faceUvs[e][p]=new THREE.UV(C,y);if(h)for(e=0;e<K;e++){z=b.uvs[e];D=[];for(h=0;h<v;h++)y=E[o++],C=z[y*2],y=z[y*2+1],D[h]=
|
||||
new THREE.UV(C,y);f.faceVertexUvs[e][p]=D}if(u)u=E[o++]*3,h=new THREE.Vector3,h.x=J[u++],h.y=J[u++],h.z=J[u],B.normal=h;if(w)for(e=0;e<v;e++)u=E[o++]*3,h=new THREE.Vector3,h.x=J[u++],h.y=J[u++],h.z=J[u],B.vertexNormals.push(h);if(x)w=E[o++],w=new THREE.Color(O[w]),B.color=w;if(c)for(e=0;e<v;e++)w=E[o++],w=new THREE.Color(O[w]),B.vertexColors.push(w);f.faces.push(B)}}})(h);(function(){var c,e,h,p;if(b.skinWeights){c=0;for(e=b.skinWeights.length;c<e;c+=2)h=b.skinWeights[c],p=b.skinWeights[c+1],f.skinWeights.push(new THREE.Vector4(h,
|
||||
p,0,0))}if(b.skinIndices){c=0;for(e=b.skinIndices.length;c<e;c+=2)h=b.skinIndices[c],p=b.skinIndices[c+1],f.skinIndices.push(new THREE.Vector4(h,p,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var e,h,p,o,t,v,w,u,y;e=0;for(h=b.morphTargets.length;e<h;e++){f.morphTargets[e]={};f.morphTargets[e].name=b.morphTargets[e].name;f.morphTargets[e].vertices=[];u=f.morphTargets[e].vertices;y=b.morphTargets[e].vertices;p=0;for(o=y.length;p<o;p+=3)t=y[p]*c,v=y[p+1]*
|
||||
c,w=y[p+2]*c,u.push(new THREE.Vertex(new THREE.Vector3(t,v,w)))}}if(b.morphColors!==void 0){e=0;for(h=b.morphColors.length;e<h;e++){f.morphColors[e]={};f.morphColors[e].name=b.morphColors[e].name;f.morphColors[e].colors=[];o=f.morphColors[e].colors;t=b.morphColors[e].colors;c=0;for(p=t.length;c<p;c+=3)v=new THREE.Color(16755200),v.setRGB(t[c],t[c+1],t[c+2]),o.push(v)}}})(h);(function(){if(b.edges!==void 0){var c,e,h;for(c=0;c<b.edges.length;c+=2)e=b.edges[c],h=b.edges[c+1],f.edges.push(new THREE.Edge(f.vertices[e],
|
||||
f.vertices[h],e,h))}})();f.computeCentroids();f.computeFaceNormals();this.hasNormals(f)&&f.computeTangents();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),h=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(c),b=(new Date).getTime(),c=new Worker(c),k=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(b){THREE.BinaryLoader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,e,h,f,k)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};
|
||||
c.postMessage(b)},loadAjaxBuffers:function(b,c,e,f,h,k){var j=new XMLHttpRequest,m=f+"/"+b,o=0;j.onreadystatechange=function(){j.readyState==4?j.status==200||j.status==0?THREE.BinaryLoader.prototype.createBinModel(j.responseText,e,h,c):alert("Couldn't load ["+m+"] ["+j.status+"]"):j.readyState==3?k&&(o==0&&(o=j.getResponseHeader("Content-Length")),k({total:o,loaded:j.responseText.length})):j.readyState==2&&(o=j.getResponseHeader("Content-Length"))};j.open("GET",m,!0);j.overrideMimeType("text/plain; charset=x-user-defined");
|
||||
j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(b,c,e,f){var h=function(c){function e(b,c){var f=p(b,c),h=p(b,c+1),j=p(b,c+2),k=p(b,c+3),m=(k<<1&255|j>>7)-127;f|=(j&127)<<16|h<<8;if(f==0&&m==-127)return 0;return(1-2*(k>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,m)}function h(b,c){var e=p(b,c),f=p(b,c+1),j=p(b,c+2);return(p(b,c+3)<<24)+(j<<16)+(f<<8)+e}function o(b,c){var e=p(b,c);return(p(b,c+1)<<8)+e}function t(b,c){var e=p(b,c);return e>127?e-256:e}function p(b,
|
||||
c){return b.charCodeAt(c)&255}function v(c){var e,f,j;e=h(b,c);f=h(b,c+M);j=h(b,c+C);c=o(b,c+J);THREE.BinaryLoader.prototype.f3(z,e,f,j,c)}function w(c){var e,f,j,k,n,t;e=h(b,c);f=h(b,c+M);j=h(b,c+C);k=o(b,c+J);n=h(b,c+E);t=h(b,c+Y);c=h(b,c+F);THREE.BinaryLoader.prototype.f3n(z,I,e,f,j,k,n,t,c)}function u(c){var e,f,j,k;e=h(b,c);f=h(b,c+L);j=h(b,c+N);k=h(b,c+P);c=o(b,c+n);THREE.BinaryLoader.prototype.f4(z,e,f,j,k,c)}function y(c){var e,f,j,k,t,p,u,v;e=h(b,c);f=h(b,c+L);j=h(b,c+N);k=h(b,c+P);t=o(b,
|
||||
c+n);p=h(b,c+V);u=h(b,c+ha);v=h(b,c+R);c=h(b,c+aa);THREE.BinaryLoader.prototype.f4n(z,I,e,f,j,k,t,p,u,v,c)}function x(c){var e,f;e=h(b,c);f=h(b,c+Z);c=h(b,c+ia);THREE.BinaryLoader.prototype.uv3(z.faceVertexUvs[0],K[e*2],K[e*2+1],K[f*2],K[f*2+1],K[c*2],K[c*2+1])}function B(c){var e,f,j;e=h(b,c);f=h(b,c+U);j=h(b,c+ea);c=h(b,c+ga);THREE.BinaryLoader.prototype.uv4(z.faceVertexUvs[0],K[e*2],K[e*2+1],K[f*2],K[f*2+1],K[j*2],K[j*2+1],K[c*2],K[c*2+1])}var z=this,H=0,D,I=[],K=[],M,C,J,E,Y,F,L,N,P,n,V,ha,R,
|
||||
aa,Z,ia,U,ea,ga,$,S,W,da,fa,la;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,f,c);D={signature:b.substr(H,8),header_bytes:p(b,H+8),vertex_coordinate_bytes:p(b,H+9),normal_coordinate_bytes:p(b,H+10),uv_coordinate_bytes:p(b,H+11),vertex_index_bytes:p(b,H+12),normal_index_bytes:p(b,H+13),uv_index_bytes:p(b,H+14),material_index_bytes:p(b,H+15),nvertices:h(b,H+16),nnormals:h(b,H+16+4),nuvs:h(b,H+16+8),ntri_flat:h(b,H+16+12),ntri_smooth:h(b,H+16+16),ntri_flat_uv:h(b,H+16+20),ntri_smooth_uv:h(b,
|
||||
H+16+24),nquad_flat:h(b,H+16+28),nquad_smooth:h(b,H+16+32),nquad_flat_uv:h(b,H+16+36),nquad_smooth_uv:h(b,H+16+40)};H+=D.header_bytes;M=D.vertex_index_bytes;C=D.vertex_index_bytes*2;J=D.vertex_index_bytes*3;E=D.vertex_index_bytes*3+D.material_index_bytes;Y=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;F=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;L=D.vertex_index_bytes;N=D.vertex_index_bytes*2;P=D.vertex_index_bytes*3;n=D.vertex_index_bytes*4;V=D.vertex_index_bytes*
|
||||
4+D.material_index_bytes;ha=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes;R=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*2;aa=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*3;Z=D.uv_index_bytes;ia=D.uv_index_bytes*2;U=D.uv_index_bytes;ea=D.uv_index_bytes*2;ga=D.uv_index_bytes*3;c=D.vertex_index_bytes*3+D.material_index_bytes;la=D.vertex_index_bytes*4+D.material_index_bytes;$=D.ntri_flat*c;S=D.ntri_smooth*(c+D.normal_index_bytes*3);W=D.ntri_flat_uv*
|
||||
(c+D.uv_index_bytes*3);da=D.ntri_smooth_uv*(c+D.normal_index_bytes*3+D.uv_index_bytes*3);fa=D.nquad_flat*la;c=D.nquad_smooth*(la+D.normal_index_bytes*4);la=D.nquad_flat_uv*(la+D.uv_index_bytes*4);H+=function(c){for(var f,h,k,m=D.vertex_coordinate_bytes*3,n=c+D.nvertices*m;c<n;c+=m)f=e(b,c),h=e(b,c+D.vertex_coordinate_bytes),k=e(b,c+D.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(z,f,h,k);return D.nvertices*m}(H);H+=function(c){for(var e,f,h,j=D.normal_coordinate_bytes*3,k=c+D.nnormals*
|
||||
j;c<k;c+=j)e=t(b,c),f=t(b,c+D.normal_coordinate_bytes),h=t(b,c+D.normal_coordinate_bytes*2),I.push(e/127,f/127,h/127);return D.nnormals*j}(H);H+=function(c){for(var f,h,k=D.uv_coordinate_bytes*2,m=c+D.nuvs*k;c<m;c+=k)f=e(b,c),h=e(b,c+D.uv_coordinate_bytes),K.push(f,h);return D.nuvs*k}(H);$=H+$;S=$+S;W=S+W;da=W+da;fa=da+fa;c=fa+c;la=c+la;(function(b){var c,e=D.vertex_index_bytes*3+D.material_index_bytes,f=e+D.uv_index_bytes*3,h=b+D.ntri_flat_uv*f;for(c=b;c<h;c+=f)v(c),x(c+e);return h-b})(S);(function(b){var c,
|
||||
e=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*3,f=e+D.uv_index_bytes*3,h=b+D.ntri_smooth_uv*f;for(c=b;c<h;c+=f)w(c),x(c+e);return h-b})(W);(function(b){var c,e=D.vertex_index_bytes*4+D.material_index_bytes,f=e+D.uv_index_bytes*4,h=b+D.nquad_flat_uv*f;for(c=b;c<h;c+=f)u(c),B(c+e);return h-b})(c);(function(b){var c,e=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*4,f=e+D.uv_index_bytes*4,h=b+D.nquad_smooth_uv*f;for(c=b;c<h;c+=f)y(c),B(c+e);return h-b})(la);
|
||||
(function(b){var c,e=D.vertex_index_bytes*3+D.material_index_bytes,f=b+D.ntri_flat*e;for(c=b;c<f;c+=e)v(c);return f-b})(H);(function(b){var c,e=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*3,f=b+D.ntri_smooth*e;for(c=b;c<f;c+=e)w(c);return f-b})($);(function(b){var c,e=D.vertex_index_bytes*4+D.material_index_bytes,f=b+D.nquad_flat*e;for(c=b;c<f;c+=e)u(c);return f-b})(da);(function(b){var c,e=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*4,f=b+D.nquad_smooth*
|
||||
e;for(c=b;c<f;c+=e)y(c);return f-b})(fa);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h(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,h){b.faces.push(new THREE.Face3(c,e,f,null,null,b.materials[h]))},f4:function(b,c,e,f,h,k){b.faces.push(new THREE.Face4(c,e,f,h,null,null,b.materials[k]))},f3n:function(b,c,e,
|
||||
f,h,k,j,m,o){var k=b.materials[k],t=c[m*3],p=c[m*3+1],m=c[m*3+2],v=c[o*3],w=c[o*3+1],o=c[o*3+2];b.faces.push(new THREE.Face3(e,f,h,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(t,p,m),new THREE.Vector3(v,w,o)],null,k))},f4n:function(b,c,e,f,h,k,j,m,o,t,p){var j=b.materials[j],v=c[o*3],w=c[o*3+1],o=c[o*3+2],u=c[t*3],y=c[t*3+1],t=c[t*3+2],x=c[p*3],B=c[p*3+1],p=c[p*3+2];b.faces.push(new THREE.Face4(e,f,h,k,[new THREE.Vector3(c[m*3],c[m*3+1],c[m*3+2]),new THREE.Vector3(v,w,o),new THREE.Vector3(u,
|
||||
y,t),new THREE.Vector3(x,B,p)],null,j))},uv3:function(b,c,e,f,h,k,j){var m=[];m.push(new THREE.UV(c,e));m.push(new THREE.UV(f,h));m.push(new THREE.UV(k,j));b.push(m)},uv4:function(b,c,e,f,h,k,j,m,o){var t=[];t.push(new THREE.UV(c,e));t.push(new THREE.UV(f,h));t.push(new THREE.UV(k,j));t.push(new THREE.UV(m,o));b.push(t)},constructor:THREE.BinaryLoader};
|
||||
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 h=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,c){return c=="relativeToHTML"?b:h+"/"+b}function m(){for(u in L.objects)if(!R.objects[u])if(H=L.objects[u],H.geometry!==void 0){if(M=R.geometries[H.geometry]){var b=!1;Y=[];for(Z=0;Z<H.materials.length;Z++)Y[Z]=R.materials[H.materials[Z]],b=Y[Z]instanceof THREE.MeshShaderMaterial;b&&M.computeTangents();D=H.position;r=H.rotation;
|
||||
q=H.quaternion;s=H.scale;q=0;Y.length==0&&(Y[0]=new THREE.MeshFaceMaterial);Y.length>1&&(Y=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(M,Y);object.name=u;object.position.set(D[0],D[1],D[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=H.visible;R.scene.addObject(object);R.objects[u]=object;H.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),R.scene.collisions.colliders.push(b));
|
||||
if(H.castsShadow)b=new THREE.ShadowVolume(M),R.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},R.triggers[object.name]=b)}}else D=H.position,r=H.rotation,q=H.quaternion,s=H.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(D[0],D[1],D[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=H.visible!==void 0?H.visible:!1,R.scene.addObject(object),R.objects[u]=object,R.empties[u]=object,H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},R.triggers[object.name]=b)}function o(b){return function(c){R.geometries[b]=c;m();P-=1;e.onLoadComplete();p()}}function t(b){return function(c){R.geometries[b]=c}}function p(){e.callbackProgress({totalModels:V,totalTextures:ha,loadedModels:V-P,loadedTextures:ha-n},R);e.onLoadProgress();P==0&&n==0&&c(R)}
|
||||
var v,w,u,y,x,B,z,H,D,I,K,M,C,J,E,Y,F,L,N,P,n,V,ha,R;L=b.data;E=new THREE.BinaryLoader;N=new THREE.JSONLoader;n=P=0;R={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(u in L.objects)if(H=L.objects[u],H.meshCollider){b=!0;break}if(b)R.scene.collisions=new THREE.CollisionSystem;if(L.transform){b=L.transform.position;I=L.transform.rotation;var aa=L.transform.scale;b&&R.scene.position.set(b[0],b[1],b[2]);I&&R.scene.rotation.set(I[0],
|
||||
I[1],I[2]);aa&&R.scene.scale.set(aa[0],aa[1],aa[2]);(b||I||aa)&&R.scene.updateMatrix()}b=function(){n-=1;p();e.onLoadComplete()};for(x in L.cameras){I=L.cameras[x];if(I.type=="perspective")C=new THREE.Camera(I.fov,I.aspect,I.near,I.far);else if(I.type=="ortho")C=new THREE.Camera,C.projectionMatrix=THREE.Matrix4.makeOrtho(I.left,I.right,I.top,I.bottom,I.near,I.far);D=I.position;I=I.target;C.position.set(D[0],D[1],D[2]);C.target.position.set(I[0],I[1],I[2]);R.cameras[x]=C}for(y in L.lights)x=L.lights[y],
|
||||
C=x.color!==void 0?x.color:16777215,I=x.intensity!==void 0?x.intensity:1,x.type=="directional"?(D=x.direction,F=new THREE.DirectionalLight(C,I),F.position.set(D[0],D[1],D[2]),F.position.normalize()):x.type=="point"?(D=x.position,d=x.distance,F=new THREE.PointLight(C,I,d),F.position.set(D[0],D[1],D[2])):x.type=="ambient"&&(F=new THREE.AmbientLight(C)),R.scene.addLight(F),R.lights[y]=F;for(B in L.fogs)y=L.fogs[B],y.type=="linear"?J=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(J=new THREE.FogExp2(0,
|
||||
y.density)),I=y.color,J.color.setRGB(I[0],I[1],I[2]),R.fogs[B]=J;if(R.cameras&&L.defaults.camera)R.currentCamera=R.cameras[L.defaults.camera];if(R.fogs&&L.defaults.fog)R.scene.fog=R.fogs[L.defaults.fog];I=L.defaults.bgcolor;R.bgColor=new THREE.Color;R.bgColor.setRGB(I[0],I[1],I[2]);R.bgColorAlpha=L.defaults.bgalpha;for(v in L.geometries)if(B=L.geometries[v],B.type=="bin_mesh"||B.type=="ascii_mesh")P+=1,e.onLoadStart();V=P;for(v in L.geometries)B=L.geometries[v],B.type=="cube"?(M=new THREE.CubeGeometry(B.width,
|
||||
B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),R.geometries[v]=M):B.type=="plane"?(M=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),R.geometries[v]=M):B.type=="sphere"?(M=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),R.geometries[v]=M):B.type=="cylinder"?(M=new THREE.CylinderGeometry(B.numSegs,B.topRad,B.botRad,B.height,B.topOffset,B.botOffset),R.geometries[v]=M):B.type=="torus"?(M=new THREE.TorusGeometry(B.radius,
|
||||
B.tube,B.segmentsR,B.segmentsT),R.geometries[v]=M):B.type=="icosahedron"?(M=new THREE.IcosahedronGeometry(B.subdivisions),R.geometries[v]=M):B.type=="bin_mesh"?E.load({model:f(B.url,L.urlBaseType),callback:o(v)}):B.type=="ascii_mesh"?N.load({model:f(B.url,L.urlBaseType),callback:o(v)}):B.type=="embedded_mesh"&&(B=L.embeds[B.id])&&N.createModel(B,t(v),"");for(z in L.textures)if(v=L.textures[z],v.url instanceof Array){n+=v.url.length;for(E=0;E<v.url.length;E++)e.onLoadStart()}else n+=1,e.onLoadStart();
|
||||
ha=n;for(z in L.textures){v=L.textures[z];if(v.mapping!=void 0&&THREE[v.mapping]!=void 0)v.mapping=new THREE[v.mapping];if(v.url instanceof Array){E=[];for(var Z=0;Z<v.url.length;Z++)E[Z]=f(v.url[Z],L.urlBaseType);E=THREE.ImageUtils.loadTextureCube(E,v.mapping,b)}else{E=THREE.ImageUtils.loadTexture(f(v.url,L.urlBaseType),v.mapping,b);if(THREE[v.minFilter]!=void 0)E.minFilter=THREE[v.minFilter];if(THREE[v.magFilter]!=void 0)E.magFilter=THREE[v.magFilter];if(v.repeat){E.repeat.set(v.repeat[0],v.repeat[1]);
|
||||
if(v.repeat[0]!=1)E.wrapS=THREE.RepeatWrapping;if(v.repeat[1]!=1)E.wrapT=THREE.RepeatWrapping}v.offset&&E.offset.set(v.offset[0],v.offset[1]);if(v.wrap){N={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(N[v.wrap[0]]!==void 0)E.wrapS=N[v.wrap[0]];if(N[v.wrap[1]]!==void 0)E.wrapT=N[v.wrap[1]]}}R.textures[z]=E}for(w in L.materials){z=L.materials[w];for(K in z.parameters)if(K=="envMap"||K=="map"||K=="lightMap")z.parameters[K]=R.textures[z.parameters[K]];else if(K=="shading")z.parameters[K]=
|
||||
z.parameters[K]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(K=="blending")z.parameters[K]=THREE[z.parameters[K]]?THREE[z.parameters[K]]:THREE.NormalBlending;else if(K=="combine")z.parameters[K]=z.parameters[K]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(K=="vertexColors")if(z.parameters[K]=="face")z.parameters[K]=THREE.FaceColors;else if(z.parameters[K])z.parameters[K]=THREE.VertexColors;if(z.parameters.opacity!==void 0&&z.parameters.opacity<1)z.parameters.transparent=
|
||||
!0;if(z.parameters.normalMap){v=THREE.ShaderUtils.lib.normal;b=THREE.UniformsUtils.clone(v.uniforms);E=z.parameters.color;N=z.parameters.specular;B=z.parameters.ambient;J=z.parameters.shininess;b.tNormal.texture=R.textures[z.parameters.normalMap];if(z.parameters.normalMapFactor)b.uNormalScale.value=z.parameters.normalMapFactor;if(z.parameters.map)b.tDiffuse.texture=z.parameters.map,b.enableDiffuse.value=!0;if(z.parameters.lightMap)b.tAO.texture=z.parameters.lightMap,b.enableAO.value=!0;if(z.parameters.specularMap)b.tSpecular.texture=
|
||||
R.textures[z.parameters.specularMap],b.enableSpecular.value=!0;b.uDiffuseColor.value.setHex(E);b.uSpecularColor.value.setHex(N);b.uAmbientColor.value.setHex(B);b.uShininess.value=J;if(z.parameters.opacity)b.uOpacity.value=z.parameters.opacity;z=new THREE.MeshShaderMaterial({fragmentShader:v.fragmentShader,vertexShader:v.vertexShader,uniforms:b,lights:!0,fog:!0})}else z=new THREE[z.type](z.parameters);R.materials[w]=z}m();e.callbackSync(R)}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};
|
||||
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),h=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(c),b=(new Date).getTime(),c=new Worker(c),k=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(b){THREE.BinaryLoader.prototype.loadAjaxBuffers(b.data.buffers,b.data.materials,e,h,f,k)};c.onerror=function(b){alert("worker.onerror: "+b.message+"\n"+b.data);b.preventDefault()};
|
||||
c.postMessage(b)};
|
||||
THREE.BinaryLoader.prototype.loadAjaxBuffers=function(b,c,e,f,h,k){var j=new XMLHttpRequest,m=f+"/"+b,p=0;j.onreadystatechange=function(){j.readyState==4?j.status==200||j.status==0?THREE.BinaryLoader.prototype.createBinModel(j.responseText,e,h,c):alert("Couldn't load ["+m+"] ["+j.status+"]"):j.readyState==3?k&&(p==0&&(p=j.getResponseHeader("Content-Length")),k({total:p,loaded:j.responseText.length})):j.readyState==2&&(p=j.getResponseHeader("Content-Length"))};j.open("GET",m,!0);j.overrideMimeType("text/plain; charset=x-user-defined");
|
||||
j.setRequestHeader("Content-Type","text/plain");j.send(null)};
|
||||
THREE.BinaryLoader.prototype.createBinModel=function(b,c,e,f){var h=function(c){function e(b,c){var f=t(b,c),h=t(b,c+1),j=t(b,c+2),k=t(b,c+3),m=(k<<1&255|j>>7)-127;f|=(j&127)<<16|h<<8;if(f==0&&m==-127)return 0;return(1-2*(k>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,m)}function h(b,c){var e=t(b,c),f=t(b,c+1),j=t(b,c+2);return(t(b,c+3)<<24)+(j<<16)+(f<<8)+e}function p(b,c){var e=t(b,c);return(t(b,c+1)<<8)+e}function o(b,c){var e=t(b,c);return e>127?e-256:e}function t(b,c){return b.charCodeAt(c)&255}function v(c){var e,
|
||||
f,j;e=h(b,c);f=h(b,c+O);j=h(b,c+K);c=p(b,c+I);z.faces.push(new THREE.Face3(e,f,j,null,null,z.materials[c]))}function w(c){var e,f,j,k,n,o;e=h(b,c);f=h(b,c+O);j=h(b,c+K);k=p(b,c+I);n=h(b,c+F);o=h(b,c+Y);c=h(b,c+G);k=z.materials[k];var t=E[o*3],u=E[o*3+1];o=E[o*3+2];var v=E[c*3],w=E[c*3+1],c=E[c*3+2];z.faces.push(new THREE.Face3(e,f,j,[new THREE.Vector3(E[n*3],E[n*3+1],E[n*3+2]),new THREE.Vector3(t,u,o),new THREE.Vector3(v,w,c)],null,k))}function u(c){var e,f,j,k;e=h(b,c);f=h(b,c+M);j=h(b,c+L);k=h(b,
|
||||
c+S);c=p(b,c+n);z.faces.push(new THREE.Face4(e,f,j,k,null,null,z.materials[c]))}function y(c){var e,f,j,k,o,t,u,v;e=h(b,c);f=h(b,c+M);j=h(b,c+L);k=h(b,c+S);o=p(b,c+n);t=h(b,c+V);u=h(b,c+fa);v=h(b,c+Q);c=h(b,c+da);o=z.materials[o];var w=E[u*3],x=E[u*3+1];u=E[u*3+2];var y=E[v*3],B=E[v*3+1];v=E[v*3+2];var C=E[c*3],D=E[c*3+1],c=E[c*3+2];z.faces.push(new THREE.Face4(e,f,j,k,[new THREE.Vector3(E[t*3],E[t*3+1],E[t*3+2]),new THREE.Vector3(w,x,u),new THREE.Vector3(y,B,v),new THREE.Vector3(C,D,c)],null,o))}
|
||||
function x(c){var e,f,j,k;e=h(b,c);f=h(b,c+$);j=h(b,c+ka);c=J[e*2];k=J[e*2+1];e=J[f*2];var n=z.faceVertexUvs[0];f=J[f*2+1];var o=J[j*2];j=J[j*2+1];var p=[];p.push(new THREE.UV(c,k));p.push(new THREE.UV(e,f));p.push(new THREE.UV(o,j));n.push(p)}function B(c){var e,f,j,k,n,o;e=h(b,c);f=h(b,c+U);j=h(b,c+aa);k=h(b,c+ja);c=J[e*2];n=J[e*2+1];e=J[f*2];o=J[f*2+1];f=J[j*2];var p=z.faceVertexUvs[0];j=J[j*2+1];var t=J[k*2];k=J[k*2+1];var u=[];u.push(new THREE.UV(c,n));u.push(new THREE.UV(e,o));u.push(new THREE.UV(f,
|
||||
j));u.push(new THREE.UV(t,k));p.push(u)}var z=this,D=0,C,E=[],J=[],O,K,I,F,Y,G,M,L,S,n,V,fa,Q,da,$,ka,U,aa,ja,ha,X,ca,ga,ia,ma;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,f,c);C={signature:b.substr(D,8),header_bytes:t(b,D+8),vertex_coordinate_bytes:t(b,D+9),normal_coordinate_bytes:t(b,D+10),uv_coordinate_bytes:t(b,D+11),vertex_index_bytes:t(b,D+12),normal_index_bytes:t(b,D+13),uv_index_bytes:t(b,D+14),material_index_bytes:t(b,D+15),nvertices:h(b,D+16),nnormals:h(b,D+16+4),nuvs:h(b,
|
||||
D+16+8),ntri_flat:h(b,D+16+12),ntri_smooth:h(b,D+16+16),ntri_flat_uv:h(b,D+16+20),ntri_smooth_uv:h(b,D+16+24),nquad_flat:h(b,D+16+28),nquad_smooth:h(b,D+16+32),nquad_flat_uv:h(b,D+16+36),nquad_smooth_uv:h(b,D+16+40)};D+=C.header_bytes;O=C.vertex_index_bytes;K=C.vertex_index_bytes*2;I=C.vertex_index_bytes*3;F=C.vertex_index_bytes*3+C.material_index_bytes;Y=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;G=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;M=C.vertex_index_bytes;
|
||||
L=C.vertex_index_bytes*2;S=C.vertex_index_bytes*3;n=C.vertex_index_bytes*4;V=C.vertex_index_bytes*4+C.material_index_bytes;fa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;Q=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;da=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;$=C.uv_index_bytes;ka=C.uv_index_bytes*2;U=C.uv_index_bytes;aa=C.uv_index_bytes*2;ja=C.uv_index_bytes*3;c=C.vertex_index_bytes*3+C.material_index_bytes;ma=C.vertex_index_bytes*
|
||||
4+C.material_index_bytes;ha=C.ntri_flat*c;X=C.ntri_smooth*(c+C.normal_index_bytes*3);ca=C.ntri_flat_uv*(c+C.uv_index_bytes*3);ga=C.ntri_smooth_uv*(c+C.normal_index_bytes*3+C.uv_index_bytes*3);ia=C.nquad_flat*ma;c=C.nquad_smooth*(ma+C.normal_index_bytes*4);ma=C.nquad_flat_uv*(ma+C.uv_index_bytes*4);D+=function(c){for(var f,h,k,m=C.vertex_coordinate_bytes*3,n=c+C.nvertices*m;c<n;c+=m)f=e(b,c),h=e(b,c+C.vertex_coordinate_bytes),k=e(b,c+C.vertex_coordinate_bytes*2),z.vertices.push(new THREE.Vertex(new THREE.Vector3(f,
|
||||
h,k)));return C.nvertices*m}(D);D+=function(c){for(var e,f,h,j=C.normal_coordinate_bytes*3,k=c+C.nnormals*j;c<k;c+=j)e=o(b,c),f=o(b,c+C.normal_coordinate_bytes),h=o(b,c+C.normal_coordinate_bytes*2),E.push(e/127,f/127,h/127);return C.nnormals*j}(D);D+=function(c){for(var f,h,k=C.uv_coordinate_bytes*2,m=c+C.nuvs*k;c<m;c+=k)f=e(b,c),h=e(b,c+C.uv_coordinate_bytes),J.push(f,h);return C.nuvs*k}(D);ha=D+ha;X=ha+X;ca=X+ca;ga=ca+ga;ia=ga+ia;c=ia+c;ma=c+ma;(function(b){var c,e=C.vertex_index_bytes*3+C.material_index_bytes,
|
||||
f=e+C.uv_index_bytes*3,h=b+C.ntri_flat_uv*f;for(c=b;c<h;c+=f)v(c),x(c+e);return h-b})(X);(function(b){var c,e=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*3,f=e+C.uv_index_bytes*3,h=b+C.ntri_smooth_uv*f;for(c=b;c<h;c+=f)w(c),x(c+e);return h-b})(ca);(function(b){var c,e=C.vertex_index_bytes*4+C.material_index_bytes,f=e+C.uv_index_bytes*4,h=b+C.nquad_flat_uv*f;for(c=b;c<h;c+=f)u(c),B(c+e);return h-b})(c);(function(b){var c,e=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*
|
||||
4,f=e+C.uv_index_bytes*4,h=b+C.nquad_smooth_uv*f;for(c=b;c<h;c+=f)y(c),B(c+e);return h-b})(ma);(function(b){var c,e=C.vertex_index_bytes*3+C.material_index_bytes,f=b+C.ntri_flat*e;for(c=b;c<f;c+=e)v(c);return f-b})(D);(function(b){var c,e=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*3,f=b+C.ntri_smooth*e;for(c=b;c<f;c+=e)w(c);return f-b})(ha);(function(b){var c,e=C.vertex_index_bytes*4+C.material_index_bytes,f=b+C.nquad_flat*e;for(c=b;c<f;c+=e)u(c);return f-b})(ga);(function(b){var c,
|
||||
e=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*4,f=b+C.nquad_smooth*e;for(c=b;c<f;c+=e)y(c);return f-b})(ia);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h(e))};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 h=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,c){return c=="relativeToHTML"?b:h+"/"+b}function m(){for(u in M.objects)if(!Q.objects[u])if(D=M.objects[u],D.geometry!==void 0){if(O=Q.geometries[D.geometry]){var b=!1;Y=[];for($=0;$<D.materials.length;$++)Y[$]=Q.materials[D.materials[$]],b=Y[$]instanceof THREE.MeshShaderMaterial;b&&O.computeTangents();C=D.position;r=D.rotation;
|
||||
q=D.quaternion;s=D.scale;q=0;Y.length==0&&(Y[0]=new THREE.MeshFaceMaterial);Y.length>1&&(Y=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(O,Y);object.name=u;object.position.set(C[0],C[1],C[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;Q.scene.addObject(object);Q.objects[u]=object;D.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),Q.scene.collisions.colliders.push(b));
|
||||
if(D.castsShadow)b=new THREE.ShadowVolume(O),Q.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},Q.triggers[object.name]=b)}}else C=D.position,r=D.rotation,q=D.quaternion,s=D.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(C[0],C[1],C[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,Q.scene.addObject(object),Q.objects[u]=object,Q.empties[u]=object,D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},Q.triggers[object.name]=b)}function p(b){return function(c){Q.geometries[b]=c;m();S-=1;e.onLoadComplete();t()}}function o(b){return function(c){Q.geometries[b]=c}}function t(){e.callbackProgress({totalModels:V,totalTextures:fa,loadedModels:V-S,loadedTextures:fa-n},Q);e.onLoadProgress();S==0&&n==0&&c(Q)}
|
||||
var v,w,u,y,x,B,z,D,C,E,J,O,K,I,F,Y,G,M,L,S,n,V,fa,Q;M=b.data;F=new THREE.BinaryLoader;L=new THREE.JSONLoader;n=S=0;Q={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(u in M.objects)if(D=M.objects[u],D.meshCollider){b=!0;break}if(b)Q.scene.collisions=new THREE.CollisionSystem;if(M.transform){b=M.transform.position;E=M.transform.rotation;var da=M.transform.scale;b&&Q.scene.position.set(b[0],b[1],b[2]);E&&Q.scene.rotation.set(E[0],
|
||||
E[1],E[2]);da&&Q.scene.scale.set(da[0],da[1],da[2]);(b||E||da)&&Q.scene.updateMatrix()}b=function(){n-=1;t();e.onLoadComplete()};for(x in M.cameras){E=M.cameras[x];if(E.type=="perspective")K=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho")K=new THREE.Camera,K.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far);C=E.position;E=E.target;K.position.set(C[0],C[1],C[2]);K.target.position.set(E[0],E[1],E[2]);Q.cameras[x]=K}for(y in M.lights)x=M.lights[y],
|
||||
K=x.color!==void 0?x.color:16777215,E=x.intensity!==void 0?x.intensity:1,x.type=="directional"?(C=x.direction,G=new THREE.DirectionalLight(K,E),G.position.set(C[0],C[1],C[2]),G.position.normalize()):x.type=="point"?(C=x.position,d=x.distance,G=new THREE.PointLight(K,E,d),G.position.set(C[0],C[1],C[2])):x.type=="ambient"&&(G=new THREE.AmbientLight(K)),Q.scene.addLight(G),Q.lights[y]=G;for(B in M.fogs)y=M.fogs[B],y.type=="linear"?I=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(I=new THREE.FogExp2(0,
|
||||
y.density)),E=y.color,I.color.setRGB(E[0],E[1],E[2]),Q.fogs[B]=I;if(Q.cameras&&M.defaults.camera)Q.currentCamera=Q.cameras[M.defaults.camera];if(Q.fogs&&M.defaults.fog)Q.scene.fog=Q.fogs[M.defaults.fog];E=M.defaults.bgcolor;Q.bgColor=new THREE.Color;Q.bgColor.setRGB(E[0],E[1],E[2]);Q.bgColorAlpha=M.defaults.bgalpha;for(v in M.geometries)if(B=M.geometries[v],B.type=="bin_mesh"||B.type=="ascii_mesh")S+=1,e.onLoadStart();V=S;for(v in M.geometries)B=M.geometries[v],B.type=="cube"?(O=new THREE.CubeGeometry(B.width,
|
||||
B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),Q.geometries[v]=O):B.type=="plane"?(O=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),Q.geometries[v]=O):B.type=="sphere"?(O=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),Q.geometries[v]=O):B.type=="cylinder"?(O=new THREE.CylinderGeometry(B.numSegs,B.topRad,B.botRad,B.height,B.topOffset,B.botOffset),Q.geometries[v]=O):B.type=="torus"?(O=new THREE.TorusGeometry(B.radius,
|
||||
B.tube,B.segmentsR,B.segmentsT),Q.geometries[v]=O):B.type=="icosahedron"?(O=new THREE.IcosahedronGeometry(B.subdivisions),Q.geometries[v]=O):B.type=="bin_mesh"?F.load({model:f(B.url,M.urlBaseType),callback:p(v)}):B.type=="ascii_mesh"?L.load({model:f(B.url,M.urlBaseType),callback:p(v)}):B.type=="embedded_mesh"&&(B=M.embeds[B.id])&&L.createModel(B,o(v),"");for(z in M.textures)if(v=M.textures[z],v.url instanceof Array){n+=v.url.length;for(F=0;F<v.url.length;F++)e.onLoadStart()}else n+=1,e.onLoadStart();
|
||||
fa=n;for(z in M.textures){v=M.textures[z];if(v.mapping!=void 0&&THREE[v.mapping]!=void 0)v.mapping=new THREE[v.mapping];if(v.url instanceof Array){F=[];for(var $=0;$<v.url.length;$++)F[$]=f(v.url[$],M.urlBaseType);F=THREE.ImageUtils.loadTextureCube(F,v.mapping,b)}else{F=THREE.ImageUtils.loadTexture(f(v.url,M.urlBaseType),v.mapping,b);if(THREE[v.minFilter]!=void 0)F.minFilter=THREE[v.minFilter];if(THREE[v.magFilter]!=void 0)F.magFilter=THREE[v.magFilter];if(v.repeat){F.repeat.set(v.repeat[0],v.repeat[1]);
|
||||
if(v.repeat[0]!=1)F.wrapS=THREE.RepeatWrapping;if(v.repeat[1]!=1)F.wrapT=THREE.RepeatWrapping}v.offset&&F.offset.set(v.offset[0],v.offset[1]);if(v.wrap){L={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(L[v.wrap[0]]!==void 0)F.wrapS=L[v.wrap[0]];if(L[v.wrap[1]]!==void 0)F.wrapT=L[v.wrap[1]]}}Q.textures[z]=F}for(w in M.materials){z=M.materials[w];for(J in z.parameters)if(J=="envMap"||J=="map"||J=="lightMap")z.parameters[J]=Q.textures[z.parameters[J]];else if(J=="shading")z.parameters[J]=
|
||||
z.parameters[J]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(J=="blending")z.parameters[J]=THREE[z.parameters[J]]?THREE[z.parameters[J]]:THREE.NormalBlending;else if(J=="combine")z.parameters[J]=z.parameters[J]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(J=="vertexColors")if(z.parameters[J]=="face")z.parameters[J]=THREE.FaceColors;else if(z.parameters[J])z.parameters[J]=THREE.VertexColors;if(z.parameters.opacity!==void 0&&z.parameters.opacity<1)z.parameters.transparent=
|
||||
!0;if(z.parameters.normalMap){v=THREE.ShaderUtils.lib.normal;b=THREE.UniformsUtils.clone(v.uniforms);F=z.parameters.color;L=z.parameters.specular;B=z.parameters.ambient;I=z.parameters.shininess;b.tNormal.texture=Q.textures[z.parameters.normalMap];if(z.parameters.normalMapFactor)b.uNormalScale.value=z.parameters.normalMapFactor;if(z.parameters.map)b.tDiffuse.texture=z.parameters.map,b.enableDiffuse.value=!0;if(z.parameters.lightMap)b.tAO.texture=z.parameters.lightMap,b.enableAO.value=!0;if(z.parameters.specularMap)b.tSpecular.texture=
|
||||
Q.textures[z.parameters.specularMap],b.enableSpecular.value=!0;b.uDiffuseColor.value.setHex(F);b.uSpecularColor.value.setHex(L);b.uAmbientColor.value.setHex(B);b.uShininess.value=I;if(z.parameters.opacity)b.uOpacity.value=z.parameters.opacity;z=new THREE.MeshShaderMaterial({fragmentShader:v.fragmentShader,vertexShader:v.vertexShader,uniforms:b,lights:!0,fog:!0})}else z=new THREE[z.type](z.parameters);Q.materials[w]=z}m();e.callbackSync(Q)}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};
|
||||
THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
|
||||
THREE.UTF8Loader.prototype={load:function(b){var c=new XMLHttpRequest,e=b.model,f=b.callback,h=b.scale!==void 0?b.scale:1,k=b.offsetX!==void 0?b.offsetX:0,j=b.offsetY!==void 0?b.offsetY:0,m=b.offsetZ!==void 0?b.offsetZ:0;c.onreadystatechange=function(){c.readyState==4?c.status==200||c.status==0?THREE.UTF8Loader.prototype.createModel(c.responseText,f,h,k,j,m):alert("Couldn't load ["+e+"] ["+c.status+"]"):c.readyState!=3&&c.readyState==2&&c.getResponseHeader("Content-Length")};c.open("GET",e,!0);c.send(null)},
|
||||
decompressMesh:function(b){var c=b.charCodeAt(0);c>=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,h=0;h<8;h++){for(var k=0,j=0;j<c;++j){var m=b.charCodeAt(j+f);k+=m>>1^-(m&1);e[8*j+h]=k}f+=c}c=b.length-f;k=new Uint16Array(c);for(h=j=0;h<c;h++)m=b.charCodeAt(h+f),k[h]=j-m,m==0&&j++;return[e,k]},createModel:function(b,c,e,f,h,k){var j=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var j=THREE.UTF8Loader.prototype.decompressMesh(b),t=[],p=[];(function(b,j,o){for(var t,p,B,
|
||||
z=b.length;o<z;o+=j)t=b[o],p=b[o+1],B=b[o+2],t=t/16383*e,p=p/16383*e,B=B/16383*e,t+=f,p+=h,B+=k,THREE.UTF8Loader.prototype.v(c,t,p,B)})(j[0],8,0);(function(b,c,e){for(var f,h,j=b.length;e<j;e+=c)f=b[e],h=b[e+1],f/=1023,h/=1023,p.push(f,h)})(j[0],8,3);(function(b,c,e){for(var f,h,j,k=b.length;e<k;e+=c)f=b[e],h=b[e+1],j=b[e+2],f=(f-512)/511,h=(h-512)/511,j=(j-512)/511,t.push(f,h,j)})(j[0],8,5);(function(b){var e,f,h,j,k,o,H,D=b.length;for(e=0;e<D;e+=3)f=b[e],h=b[e+1],j=b[e+2],THREE.UTF8Loader.prototype.f3n(c,
|
||||
t,f,h,j,0,f,h,j),k=p[f*2],f=p[f*2+1],o=p[h*2],h=p[h*2+1],H=p[j*2],j=p[j*2+1],THREE.UTF8Loader.prototype.uv3(c.faceVertexUvs[0],k,f,o,h,H,j)})(j[1]);this.computeCentroids();this.computeFaceNormals()};j.prototype=new THREE.Geometry;j.prototype.constructor=j;c(new j)},v:function(b,c,e,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(c,e,f)))},f3n:function(b,c,e,f,h,k,j,m,o){var k=b.materials[k],t=c[m*3],p=c[m*3+1],m=c[m*3+2],v=c[o*3],w=c[o*3+1],o=c[o*3+2],j=new THREE.Vector3(c[j*3],c[j*3+1],c[j*
|
||||
3+2]),m=new THREE.Vector3(t,p,m),o=new THREE.Vector3(v,w,o);b.faces.push(new THREE.Face3(e,f,h,[j,m,o],null,k))},uv3:function(b,c,e,f,h,k,j){var m=[];m.push(new THREE.UV(c,e));m.push(new THREE.UV(f,h));m.push(new THREE.UV(k,j));b.push(m)},constructor:THREE.UTF8Loader};
|
||||
THREE.UTF8Loader.prototype.load=function(b){var c=new XMLHttpRequest,e=b.model,f=b.callback,h=b.scale!==void 0?b.scale:1,k=b.offsetX!==void 0?b.offsetX:0,j=b.offsetY!==void 0?b.offsetY:0,m=b.offsetZ!==void 0?b.offsetZ:0;c.onreadystatechange=function(){c.readyState==4?c.status==200||c.status==0?THREE.UTF8Loader.prototype.createModel(c.responseText,f,h,k,j,m):alert("Couldn't load ["+e+"] ["+c.status+"]"):c.readyState!=3&&c.readyState==2&&c.getResponseHeader("Content-Length")};c.open("GET",e,!0);c.send(null)};
|
||||
THREE.UTF8Loader.prototype.decompressMesh=function(b){var c=b.charCodeAt(0);c>=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,h=0;h<8;h++){for(var k=0,j=0;j<c;++j){var m=b.charCodeAt(j+f);k+=m>>1^-(m&1);e[8*j+h]=k}f+=c}c=b.length-f;k=new Uint16Array(c);for(h=j=0;h<c;h++)m=b.charCodeAt(h+f),k[h]=j-m,m==0&&j++;return[e,k]};
|
||||
THREE.UTF8Loader.prototype.createModel=function(b,c,e,f,h,k){var j=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var j=THREE.UTF8Loader.prototype.decompressMesh(b),o=[],t=[];(function(b,j,o){for(var p,t,B,z=b.length;o<z;o+=j)p=b[o],t=b[o+1],B=b[o+2],p=p/16383*e,t=t/16383*e,B=B/16383*e,p+=f,t+=h,B+=k,c.vertices.push(new THREE.Vertex(new THREE.Vector3(p,t,B)))})(j[0],8,0);(function(b,c,e){for(var f,h,j=b.length;e<j;e+=c)f=b[e],h=b[e+1],f/=1023,h/=1023,t.push(f,h)})(j[0],8,3);(function(b,
|
||||
c,e){for(var f,h,j,k=b.length;e<k;e+=c)f=b[e],h=b[e+1],j=b[e+2],f=(f-512)/511,h=(h-512)/511,j=(j-512)/511,o.push(f,h,j)})(j[0],8,5);(function(b){var e,f,h,j,k,p,D,C,E,J=b.length;for(e=0;e<J;e+=3){f=b[e];h=b[e+1];j=b[e+2];k=c;C=f;E=h;p=j;D=f;var O=h,K=j,I=k.materials[0],F=o[O*3],Y=o[O*3+1],O=o[O*3+2],G=o[K*3],M=o[K*3+1],K=o[K*3+2];D=new THREE.Vector3(o[D*3],o[D*3+1],o[D*3+2]);O=new THREE.Vector3(F,Y,O);K=new THREE.Vector3(G,M,K);k.faces.push(new THREE.Face3(C,E,p,[D,O,K],null,I));k=t[f*2];f=t[f*2+
|
||||
1];p=t[h*2];D=t[h*2+1];C=t[j*2];E=t[j*2+1];j=c.faceVertexUvs[0];h=p;p=D;D=[];D.push(new THREE.UV(k,f));D.push(new THREE.UV(h,p));D.push(new THREE.UV(C,E));j.push(D)}})(j[1]);this.computeCentroids();this.computeFaceNormals()};j.prototype=new THREE.Geometry;j.prototype.constructor=j;c(new j)};
|
||||
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,h){return b+(c-b)*h};this.VIntX=function(b,c,h,k,j,m,o,t,p,v){j=(j-p)/(v-p);p=this.normal_cache;c[k]=m+j*this.delta;c[k+1]=o;c[k+2]=t;h[k]=this.lerp(p[b],p[b+3],j);h[k+1]=this.lerp(p[b+1],p[b+4],j);h[k+2]=this.lerp(p[b+2],p[b+5],j)};this.VIntY=function(b,c,h,k,j,m,o,t,p,v){j=(j-p)/(v-p);p=this.normal_cache;c[k]=m;c[k+1]=o+j*this.delta;c[k+
|
||||
2]=t;c=b+this.yd*3;h[k]=this.lerp(p[b],p[c],j);h[k+1]=this.lerp(p[b+1],p[c+1],j);h[k+2]=this.lerp(p[b+2],p[c+2],j)};this.VIntZ=function(b,c,h,k,j,m,o,t,p,v){j=(j-p)/(v-p);p=this.normal_cache;c[k]=m;c[k+1]=o;c[k+2]=t+j*this.delta;c=b+this.zd*3;h[k]=this.lerp(p[b],p[c],j);h[k+1]=this.lerp(p[b+1],p[c+1],j);h[k+2]=this.lerp(p[b+2],p[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,h,k,j,m){var o=k+1,t=k+this.yd,p=k+this.zd,v=o+this.yd,w=o+this.zd,u=k+this.yd+this.zd,y=o+this.yd+this.zd,x=0,B=this.field[k],z=this.field[o],H=this.field[t],D=this.field[v],I=this.field[p],K=this.field[w],M=this.field[u],C=this.field[y];B<j&&(x|=1);z<j&&(x|=2);H<j&&(x|=8);D<j&&(x|=4);I<j&&(x|=16);K<j&&(x|=32);M<j&&(x|=128);C<j&&(x|=64);var J=THREE.edgeTable[x];if(J==0)return 0;var E=this.delta,
|
||||
Y=b+E,F=c+E,E=h+E;J&1&&(this.compNorm(k),this.compNorm(o),this.VIntX(k*3,this.vlist,this.nlist,0,j,b,c,h,B,z));J&2&&(this.compNorm(o),this.compNorm(v),this.VIntY(o*3,this.vlist,this.nlist,3,j,Y,c,h,z,D));J&4&&(this.compNorm(t),this.compNorm(v),this.VIntX(t*3,this.vlist,this.nlist,6,j,b,F,h,H,D));J&8&&(this.compNorm(k),this.compNorm(t),this.VIntY(k*3,this.vlist,this.nlist,9,j,b,c,h,B,H));J&16&&(this.compNorm(p),this.compNorm(w),this.VIntX(p*3,this.vlist,this.nlist,12,j,b,c,E,I,K));J&32&&(this.compNorm(w),
|
||||
this.compNorm(y),this.VIntY(w*3,this.vlist,this.nlist,15,j,Y,c,E,K,C));J&64&&(this.compNorm(u),this.compNorm(y),this.VIntX(u*3,this.vlist,this.nlist,18,j,b,F,E,M,C));J&128&&(this.compNorm(p),this.compNorm(u),this.VIntY(p*3,this.vlist,this.nlist,21,j,b,c,E,I,M));J&256&&(this.compNorm(k),this.compNorm(p),this.VIntZ(k*3,this.vlist,this.nlist,24,j,b,c,h,B,I));J&512&&(this.compNorm(o),this.compNorm(w),this.VIntZ(o*3,this.vlist,this.nlist,27,j,Y,c,h,z,K));J&1024&&(this.compNorm(v),this.compNorm(y),this.VIntZ(v*
|
||||
3,this.vlist,this.nlist,30,j,Y,F,h,D,C));J&2048&&(this.compNorm(t),this.compNorm(u),this.VIntZ(t*3,this.vlist,this.nlist,33,j,b,F,h,H,M));x<<=4;for(j=k=0;THREE.triTable[x+j]!=-1;)b=x+j,c=b+1,h=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[h],m),j+=3,k++;return k};this.posnormtriv=function(b,c,h,k,j,m){var o=this.count*3;this.positionArray[o]=b[h];this.positionArray[o+1]=b[h+1];this.positionArray[o+2]=b[h+2];this.positionArray[o+3]=b[k];this.positionArray[o+
|
||||
4]=b[k+1];this.positionArray[o+5]=b[k+2];this.positionArray[o+6]=b[j];this.positionArray[o+7]=b[j+1];this.positionArray[o+8]=b[j+2];this.normalArray[o]=c[h];this.normalArray[o+1]=c[h+1];this.normalArray[o+2]=c[h+2];this.normalArray[o+3]=c[k];this.normalArray[o+4]=c[k+1];this.normalArray[o+5]=c[k+2];this.normalArray[o+6]=c[j];this.normalArray[o+7]=c[j+1];this.normalArray[o+8]=c[j+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,h,k,j){var m=this.size*Math.sqrt(k/j),o=h*this.size,t=c*this.size,p=b*this.size,v=Math.floor(o-m);v<1&&(v=1);o=Math.floor(o+m);o>this.size-1&&(o=this.size-1);var w=Math.floor(t-m);w<1&&(w=1);t=Math.floor(t+m);t>this.size-1&&(t=this.size-1);var u=Math.floor(p-m);u<1&&(u=1);m=Math.floor(p+m);m>this.size-1&&(m=this.size-
|
||||
1);for(var y,x,B,z,H,D;v<o;v++){p=this.size2*v;x=v/this.size-h;H=x*x;for(x=w;x<t;x++){B=p+this.size*x;y=x/this.size-c;D=y*y;for(y=u;y<m;y++)z=y/this.size-b,z=k/(1.0E-6+z*z+D+H)-j,z>0&&(this.field[B+y]+=z)}}};this.addPlaneX=function(b,c){var h,k,j,m,o,t=this.size,p=this.yd,v=this.zd,w=this.field,u=t*Math.sqrt(b/c);u>t&&(u=t);for(h=0;h<u;h++)if(k=h/t,k*=k,m=b/(1.0E-4+k)-c,m>0)for(k=0;k<t;k++){o=h+k*p;for(j=0;j<t;j++)w[v*j+o]+=m}};this.addPlaneY=function(b,c){var h,k,j,m,o,t,p=this.size,v=this.yd,w=
|
||||
this.zd,u=this.field,y=p*Math.sqrt(b/c);y>p&&(y=p);for(k=0;k<y;k++)if(h=k/p,h*=h,m=b/(1.0E-4+h)-c,m>0){o=k*v;for(h=0;h<p;h++){t=o+h;for(j=0;j<p;j++)u[w*j+t]+=m}}};this.addPlaneZ=function(b,c){var h,k,j,m,o,t;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(h=j/size,h*=h,m=b/(1.0E-4+h)-c,m>0){o=zd*j;for(k=0;k<size;k++){t=o+k*yd;for(h=0;h<size;h++)field[t+h]+=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,h,k,j,m,o,t,p,v,w=this.size-2;for(j=1;j<w;j++){v=this.size2*j;t=(j-this.halfsize)/this.halfsize;for(k=1;k<w;k++){p=v+this.size*k;o=(k-this.halfsize)/this.halfsize;for(h=1;h<w;h++)m=(h-this.halfsize)/this.halfsize,c=p+h,this.polygonize(m,o,t,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,h=[];this.render(function(k){var j,m,o,t,p,v,w,u;for(j=0;j<k.count;j++)w=j*3,p=w+1,u=w+2,m=k.positionArray[w],
|
||||
o=k.positionArray[p],t=k.positionArray[u],v=new THREE.Vector3(m,o,t),m=k.normalArray[w],o=k.normalArray[p],t=k.normalArray[u],w=new THREE.Vector3(m,o,t),w.normalize(),p=new THREE.Vertex(v),c.vertices.push(p),h.push(w);nfaces=k.count/3;for(j=0;j<nfaces;j++)w=(b+j)*3,p=w+1,u=w+2,v=h[w],m=h[p],o=h[u],w=new THREE.Face3(w,p,u,[v,m,o]),c.faces.push(w);b+=nfaces;k.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,h){return b+(c-b)*h};this.VIntX=function(b,c,h,k,j,m,p,o,t,v){j=(j-t)/(v-t);t=this.normal_cache;c[k]=m+j*this.delta;c[k+1]=p;c[k+2]=o;h[k]=this.lerp(t[b],t[b+3],j);h[k+1]=this.lerp(t[b+1],t[b+4],j);h[k+2]=this.lerp(t[b+2],t[b+5],j)};this.VIntY=function(b,c,h,k,j,m,p,o,t,v){j=(j-t)/(v-t);t=this.normal_cache;c[k]=m;c[k+1]=p+j*this.delta;c[k+
|
||||
2]=o;c=b+this.yd*3;h[k]=this.lerp(t[b],t[c],j);h[k+1]=this.lerp(t[b+1],t[c+1],j);h[k+2]=this.lerp(t[b+2],t[c+2],j)};this.VIntZ=function(b,c,h,k,j,m,p,o,t,v){j=(j-t)/(v-t);t=this.normal_cache;c[k]=m;c[k+1]=p;c[k+2]=o+j*this.delta;c=b+this.zd*3;h[k]=this.lerp(t[b],t[c],j);h[k+1]=this.lerp(t[b+1],t[c+1],j);h[k+2]=this.lerp(t[b+2],t[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,h,k,j,m){var p=k+1,o=k+this.yd,t=k+this.zd,v=p+this.yd,w=p+this.zd,u=k+this.yd+this.zd,y=p+this.yd+this.zd,x=0,B=this.field[k],z=this.field[p],D=this.field[o],C=this.field[v],E=this.field[t],J=this.field[w],O=this.field[u],K=this.field[y];B<j&&(x|=1);z<j&&(x|=2);D<j&&(x|=8);C<j&&(x|=4);E<j&&(x|=16);J<j&&(x|=32);O<j&&(x|=128);K<j&&(x|=64);var I=THREE.edgeTable[x];if(I==0)return 0;var F=this.delta,
|
||||
Y=b+F,G=c+F,F=h+F;I&1&&(this.compNorm(k),this.compNorm(p),this.VIntX(k*3,this.vlist,this.nlist,0,j,b,c,h,B,z));I&2&&(this.compNorm(p),this.compNorm(v),this.VIntY(p*3,this.vlist,this.nlist,3,j,Y,c,h,z,C));I&4&&(this.compNorm(o),this.compNorm(v),this.VIntX(o*3,this.vlist,this.nlist,6,j,b,G,h,D,C));I&8&&(this.compNorm(k),this.compNorm(o),this.VIntY(k*3,this.vlist,this.nlist,9,j,b,c,h,B,D));I&16&&(this.compNorm(t),this.compNorm(w),this.VIntX(t*3,this.vlist,this.nlist,12,j,b,c,F,E,J));I&32&&(this.compNorm(w),
|
||||
this.compNorm(y),this.VIntY(w*3,this.vlist,this.nlist,15,j,Y,c,F,J,K));I&64&&(this.compNorm(u),this.compNorm(y),this.VIntX(u*3,this.vlist,this.nlist,18,j,b,G,F,O,K));I&128&&(this.compNorm(t),this.compNorm(u),this.VIntY(t*3,this.vlist,this.nlist,21,j,b,c,F,E,O));I&256&&(this.compNorm(k),this.compNorm(t),this.VIntZ(k*3,this.vlist,this.nlist,24,j,b,c,h,B,E));I&512&&(this.compNorm(p),this.compNorm(w),this.VIntZ(p*3,this.vlist,this.nlist,27,j,Y,c,h,z,J));I&1024&&(this.compNorm(v),this.compNorm(y),this.VIntZ(v*
|
||||
3,this.vlist,this.nlist,30,j,Y,G,h,C,K));I&2048&&(this.compNorm(o),this.compNorm(u),this.VIntZ(o*3,this.vlist,this.nlist,33,j,b,G,h,D,O));x<<=4;for(j=k=0;THREE.triTable[x+j]!=-1;)b=x+j,c=b+1,h=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[h],m),j+=3,k++;return k};this.posnormtriv=function(b,c,h,k,j,m){var p=this.count*3;this.positionArray[p]=b[h];this.positionArray[p+1]=b[h+1];this.positionArray[p+2]=b[h+2];this.positionArray[p+3]=b[k];this.positionArray[p+
|
||||
4]=b[k+1];this.positionArray[p+5]=b[k+2];this.positionArray[p+6]=b[j];this.positionArray[p+7]=b[j+1];this.positionArray[p+8]=b[j+2];this.normalArray[p]=c[h];this.normalArray[p+1]=c[h+1];this.normalArray[p+2]=c[h+2];this.normalArray[p+3]=c[k];this.normalArray[p+4]=c[k+1];this.normalArray[p+5]=c[k+2];this.normalArray[p+6]=c[j];this.normalArray[p+7]=c[j+1];this.normalArray[p+8]=c[j+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,h,k,j){var m=this.size*Math.sqrt(k/j),p=h*this.size,o=c*this.size,t=b*this.size,v=Math.floor(p-m);v<1&&(v=1);p=Math.floor(p+m);p>this.size-1&&(p=this.size-1);var w=Math.floor(o-m);w<1&&(w=1);o=Math.floor(o+m);o>this.size-1&&(o=this.size-1);var u=Math.floor(t-m);u<1&&(u=1);m=Math.floor(t+m);m>this.size-1&&(m=this.size-
|
||||
1);for(var y,x,B,z,D,C;v<p;v++){t=this.size2*v;x=v/this.size-h;D=x*x;for(x=w;x<o;x++){B=t+this.size*x;y=x/this.size-c;C=y*y;for(y=u;y<m;y++)z=y/this.size-b,z=k/(1.0E-6+z*z+C+D)-j,z>0&&(this.field[B+y]+=z)}}};this.addPlaneX=function(b,c){var h,k,j,m,p,o=this.size,t=this.yd,v=this.zd,w=this.field,u=o*Math.sqrt(b/c);u>o&&(u=o);for(h=0;h<u;h++)if(k=h/o,k*=k,m=b/(1.0E-4+k)-c,m>0)for(k=0;k<o;k++){p=h+k*t;for(j=0;j<o;j++)w[v*j+p]+=m}};this.addPlaneY=function(b,c){var h,k,j,m,p,o,t=this.size,v=this.yd,w=
|
||||
this.zd,u=this.field,y=t*Math.sqrt(b/c);y>t&&(y=t);for(k=0;k<y;k++)if(h=k/t,h*=h,m=b/(1.0E-4+h)-c,m>0){p=k*v;for(h=0;h<t;h++){o=p+h;for(j=0;j<t;j++)u[w*j+o]+=m}}};this.addPlaneZ=function(b,c){var h,k,j,m,p,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(h=j/size,h*=h,m=b/(1.0E-4+h)-c,m>0){p=zd*j;for(k=0;k<size;k++){o=p+k*yd;for(h=0;h<size;h++)field[o+h]+=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,h,k,j,m,p,o,t,v,w=this.size-2;for(j=1;j<w;j++){v=this.size2*j;o=(j-this.halfsize)/this.halfsize;for(k=1;k<w;k++){t=v+this.size*k;p=(k-this.halfsize)/this.halfsize;for(h=1;h<w;h++)m=(h-this.halfsize)/this.halfsize,c=t+h,this.polygonize(m,p,o,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,h=[];this.render(function(k){var j,m,p,o,t,v,w,u;for(j=0;j<k.count;j++)w=j*3,t=w+1,u=w+2,m=k.positionArray[w],
|
||||
p=k.positionArray[t],o=k.positionArray[u],v=new THREE.Vector3(m,p,o),m=k.normalArray[w],p=k.normalArray[t],o=k.normalArray[u],w=new THREE.Vector3(m,p,o),w.normalize(),t=new THREE.Vertex(v),c.vertices.push(t),h.push(w);nfaces=k.count/3;for(j=0;j<nfaces;j++)w=(b+j)*3,t=w+1,u=w+2,v=h[w],m=h[t],p=h[u],w=new THREE.Face3(w,t,u,[v,m,p]),c.faces.push(w);b+=nfaces;k.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]);
|
||||
@@ -608,20 +608,20 @@ THREE.MeshCollider=function(b,c){this.mesh=b;this.box=c;this.numFaces=this.mesh.
|
||||
THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,e,f,h,k=0;c=0;for(e=this.colliders.length;c<e;c++)if(h=this.colliders[c],f=this.rayCast(b,h),f<Number.MAX_VALUE)h.distance=f,f>k?this.hits.push(h):this.hits.unshift(h),k=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 e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,h,k=0;k<c.numFaces;k++){var j=c.mesh.geometry.faces[k],m=c.mesh.geometry.vertices[j.a].position,o=c.mesh.geometry.vertices[j.b].position,t=c.mesh.geometry.vertices[j.c].position,p=j instanceof THREE.Face4?c.mesh.geometry.vertices[j.d].position:null;j instanceof THREE.Face3?(j=this.rayTriangle(e,m,o,t,f,this.collisionNormal,c.mesh),j<f&&(f=j,h=k,c.normal.copy(this.collisionNormal),c.normal.normalize())):
|
||||
j instanceof THREE.Face4&&(j=this.rayTriangle(e,m,o,p,f,this.collisionNormal,c.mesh),j<f&&(f=j,h=k,c.normal.copy(this.collisionNormal),c.normal.normalize()),j=this.rayTriangle(e,o,t,p,f,this.collisionNormal,c.mesh),j<f&&(f=j,h=k,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:f,faceIndex:h}};
|
||||
THREE.CollisionSystem.prototype.rayTriangle=function(b,c,e,f,h,k,j){var m=THREE.CollisionSystem.__v1,o=THREE.CollisionSystem.__v2;k.set(0,0,0);m.sub(e,c);o.sub(f,e);k.cross(m,o);m=k.dot(b.direction);if(!(m<0))if(j.doubleSided||j.flipSided)k.multiplyScalar(-1),m*=-1;else return Number.MAX_VALUE;j=k.dot(c)-k.dot(b.origin);if(!(j<=0))return Number.MAX_VALUE;if(!(j>=m*h))return Number.MAX_VALUE;j/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(j);m.addSelf(b.origin);Math.abs(k.x)>
|
||||
THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,h,k=0;k<c.numFaces;k++){var j=c.mesh.geometry.faces[k],m=c.mesh.geometry.vertices[j.a].position,p=c.mesh.geometry.vertices[j.b].position,o=c.mesh.geometry.vertices[j.c].position,t=j instanceof THREE.Face4?c.mesh.geometry.vertices[j.d].position:null;j instanceof THREE.Face3?(j=this.rayTriangle(e,m,p,o,f,this.collisionNormal,c.mesh),j<f&&(f=j,h=k,c.normal.copy(this.collisionNormal),c.normal.normalize())):
|
||||
j instanceof THREE.Face4&&(j=this.rayTriangle(e,m,p,t,f,this.collisionNormal,c.mesh),j<f&&(f=j,h=k,c.normal.copy(this.collisionNormal),c.normal.normalize()),j=this.rayTriangle(e,p,o,t,f,this.collisionNormal,c.mesh),j<f&&(f=j,h=k,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:f,faceIndex:h}};
|
||||
THREE.CollisionSystem.prototype.rayTriangle=function(b,c,e,f,h,k,j){var m=THREE.CollisionSystem.__v1,p=THREE.CollisionSystem.__v2;k.set(0,0,0);m.sub(e,c);p.sub(f,e);k.cross(m,p);m=k.dot(b.direction);if(!(m<0))if(j.doubleSided||j.flipSided)k.multiplyScalar(-1),m*=-1;else return Number.MAX_VALUE;j=k.dot(c)-k.dot(b.origin);if(!(j<=0))return Number.MAX_VALUE;if(!(j>=m*h))return Number.MAX_VALUE;j/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(j);m.addSelf(b.origin);Math.abs(k.x)>
|
||||
Math.abs(k.y)?Math.abs(k.x)>Math.abs(k.z)?(b=m.y-c.y,k=e.y-c.y,h=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,k=e.x-c.x,h=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(k.y)>Math.abs(k.z)?(b=m.x-c.x,k=e.x-c.x,h=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,k=e.x-c.x,h=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=k*f-e*h;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*h)*c;if(!(f>=0))return Number.MAX_VALUE;c*=k*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return j};
|
||||
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,h=0,k=0,j=0,m=0,o=0,t=!0;e.origin.x<c.min.x?(f=c.min.x-e.origin.x,f/=e.direction.x,t=!1,j=-1):e.origin.x>c.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,t=!1,j=1);e.origin.y<c.min.y?(h=c.min.y-e.origin.y,h/=e.direction.y,t=!1,m=-1):e.origin.y>c.max.y&&(h=c.max.y-e.origin.y,h/=e.direction.y,
|
||||
t=!1,m=1);e.origin.z<c.min.z?(k=c.min.z-e.origin.z,k/=e.direction.z,t=!1,o=-1):e.origin.z>c.max.z&&(k=c.max.z-e.origin.z,k/=e.direction.z,t=!1,o=1);if(t)return-1;t=0;h>f&&(t=1,f=h);k>f&&(t=2,f=k);switch(t){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(j,0,0);break;case 1:j=e.origin.x+e.direction.x*f;if(j<c.min.x||j>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:j=e.origin.x+e.direction.x*f;if(j<c.min.x||j>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,o)}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.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,h=0,k=0,j=0,m=0,p=0,o=!0;e.origin.x<c.min.x?(f=c.min.x-e.origin.x,f/=e.direction.x,o=!1,j=-1):e.origin.x>c.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,o=!1,j=1);e.origin.y<c.min.y?(h=c.min.y-e.origin.y,h/=e.direction.y,o=!1,m=-1):e.origin.y>c.max.y&&(h=c.max.y-e.origin.y,h/=e.direction.y,
|
||||
o=!1,m=1);e.origin.z<c.min.z?(k=c.min.z-e.origin.z,k/=e.direction.z,o=!1,p=-1):e.origin.z>c.max.z&&(k=c.max.z-e.origin.z,k/=e.direction.z,o=!1,p=1);if(o)return-1;o=0;h>f&&(o=1,f=h);k>f&&(o=2,f=k);switch(o){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(j,0,0);break;case 1:j=e.origin.x+e.direction.x*f;if(j<c.min.x||j>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:j=e.origin.x+e.direction.x*f;if(j<c.min.x||j>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,p)}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))};
|
||||
if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,h=new THREE.Camera,k=new THREE.Camera,j=new THREE.Matrix4,m=new THREE.Matrix4,o,t,p;h.useTarget=k.useTarget=!1;h.matrixAutoUpdate=k.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},v=new THREE.WebGLRenderTarget(512,512,b),w=new THREE.WebGLRenderTarget(512,512,b),u=new THREE.Camera(53,1,1,1E4);u.position.z=
|
||||
if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,h=new THREE.Camera,k=new THREE.Camera,j=new THREE.Matrix4,m=new THREE.Matrix4,p,o,t;h.useTarget=k.useTarget=!1;h.matrixAutoUpdate=k.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},v=new THREE.WebGLRenderTarget(512,512,b),w=new THREE.WebGLRenderTarget(512,512,b),u=new THREE.Camera(53,1,1,1E4);u.position.z=
|
||||
2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:v},mapRight:{type:"t",value:1,texture:w}},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 y=new THREE.Scene;y.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);v.width=b;v.height=f;w.width=b;w.height=f};this.render=function(b,e){e.update(null,!0);if(o!==e.aspect||t!==e.near||p!==e.fov){o=e.aspect;t=e.near;p=e.fov;var z=e.projectionMatrix.clone(),H=125/30*0.5,D=H*t/125,I=t*Math.tan(p*Math.PI/360),K;j.n14=H;m.n14=-H;H=-I*o+D;K=I*o+D;z.n11=2*t/(K-H);z.n13=(K+H)/(K-H);h.projectionMatrix=z.clone();H=-I*o-D;K=I*o-D;z.n11=2*t/(K-H);
|
||||
z.n13=(K+H)/(K-H);k.projectionMatrix=z.clone()}h.matrix=e.matrixWorld.clone().multiplySelf(m);h.update(null,!0);h.position.copy(e.position);h.near=t;h.far=e.far;f.call(c,b,h,v,!0);k.matrix=e.matrixWorld.clone().multiplySelf(j);k.update(null,!0);k.position.copy(e.position);k.near=t;k.far=e.far;f.call(c,b,k,w,!0);f.call(c,y,u)}};
|
||||
var y=new THREE.Scene;y.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);v.width=b;v.height=f;w.width=b;w.height=f};this.render=function(b,e){e.update(null,!0);if(p!==e.aspect||o!==e.near||t!==e.fov){p=e.aspect;o=e.near;t=e.fov;var z=e.projectionMatrix.clone(),D=125/30*0.5,C=D*o/125,E=o*Math.tan(t*Math.PI/360),J;j.n14=D;m.n14=-D;D=-E*p+C;J=E*p+C;z.n11=2*o/(J-D);z.n13=(J+D)/(J-D);h.projectionMatrix=z.clone();D=-E*p-C;J=E*p-C;z.n11=2*o/(J-D);
|
||||
z.n13=(J+D)/(J-D);k.projectionMatrix=z.clone()}h.matrix=e.matrixWorld.clone().multiplySelf(m);h.update(null,!0);h.position.copy(e.position);h.near=o;h.far=e.far;f.call(c,b,h,v,!0);k.matrix=e.matrixWorld.clone().multiplySelf(j);k.update(null,!0);k.position.copy(e.position);k.near=o;k.far=e.far;f.call(c,b,k,w,!0);f.call(c,y,u)}};
|
||||
if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,h,k,j=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);h=b/2;k=f};this.render=function(b,e){this.clear();j.fov=e.fov;j.aspect=0.5*e.aspect;j.near=e.near;j.far=e.far;
|
||||
j.updateProjectionMatrix();j.position.copy(e.position);j.target.position.copy(e.target.position);j.translateX(c.separation);m.projectionMatrix=j.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,h,k);f.call(c,b,j);this.setViewport(h,0,h,k);f.call(c,b,m,!1)}};
|
||||
|
||||
+83
-83
@@ -1,8 +1,8 @@
|
||||
// ThreeExtras.js r44dev - http://github.com/mrdoob/three.js
|
||||
THREE.ColorUtils={adjustHSV:function(a,b,c,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.ColorUtils.clamp(f.h+b,0,1);f.s=THREE.ColorUtils.clamp(f.s+c,0,1);f.v=THREE.ColorUtils.clamp(f.v+e,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,b){var c=a.r,e=a.g,f=a.b,h=Math.max(Math.max(c,e),f),g=Math.min(Math.min(c,e),f);if(g==h)g=c=0;else{var j=h-g,g=j/h,c=c==h?(e-f)/j:e==h?2+(f-c)/j:4+(c-e)/j;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=h;return b},
|
||||
clamp:function(a,b,c){return a<b?b:a>c?c:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
|
||||
THREE.GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,f=c?b.geometry:b,h=a.vertices,g=f.vertices,j=a.faces,k=f.faces,l=a.faceVertexUvs[0],f=f.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var m=0,n=g.length;m<n;m++){var o=new THREE.Vertex(g[m].position.clone());c&&b.matrix.multiplyVector3(o.position);h.push(o)}m=0;for(n=k.length;m<n;m++){var g=k[m],p,v,t=g.vertexNormals,o=g.vertexColors;g instanceof THREE.Face3?p=new THREE.Face3(g.a+e,g.b+e,g.c+
|
||||
e):g instanceof THREE.Face4&&(p=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));p.normal.copy(g.normal);c=0;for(h=t.length;c<h;c++)v=t[c],p.vertexNormals.push(v.clone());p.color.copy(g.color);c=0;for(h=o.length;c<h;c++)v=o[c],p.vertexColors.push(v.clone());p.materials=g.materials.slice();p.centroid.copy(g.centroid);j.push(p)}m=0;for(n=f.length;m<n;m++){e=f[m];j=[];c=0;for(h=e.length;c<h;c++)j.push(new THREE.UV(e[c].u,e[c].v));l.push(j)}},clone:function(a){var b=new THREE.Geometry,c,e=a.vertices,f=a.faces,
|
||||
THREE.GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,f=c?b.geometry:b,h=a.vertices,g=f.vertices,j=a.faces,k=f.faces,l=a.faceVertexUvs[0],f=f.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var m=0,n=g.length;m<n;m++){var o=new THREE.Vertex(g[m].position.clone());c&&b.matrix.multiplyVector3(o.position);h.push(o)}m=0;for(n=k.length;m<n;m++){var g=k[m],p,v,u=g.vertexNormals,o=g.vertexColors;g instanceof THREE.Face3?p=new THREE.Face3(g.a+e,g.b+e,g.c+
|
||||
e):g instanceof THREE.Face4&&(p=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));p.normal.copy(g.normal);c=0;for(h=u.length;c<h;c++)v=u[c],p.vertexNormals.push(v.clone());p.color.copy(g.color);c=0;for(h=o.length;c<h;c++)v=o[c],p.vertexColors.push(v.clone());p.materials=g.materials.slice();p.centroid.copy(g.centroid);j.push(p)}m=0;for(n=f.length;m<n;m++){e=f[m];j=[];c=0;for(h=e.length;c<h;c++)j.push(new THREE.UV(e[c].u,e[c].v));l.push(j)}},clone:function(a){var b=new THREE.Geometry,c,e=a.vertices,f=a.faces,
|
||||
h=a.faceVertexUvs[0],a=0;for(c=e.length;a<c;a++){var g=new THREE.Vertex(e[a].position.clone());b.vertices.push(g)}a=0;for(c=f.length;a<c;a++){var j=f[a],k,l,m=j.vertexNormals,n=j.vertexColors;j instanceof THREE.Face3?k=new THREE.Face3(j.a,j.b,j.c):j instanceof THREE.Face4&&(k=new THREE.Face4(j.a,j.b,j.c,j.d));k.normal.copy(j.normal);e=0;for(g=m.length;e<g;e++)l=m[e],k.vertexNormals.push(l.clone());k.color.copy(j.color);e=0;for(g=n.length;e<g;e++)l=n[e],k.vertexColors.push(l.clone());k.materials=j.materials.slice();
|
||||
k.centroid.copy(j.centroid);b.faces.push(k)}a=0;for(c=h.length;a<c;a++){f=h[a];k=[];e=0;for(g=f.length;e<g;e++)k.push(new THREE.UV(f[e].u,f[e].v));b.faceVertexUvs[0].push(k)}return b},randomPointInTriangle:function(a,b,c){var e,f,h,g=new THREE.Vector3,j=THREE.GeometryUtils.__v1;e=THREE.GeometryUtils.random();f=THREE.GeometryUtils.random();e+f>1&&(e=1-e,f=1-f);h=1-e-f;g.copy(a);g.multiplyScalar(e);j.copy(b);j.multiplyScalar(f);g.addSelf(j);j.copy(c);j.multiplyScalar(h);g.addSelf(j);return g},randomPointInFace:function(a,
|
||||
b,c){var e,f,h;if(a instanceof THREE.Face3)return e=b.vertices[a.a].position,f=b.vertices[a.b].position,h=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(e,f,h);else if(a instanceof THREE.Face4){e=b.vertices[a.a].position;f=b.vertices[a.b].position;h=b.vertices[a.c].position;var b=b.vertices[a.d].position,g;c?a._area1&&a._area2?(c=a._area1,g=a._area2):(c=THREE.GeometryUtils.triangleArea(e,f,b),g=THREE.GeometryUtils.triangleArea(f,h,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(e,
|
||||
@@ -10,9 +10,9 @@ f,b),g=THREE.GeometryUtils.triangleArea(f,h,b));return THREE.GeometryUtils.rando
|
||||
o=g[e.c].position,e._area=THREE.GeometryUtils.triangleArea(m,n,o);else if(e instanceof THREE.Face4)m=g[e.a].position,n=g[e.b].position,o=g[e.c].position,p=g[e.d].position,e._area1=THREE.GeometryUtils.triangleArea(m,n,p),e._area2=THREE.GeometryUtils.triangleArea(n,o,p),e._area=e._area1+e._area2;k+=e._area;l[f]=k}e=[];g={};for(f=0;f<b;f++)j=THREE.GeometryUtils.random()*k,j=c(j),e[f]=THREE.GeometryUtils.randomPointInFace(h[j],a,!0),g[j]?g[j]+=1:g[j]=1;return e},triangleArea:function(a,b,c){var e,f=THREE.GeometryUtils.__v1;
|
||||
f.sub(a,b);e=f.length();f.sub(a,c);a=f.length();f.sub(b,c);c=f.length();b=0.5*(e+a+c);return Math.sqrt(b*(b-e)*(b-a)*(b-c))},random16:function(){return(65280*Math.random()+255*Math.random())/65535}};THREE.GeometryUtils.random=THREE.GeometryUtils.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
|
||||
THREE.ImageUtils={loadTexture:function(a,b,c){var e=new Image,f=new THREE.Texture(e,b);e.onload=function(){f.needsUpdate=!0;c&&c(this)};e.crossOrigin="";e.src=a;return f},loadTextureCube:function(a,b,c){var e,f=[],h=new THREE.Texture(f,b),b=f.loadCount=0;for(e=a.length;b<e;++b)f[b]=new Image,f[b].onload=function(){f.loadCount+=1;if(f.loadCount==6)h.needsUpdate=!0;c&&c(this)},f[b].crossOrigin="",f[b].src=a[b];return h},getNormalMap:function(a,b){var c=function(a){var c=Math.sqrt(a[0]*a[0]+a[1]*a[1]+
|
||||
a[2]*a[2]);return[a[0]/c,a[1]/c,a[2]/c]};b|=1;var e=a.width,f=a.height,h=document.createElement("canvas");h.width=e;h.height=f;var g=h.getContext("2d");g.drawImage(a,0,0);for(var j=g.getImageData(0,0,e,f).data,k=g.createImageData(e,f),l=k.data,m=0;m<e;m++)for(var n=1;n<f;n++){var o=n-1<0?f-1:n-1,p=(n+1)%f,v=m-1<0?e-1:m-1,t=(m+1)%e,w=[],y=[0,0,j[(n*e+m)*4]/255*b];w.push([-1,0,j[(n*e+v)*4]/255*b]);w.push([-1,-1,j[(o*e+v)*4]/255*b]);w.push([0,-1,j[(o*e+m)*4]/255*b]);w.push([1,-1,j[(o*e+t)*4]/255*b]);
|
||||
w.push([1,0,j[(n*e+t)*4]/255*b]);w.push([1,1,j[(p*e+t)*4]/255*b]);w.push([0,1,j[(p*e+m)*4]/255*b]);w.push([-1,1,j[(p*e+v)*4]/255*b]);o=[];v=w.length;for(p=0;p<v;p++){var t=w[p],x=w[(p+1)%v],t=[t[0]-y[0],t[1]-y[1],t[2]-y[2]],x=[x[0]-y[0],x[1]-y[1],x[2]-y[2]];o.push(c([t[1]*x[2]-t[2]*x[1],t[2]*x[0]-t[0]*x[2],t[0]*x[1]-t[1]*x[0]]))}w=[0,0,0];for(p=0;p<o.length;p++)w[0]+=o[p][0],w[1]+=o[p][1],w[2]+=o[p][2];w[0]/=o.length;w[1]/=o.length;w[2]/=o.length;y=(n*e+m)*4;l[y]=(w[0]+1)/2*255|0;l[y+1]=(w[1]+0.5)*
|
||||
255|0;l[y+2]=w[2]*255|0;l[y+3]=255}g.putImageData(k,0,0);return h}};THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,e,f=a.children.length;for(e=0;e<f;e++)c=a.children[e],b(c),THREE.SceneUtils.traverseHierarchy(c,b)}};
|
||||
a[2]*a[2]);return[a[0]/c,a[1]/c,a[2]/c]};b|=1;var e=a.width,f=a.height,h=document.createElement("canvas");h.width=e;h.height=f;var g=h.getContext("2d");g.drawImage(a,0,0);for(var j=g.getImageData(0,0,e,f).data,k=g.createImageData(e,f),l=k.data,m=0;m<e;m++)for(var n=1;n<f;n++){var o=n-1<0?f-1:n-1,p=(n+1)%f,v=m-1<0?e-1:m-1,u=(m+1)%e,x=[],y=[0,0,j[(n*e+m)*4]/255*b];x.push([-1,0,j[(n*e+v)*4]/255*b]);x.push([-1,-1,j[(o*e+v)*4]/255*b]);x.push([0,-1,j[(o*e+m)*4]/255*b]);x.push([1,-1,j[(o*e+u)*4]/255*b]);
|
||||
x.push([1,0,j[(n*e+u)*4]/255*b]);x.push([1,1,j[(p*e+u)*4]/255*b]);x.push([0,1,j[(p*e+m)*4]/255*b]);x.push([-1,1,j[(p*e+v)*4]/255*b]);o=[];v=x.length;for(p=0;p<v;p++){var u=x[p],w=x[(p+1)%v],u=[u[0]-y[0],u[1]-y[1],u[2]-y[2]],w=[w[0]-y[0],w[1]-y[1],w[2]-y[2]];o.push(c([u[1]*w[2]-u[2]*w[1],u[2]*w[0]-u[0]*w[2],u[0]*w[1]-u[1]*w[0]]))}x=[0,0,0];for(p=0;p<o.length;p++)x[0]+=o[p][0],x[1]+=o[p][1],x[2]+=o[p][2];x[0]/=o.length;x[1]/=o.length;x[2]/=o.length;y=(n*e+m)*4;l[y]=(x[0]+1)/2*255|0;l[y+1]=(x[1]+0.5)*
|
||||
255|0;l[y+2]=x[2]*255|0;l[y+3]=255}g.putImageData(k,0,0);return h}};THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,e,f=a.children.length;for(e=0;e<f;e++)c=a.children[e],b(c),THREE.SceneUtils.traverseHierarchy(c,b)}};
|
||||
if(THREE.WebGLRenderer)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:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,{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},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",
|
||||
@@ -30,7 +30,7 @@ THREE.Bone?f.skinMatrix:f.matrix;var h=f.animationCache.prevKey;f=f.animationCac
|
||||
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 a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==void 0)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
|
||||
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,f,h,g,j,k,l,m=this.data.JIT.hierarchy,n,o;this.currentTime+=a*this.timeScale;o=this.currentTime;n=this.currentTime%=this.data.length;l=parseInt(Math.min(n*this.data.fps,this.data.length*this.data.fps),10);for(var p=0,v=this.hierarchy.length;p<v;p++)if(a=this.hierarchy[p],k=a.animationCache,this.JITCompile&&m[p][l]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=m[p][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
|
||||
!1):(a.matrix=m[p][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var t=0;t<3;t++){c=b[t];g=k.prevKey[c];j=k.nextKey[c];if(j.time<=o){if(n<o)if(this.loop){g=this.data.hierarchy[p].keys[0];for(j=this.getNextKeyWith(c,p,1);j.time<n;)g=j,j=this.getNextKeyWith(c,p,j.index+1)}else{this.stop();return}else{do g=j,j=this.getNextKeyWith(c,p,j.index+1);while(j.time<
|
||||
!1):(a.matrix=m[p][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var u=0;u<3;u++){c=b[u];g=k.prevKey[c];j=k.nextKey[c];if(j.time<=o){if(n<o)if(this.loop){g=this.data.hierarchy[p].keys[0];for(j=this.getNextKeyWith(c,p,1);j.time<n;)g=j,j=this.getNextKeyWith(c,p,j.index+1)}else{this.stop();return}else{do g=j,j=this.getNextKeyWith(c,p,j.index+1);while(j.time<
|
||||
n)}k.prevKey[c]=g;k.nextKey[c]=j}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(n-g.time)/(j.time-g.time);f=g[c];h=j[c];if(e<0||e>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+p),e=e<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=f[0]+(h[0]-f[0])*e,c.y=f[1]+(h[1]-f[1])*e,c.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",p,g.index-1).pos,this.points[1]=f,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",p,j.index+1).pos,e=e*0.33+0.33,f=this.interpolateCatmullRom(this.points,e),c.x=f[0],c.y=f[1],c.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(c),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(c===
|
||||
"rot")THREE.Quaternion.slerp(f,h,a.quaternion,e);else if(c==="scl")c=a.scale,c.x=f[0]+(h[0]-f[0])*e,c.y=f[1]+(h[1]-f[1])*e,c.z=f[2]+(h[2]-f[2])*e}}if(this.JITCompile&&m[0][l]===void 0){this.hierarchy[0].update(void 0,!0);for(p=0;p<this.hierarchy.length;p++)m[p][l]=this.hierarchy[p]instanceof THREE.Bone?this.hierarchy[p].skinMatrix.clone():this.hierarchy[p].matrix.clone()}}};
|
||||
@@ -47,7 +47,7 @@ this.moveRight&&this.translateX(b);this.moveUp&&this.translateY(b);this.moveDown
|
||||
1;this.constrainVertical&&(a=3.14/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b*a);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;a=this.target.position;f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*
|
||||
Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};
|
||||
THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);if(this.noFly)b.y=0;this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};
|
||||
THREE.PathCamera=function(a){function b(a,c,b,e){var g={name:b,fps:0.6,length:e,hierarchy:[]},h,f=c.getControlPointsArray(),j=c.getLength(),k=f.length,x=0;h=k-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[h]={time:e,pos:f[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<k-1;h++)x=e*j.chunks[h]/j.total,c.keys[h]={time:x,pos:f[h]};g.hierarchy[0]=c;THREE.AnimationHandler.add(g);return new THREE.Animation(a,b,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(a,c){var b,
|
||||
THREE.PathCamera=function(a){function b(a,c,b,e){var g={name:b,fps:0.6,length:e,hierarchy:[]},h,f=c.getControlPointsArray(),j=c.getLength(),k=f.length,w=0;h=k-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[h]={time:e,pos:f[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<k-1;h++)w=e*j.chunks[h]/j.total,c.keys[h]={time:w,pos:f[h]};g.hierarchy[0]=c;THREE.AnimationHandler.add(g);return new THREE.Animation(a,b,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(a,c){var b,
|
||||
e,g=new THREE.Geometry;for(b=0;b<a.points.length*c;b++)e=b/(a.points.length*c),e=a.getPoint(e),g.vertices[b]=new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z));return g}function e(a,b){var e=c(b,10),g=c(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(e,h);particleObj=new THREE.ParticleSystem(g,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.addChild(lineObj);particleObj.scale.set(1,1,1);a.addChild(particleObj);g=new THREE.SphereGeometry(1,
|
||||
16,8);h=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<b.points.length;i++)e=new THREE.Mesh(g,h),e.position.copy(b.points[i]),e.updateMatrix(),a.addChild(e)}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.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(a){if(a.duration!==void 0)this.duration=a.duration*1E3;if(a.waypoints!==void 0)this.waypoints=a.waypoints;if(a.useConstantSpeed!==void 0)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==void 0)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==void 0)this.createDebugPath=a.createDebugPath;if(a.createDebugDummy!==
|
||||
@@ -67,18 +67,18 @@ this.rollSpeed;this.translateX(this.moveVector.x*a);this.translateY(this.moveVec
|
||||
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=-a+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",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this,this.mouseup),!1);window.addEventListener("keydown",b(this,this.keydown),!1);window.addEventListener("keyup",b(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(a,b,c,e){THREE.Camera.call(this,a,b,c,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,g=new THREE.Vector3,j=new THREE.Matrix4,k=!1,l=1,m=0,n=0,o=0,p=0,v=0,t=window.innerWidth/2,w=window.innerHeight/2;this.update=
|
||||
THREE.RollCamera=function(a,b,c,e){THREE.Camera.call(this,a,b,c,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,g=new THREE.Vector3,j=new THREE.Matrix4,k=!1,l=1,m=0,n=0,o=0,p=0,v=0,u=window.innerWidth/2,x=window.innerHeight/2;this.update=
|
||||
function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.delta=(a-this.lastUpdate)/1E3;this.lastUpdate=a;this.mouseLook&&(a=this.delta*this.lookSpeed,this.rotateHorizontally(a*p),this.rotateVertically(a*v));a=this.delta*this.movementSpeed;this.translateZ(a*(m>0||this.autoForward&&!(m<0)?1:m));this.translateX(a*n);this.translateY(a*o);k&&(this.roll+=this.rollSpeed*this.delta*l);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();g.copy(this.forward);h.set(0,1,0);f.cross(h,g).normalize();h.cross(g,f).normalize();this.matrix.n11=f.x;this.matrix.n12=h.x;this.matrix.n13=g.x;this.matrix.n21=f.y;this.matrix.n22=h.y;this.matrix.n23=g.y;this.matrix.n31=f.z;this.matrix.n32=h.z;this.matrix.n33=g.z;j.identity();j.n11=Math.cos(this.roll);j.n12=-Math.sin(this.roll);j.n21=Math.sin(this.roll);j.n22=Math.cos(this.roll);this.matrix.multiplySelf(j);
|
||||
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(a){this.position.x+=this.matrix.n11*a;this.position.y+=this.matrix.n21*a;this.position.z+=this.matrix.n31*a};this.translateY=function(a){this.position.x+=this.matrix.n12*a;this.position.y+=this.matrix.n22*a;this.position.z+=this.matrix.n32*a};this.translateZ=function(a){this.position.x-=this.matrix.n13*a;this.position.y-=
|
||||
this.matrix.n23*a;this.position.z-=this.matrix.n33*a};this.rotateHorizontally=function(a){f.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);f.multiplyScalar(a);this.forward.subSelf(f);this.forward.normalize()};this.rotateVertically=function(a){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(a);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",
|
||||
function(a){p=(a.clientX-t)/window.innerWidth;v=(a.clientY-w)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:m=1;break;case 2:m=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:m=0;break;case 2:m=0}},!1);this.domElement.addEventListener("keydown",function(a){switch(a.keyCode){case 38:case 87:m=1;break;case 37:case 65:n=-1;break;
|
||||
function(a){p=(a.clientX-u)/window.innerWidth;v=(a.clientY-x)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:m=1;break;case 2:m=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:m=0;break;case 2:m=0}},!1);this.domElement.addEventListener("keydown",function(a){switch(a.keyCode){case 38:case 87:m=1;break;case 37:case 65:n=-1;break;
|
||||
case 40:case 83:m=-1;break;case 39:case 68:n=1;break;case 81:k=!0;l=1;break;case 69:k=!0;l=-1;break;case 82:o=1;break;case 70:o=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:m=0;break;case 37:case 65:n=0;break;case 40:case 83:m=0;break;case 39:case 68:n=0;break;case 81:k=!1;break;case 69:k=!1;break;case 82:o=0;break;case 70:o=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
|
||||
THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
|
||||
THREE.TrackballCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}a=a||{};THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.domElement=a.domElement||document;this.screen=a.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=a.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=a.rotateSpeed||1;this.zoomSpeed=a.zoomSpeed||1.2;this.panSpeed=a.panSpeed||0.3;this.noZoom=a.noZoom||!1;this.noPan=a.noPan||
|
||||
!1;this.staticMoving=a.staticMoving||!1;this.dynamicDampingFactor=a.dynamicDampingFactor||0.2;this.minDistance=a.minDistance||0;this.maxDistance=a.maxDistance||Infinity;this.keys=a.keys||[65,83,68];this.useTarget=!0;var c=!1,e=this.STATE.NONE,f=new THREE.Vector3,h=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector2,k=new THREE.Vector2,l=new THREE.Vector2,m=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2((a-
|
||||
this.screen.offsetLeft)/this.radius*0.5,(b-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(a,b){var c=new THREE.Vector3((a-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-b)/this.radius,0),e=c.length();e>1?c.normalize():c.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(c.y);e.addSelf(this.up.clone().crossSelf(f).setLength(c.x));e.addSelf(f.setLength(c.z));return e};
|
||||
this.rotateCamera=function(){var a=Math.acos(h.dot(g)/h.length()/g.length());if(a){var b=(new THREE.Vector3).cross(h,g).normalize(),c=new THREE.Quaternion;a*=this.rotateSpeed;c.setFromAxisAngle(b,-a);c.multiplyVector3(f);c.multiplyVector3(this.up);c.multiplyVector3(g);this.staticMoving?h=g:(c.setFromAxisAngle(b,a*(this.dynamicDampingFactor-1)),c.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),this.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)};
|
||||
THREE.TrackballCamera=function(a){function b(a,c){return function(){c.apply(a,arguments)}}a=a||{};THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.domElement=a.domElement||document;this.screen=a.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=a.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=a.rotateSpeed||1;this.zoomSpeed=a.zoomSpeed||1.2;this.panSpeed=a.panSpeed||0.3;this.noZoom=a.noZoom||!1;this.noPan=a.noPan||
|
||||
!1;this.staticMoving=a.staticMoving||!1;this.dynamicDampingFactor=a.dynamicDampingFactor||0.2;this.minDistance=a.minDistance||0;this.maxDistance=a.maxDistance||Infinity;this.keys=a.keys||[65,83,68];this.useTarget=!0;var c=!1,e=this.STATE.NONE,f=new THREE.Vector3,h=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector2,k=new THREE.Vector2,l=new THREE.Vector2,m=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,c){return new THREE.Vector2((a-
|
||||
this.screen.offsetLeft)/this.radius*0.5,(c-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(a,c){var b=new THREE.Vector3((a-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-c)/this.radius,0),e=b.length();e>1?b.normalize():b.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(b.y);e.addSelf(this.up.clone().crossSelf(f).setLength(b.x));e.addSelf(f.setLength(b.z));return e};
|
||||
this.rotateCamera=function(){var a=Math.acos(h.dot(g)/h.length()/g.length());if(a){var c=(new THREE.Vector3).cross(h,g).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c,-a);b.multiplyVector3(f);b.multiplyVector3(this.up);b.multiplyVector3(g);this.staticMoving?h=g:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),this.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)};
|
||||
this.panCamera=function(){var a=m.clone().subSelf(l);if(a.lengthSq()){a.multiplyScalar(f.length()*this.panSpeed);var b=f.clone().crossSelf(this.up).setLength(a.x);b.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(b);this.target.position.addSelf(b);this.staticMoving?l=m:l.addSelf(a.sub(m,l).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(a,b,c){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,a,b,c)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",
|
||||
b(this,function(a){c&&(h=g=this.getMouseProjectionOnBall(a.clientX,a.clientY),j=k=this.getMouseOnScreen(a.clientX,a.clientY),l=m=this.getMouseOnScreen(a.clientX,a.clientY),c=!1);e!==this.STATE.NONE&&(e===this.STATE.ROTATE?g=this.getMouseProjectionOnBall(a.clientX,a.clientY):e===this.STATE.ZOOM&&!this.noZoom?k=this.getMouseOnScreen(a.clientX,a.clientY):e===this.STATE.PAN&&!this.noPan&&(m=this.getMouseOnScreen(a.clientX,a.clientY)))}),!1);this.domElement.addEventListener("mousedown",b(this,function(a){a.preventDefault();
|
||||
@@ -112,9 +112,9 @@ THREE.Path.prototype.quadraticCurveTo=function(a,b,c,e){var f=Array.prototype.sl
|
||||
THREE.Path.prototype.bezierCurveTo=function(a,b,c,e,f,h){var g=Array.prototype.slice.call(arguments),j=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(j[j.length-2],j[j.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,e),new THREE.Vector2(f,h)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g})};
|
||||
THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])],c=c.concat(a);this.curves.push(new THREE.SplineCurve(c));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})};THREE.Path.prototype.arc=function(a,b,c,e,f,h){var g=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(a,b,c,e,f,h));this.actions.push({action:THREE.PathActions.ARC,args:g})};
|
||||
THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));return b};
|
||||
THREE.Path.prototype.getPoints=function(a,b){var a=a||12,c=[],e,f,h,g,j,k,l,m,n,o,p,v,t;e=0;for(f=this.actions.length;e<f;e++)switch(h=this.actions[e],g=h.action,h=h.args,g){case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(h[0],h[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:j=h[2];k=h[3];n=h[0];o=h[1];c.length>0?(g=c[c.length-1],p=g.x,v=g.y):(g=this.actions[e-1].args,p=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)t=g/a,h=THREE.Shape.Utils.b2(t,p,n,j),t=THREE.Shape.Utils.b2(t,v,o,
|
||||
k),c.push(new THREE.Vector2(h,t));break;case THREE.PathActions.BEZIER_CURVE_TO:j=h[4];k=h[5];n=h[0];o=h[1];l=h[2];m=h[3];c.length>0?(g=c[c.length-1],p=g.x,v=g.y):(g=this.actions[e-1].args,p=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)t=g/a,h=THREE.Shape.Utils.b3(t,p,n,l,j),t=THREE.Shape.Utils.b3(t,v,o,m,k),c.push(new THREE.Vector2(h,t));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[e-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];t=a*h[0].length;g=g.concat(h[0]);h=new THREE.SplineCurve(g);
|
||||
for(g=1;g<=t;g++)c.push(h.getPointAt(g/t));break;case THREE.PathActions.ARC:g=this.actions[e-1].args;j=h[0];k=h[1];l=h[2];n=h[3];t=h[4];o=!!h[5];m=g[g.length-2];p=g[g.length-1];g.length==0&&(m=p=0);v=t-n;var w=a*2;for(g=1;g<=w;g++)t=g/w,o||(t=1-t),t=n+t*v,h=m+j+l*Math.cos(t),t=p+k+l*Math.sin(t),c.push(new THREE.Vector2(h,t))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)};
|
||||
THREE.Path.prototype.getPoints=function(a,b){var a=a||12,c=[],e,f,h,g,j,k,l,m,n,o,p,v,u;e=0;for(f=this.actions.length;e<f;e++)switch(h=this.actions[e],g=h.action,h=h.args,g){case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(h[0],h[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:j=h[2];k=h[3];n=h[0];o=h[1];c.length>0?(g=c[c.length-1],p=g.x,v=g.y):(g=this.actions[e-1].args,p=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)u=g/a,h=THREE.Shape.Utils.b2(u,p,n,j),u=THREE.Shape.Utils.b2(u,v,o,
|
||||
k),c.push(new THREE.Vector2(h,u));break;case THREE.PathActions.BEZIER_CURVE_TO:j=h[4];k=h[5];n=h[0];o=h[1];l=h[2];m=h[3];c.length>0?(g=c[c.length-1],p=g.x,v=g.y):(g=this.actions[e-1].args,p=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)u=g/a,h=THREE.Shape.Utils.b3(u,p,n,l,j),u=THREE.Shape.Utils.b3(u,v,o,m,k),c.push(new THREE.Vector2(h,u));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[e-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];u=a*h[0].length;g=g.concat(h[0]);h=new THREE.SplineCurve(g);
|
||||
for(g=1;g<=u;g++)c.push(h.getPointAt(g/u));break;case THREE.PathActions.ARC:g=this.actions[e-1].args;j=h[0];k=h[1];l=h[2];n=h[3];u=h[4];o=!!h[5];m=g[g.length-2];p=g[g.length-1];g.length==0&&(m=p=0);v=u-n;var x=a*2;for(g=1;g<=x;g++)u=g/x,o||(u=1-u),u=n+u*v,h=m+j+l*Math.cos(u),u=p+k+l*Math.sin(u),c.push(new THREE.Vector2(h,u))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)};
|
||||
THREE.Path.prototype.nltransform=function(a,b,c,e,f,h){var g=this.getPoints(),j,k,l,m,n;j=0;for(k=g.length;j<k;j++)l=g[j],m=l.x,n=l.y,l.x=a*m+b*n+c,l.y=e*n+f*m+h;return g};
|
||||
THREE.Path.prototype.debug=function(a){var b=this.getBoundingBox();a||(a=document.createElement("canvas"),a.setAttribute("width",b.maxX+100),a.setAttribute("height",b.maxY+100),document.body.appendChild(a));b=a.getContext("2d");b.fillStyle="white";b.fillRect(0,0,a.width,a.height);b.strokeStyle="black";b.beginPath();var c,e,f,a=0;for(c=this.actions.length;a<c;a++)e=this.actions[a],f=e.args,e=e.action,e!=THREE.PathActions.CSPLINE_THRU&&b[e].apply(b,f);b.stroke();b.closePath();b.strokeStyle="red";e=
|
||||
this.getPoints();a=0;for(c=e.length;a<c;a++)f=e[a],b.beginPath(),b.arc(f.x,f.y,1.5,0,Math.PI*2,!1),b.stroke(),b.closePath()};
|
||||
@@ -122,29 +122,29 @@ THREE.Path.prototype.toShapes=function(){var a,b,c,e,f=[],h=new THREE.Path;a=0;f
|
||||
e.curves):g.holes.push(e);h.push(g)}else{g=new THREE.Shape;a=0;for(b=f.length;a<b;a++)e=f[a],THREE.Shape.Utils.isClockWise(e.getPoints())?(g.actions=e.actions,g.curves=e.curves,h.push(g),g=new THREE.Shape):g.holes.push(e)}return h};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};
|
||||
THREE.Shape.prototype.getPointsHoles=function(a){var b,c=this.holes.length,e=[];for(b=0;b<c;b++)e[b]=this.holes[b].getTransformedPoints(a,this.bends);return e};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var b,c=this.holes.length,e=[];for(b=0;b<c;b++)e[b]=this.holes[b].getTransformedSpacedPoints(a,this.bends);return e};THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};
|
||||
THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
|
||||
THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),e=c.concat(),f,h,g,j,k,l,m,n,o,p,v=[];for(k=0;k<b.length;k++){l=b[k];e=e.concat(l);h=Number.POSITIVE_INFINITY;for(f=0;f<l.length;f++){o=l[f];p=[];for(n=0;n<c.length;n++)m=c[n],m=o.distanceToSquared(m),p.push(m),m<h&&(h=m,g=f,j=n)}f=j-1>=0?j-1:c.length-1;h=g-1>=0?g-1:l.length-1;var t=[l[g],c[j],c[f]];n=THREE.FontUtils.Triangulate.area(t);var w=[l[g],l[h],c[j]];o=THREE.FontUtils.Triangulate.area(w);p=j;m=g;j+=1;g+=-1;j<0&&(j+=c.length);j%=
|
||||
c.length;g<0&&(g+=l.length);g%=l.length;f=j-1>=0?j-1:c.length-1;h=g-1>=0?g-1:l.length-1;t=[l[g],c[j],c[f]];t=THREE.FontUtils.Triangulate.area(t);w=[l[g],l[h],c[j]];w=THREE.FontUtils.Triangulate.area(w);n+o>t+w&&(j=p,g=m,j<0&&(j+=c.length),j%=c.length,g<0&&(g+=l.length),g%=l.length,f=j-1>=0?j-1:c.length-1,h=g-1>=0?g-1:l.length-1);n=c.slice(0,j);o=c.slice(j);p=l.slice(g);m=l.slice(0,g);h=[l[g],l[h],c[j]];v.push([l[g],c[j],c[f]]);v.push(h);c=n.concat(p).concat(m).concat(o)}return{shape:c,isolatedPts:v,
|
||||
THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),e=c.concat(),f,h,g,j,k,l,m,n,o,p,v=[];for(k=0;k<b.length;k++){l=b[k];e=e.concat(l);h=Number.POSITIVE_INFINITY;for(f=0;f<l.length;f++){o=l[f];p=[];for(n=0;n<c.length;n++)m=c[n],m=o.distanceToSquared(m),p.push(m),m<h&&(h=m,g=f,j=n)}f=j-1>=0?j-1:c.length-1;h=g-1>=0?g-1:l.length-1;var u=[l[g],c[j],c[f]];n=THREE.FontUtils.Triangulate.area(u);var x=[l[g],l[h],c[j]];o=THREE.FontUtils.Triangulate.area(x);p=j;m=g;j+=1;g+=-1;j<0&&(j+=c.length);j%=
|
||||
c.length;g<0&&(g+=l.length);g%=l.length;f=j-1>=0?j-1:c.length-1;h=g-1>=0?g-1:l.length-1;u=[l[g],c[j],c[f]];u=THREE.FontUtils.Triangulate.area(u);x=[l[g],l[h],c[j]];x=THREE.FontUtils.Triangulate.area(x);n+o>u+x&&(j=p,g=m,j<0&&(j+=c.length),j%=c.length,g<0&&(g+=l.length),g%=l.length,f=j-1>=0?j-1:c.length-1,h=g-1>=0?g-1:l.length-1);n=c.slice(0,j);o=c.slice(j);p=l.slice(g);m=l.slice(0,g);h=[l[g],l[h],c[j]];v.push([l[g],c[j],c[f]]);v.push(h);c=n.concat(p).concat(m).concat(o)}return{shape:c,isolatedPts:v,
|
||||
allpoints:e}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),e=c.allpoints,f=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),h,g,j,k,l={};h=0;for(g=e.length;h<g;h++)k=e[h].x+":"+e[h].y,l[k]!==void 0&&console.log("Duplicate point",k),l[k]=h;h=0;for(g=c.length;h<g;h++){j=c[h];for(e=0;e<3;e++)k=j[e].x+":"+j[e].y,k=l[k],k!==void 0&&(j[e]=k)}h=0;for(g=f.length;h<g;h++){j=f[h];for(e=0;e<3;e++)k=j[e].x+":"+j[e].y,k=l[k],k!==void 0&&(j[e]=k)}return c.concat(f)},isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<
|
||||
0},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,e){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,e)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,e,f){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,e)+this.b3p3(a,f)}};
|
||||
THREE.TextPath=function(a,b){THREE.Path.call(this);this.parameters=b||{};this.set(a)};THREE.TextPath.prototype.set=function(a,b){this.text=a;var b=b||this.parameters,c=b.curveSegments!==void 0?b.curveSegments:4,e=b.font!==void 0?b.font:"helvetiker",f=b.weight!==void 0?b.weight:"normal",h=b.style!==void 0?b.style:"normal";THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=e;THREE.FontUtils.weight=f;THREE.FontUtils.style=h};
|
||||
THREE.TextPath.prototype.toShapes=function(){for(var a=THREE.FontUtils.drawText(this.text).paths,b=[],c=0,e=a.length;c<e;c++)b=b.concat(a[c].toShapes());return b};
|
||||
THREE.CubeGeometry=function(a,b,c,e,f,h,g,j,k){function l(a,b,c,g,j,k,l,n){var p,o,t=e||1,v=f||1,C=j/2,I=k/2,K=m.vertices.length;if(a=="x"&&b=="y"||a=="y"&&b=="x")p="z";else if(a=="x"&&b=="z"||a=="z"&&b=="x")p="y",v=h||1;else if(a=="z"&&b=="y"||a=="y"&&b=="z")p="x",t=h||1;var L=t+1,J=v+1;j/=t;var N=k/v;for(o=0;o<J;o++)for(k=0;k<L;k++){var D=new THREE.Vector3;D[a]=(k*j-C)*c;D[b]=(o*N-I)*g;D[p]=l;m.vertices.push(new THREE.Vertex(D))}for(o=0;o<v;o++)for(k=0;k<t;k++)m.faces.push(new THREE.Face4(k+L*o+
|
||||
K,k+L*(o+1)+K,k+1+L*(o+1)+K,k+1+L*o+K,null,null,n)),m.faceVertexUvs[0].push([new THREE.UV(k/t,o/v),new THREE.UV(k/t,(o+1)/v),new THREE.UV((k+1)/t,(o+1)/v),new THREE.UV((k+1)/t,o/v)])}THREE.Geometry.call(this);var m=this,n=a/2,o=b/2,p=c/2,j=j?-1:1;if(g!==void 0)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var v=0;v<6;v++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=void 0)for(var t in k)this.sides[t]!=void 0&&(this.sides[t]=
|
||||
k[t]);this.sides.px&&l("z","y",1*j,-1,c,b,-n,this.materials[0]);this.sides.nx&&l("z","y",-1*j,-1,c,b,n,this.materials[1]);this.sides.py&&l("x","z",1*j,1,a,c,o,this.materials[2]);this.sides.ny&&l("x","z",1*j,-1,a,c,-o,this.materials[3]);this.sides.pz&&l("x","y",1*j,-1,a,b,p,this.materials[4]);this.sides.nz&&l("x","y",-1*j,-1,a,b,-p,this.materials[5]);(function(){for(var a=[],b=[],c=0,e=m.vertices.length;c<e;c++){for(var g=m.vertices[c],h=!1,f=0,j=a.length;f<j;f++){var k=a[f];if(g.position.x==k.position.x&&
|
||||
THREE.CubeGeometry=function(a,b,c,e,f,h,g,j,k){function l(a,b,c,g,j,k,l,n){var p,o,u=e||1,v=f||1,D=j/2,I=k/2,K=m.vertices.length;if(a=="x"&&b=="y"||a=="y"&&b=="x")p="z";else if(a=="x"&&b=="z"||a=="z"&&b=="x")p="y",v=h||1;else if(a=="z"&&b=="y"||a=="y"&&b=="z")p="x",u=h||1;var M=u+1,J=v+1;j/=u;var N=k/v;for(o=0;o<J;o++)for(k=0;k<M;k++){var E=new THREE.Vector3;E[a]=(k*j-D)*c;E[b]=(o*N-I)*g;E[p]=l;m.vertices.push(new THREE.Vertex(E))}for(o=0;o<v;o++)for(k=0;k<u;k++)m.faces.push(new THREE.Face4(k+M*o+
|
||||
K,k+M*(o+1)+K,k+1+M*(o+1)+K,k+1+M*o+K,null,null,n)),m.faceVertexUvs[0].push([new THREE.UV(k/u,o/v),new THREE.UV(k/u,(o+1)/v),new THREE.UV((k+1)/u,(o+1)/v),new THREE.UV((k+1)/u,o/v)])}THREE.Geometry.call(this);var m=this,n=a/2,o=b/2,p=c/2,j=j?-1:1;if(g!==void 0)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var v=0;v<6;v++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=void 0)for(var u in k)this.sides[u]!=void 0&&(this.sides[u]=
|
||||
k[u]);this.sides.px&&l("z","y",1*j,-1,c,b,-n,this.materials[0]);this.sides.nx&&l("z","y",-1*j,-1,c,b,n,this.materials[1]);this.sides.py&&l("x","z",1*j,1,a,c,o,this.materials[2]);this.sides.ny&&l("x","z",1*j,-1,a,c,-o,this.materials[3]);this.sides.pz&&l("x","y",1*j,-1,a,b,p,this.materials[4]);this.sides.nz&&l("x","y",-1*j,-1,a,b,-p,this.materials[5]);(function(){for(var a=[],b=[],c=0,e=m.vertices.length;c<e;c++){for(var g=m.vertices[c],h=!1,f=0,j=a.length;f<j;f++){var k=a[f];if(g.position.x==k.position.x&&
|
||||
g.position.y==k.position.y&&g.position.z==k.position.z){b[c]=f;h=!0;break}}if(!h)b[c]=a.length,a.push(new THREE.Vertex(g.position.clone()))}c=0;for(e=m.faces.length;c<e;c++)g=m.faces[c],g.a=b[g.a],g.b=b[g.b],g.c=b[g.c],g.d=b[g.d];m.vertices=a})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
|
||||
THREE.CylinderGeometry=function(a,b,c,e,f,h){function g(a,b,c){j.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}THREE.Geometry.call(this);var j=this,k,l=Math.PI*2,m=e/2;for(k=0;k<a;k++)g(Math.sin(l*k/a)*b,Math.cos(l*k/a)*b,-m);for(k=0;k<a;k++)g(Math.sin(l*k/a)*c,Math.cos(l*k/a)*c,m);var n,o,p,v,t=b-c;for(k=0;k<a;k++)n=new THREE.Vector3,n.copy(j.vertices[k].position),n.z=t,n.normalize(),o=new THREE.Vector3,o.copy(j.vertices[k+a].position),o.z=t,o.normalize(),p=new THREE.Vector3,p.copy(j.vertices[a+
|
||||
(k+1)%a].position),p.z=t,p.normalize(),v=new THREE.Vector3,v.copy(j.vertices[(k+1)%a].position),v.z=t,v.normalize(),j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a,[n,o,p,v]));if(c>0){c=new THREE.Vector3(0,0,-1);g(0,0,-m-(h||0));for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a,[c,c,c,c]))}if(b>0){b=new THREE.Vector3(0,0,1);g(0,0,m+(f||0));for(k=a+a/2;k<2*a;k++)j.faces.push(new THREE.Face4(2*a+1,(2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,[b,b,b,b]))}k=
|
||||
THREE.CylinderGeometry=function(a,b,c,e,f,h){function g(a,b,c){j.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}THREE.Geometry.call(this);var j=this,k,l=Math.PI*2,m=e/2;for(k=0;k<a;k++)g(Math.sin(l*k/a)*b,Math.cos(l*k/a)*b,-m);for(k=0;k<a;k++)g(Math.sin(l*k/a)*c,Math.cos(l*k/a)*c,m);var n,o,p,v,u=b-c;for(k=0;k<a;k++)n=new THREE.Vector3,n.copy(j.vertices[k].position),n.z=u,n.normalize(),o=new THREE.Vector3,o.copy(j.vertices[k+a].position),o.z=u,o.normalize(),p=new THREE.Vector3,p.copy(j.vertices[a+
|
||||
(k+1)%a].position),p.z=u,p.normalize(),v=new THREE.Vector3,v.copy(j.vertices[(k+1)%a].position),v.z=u,v.normalize(),j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a,[n,o,p,v]));if(c>0){c=new THREE.Vector3(0,0,-1);g(0,0,-m-(h||0));for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a,[c,c,c,c]))}if(b>0){b=new THREE.Vector3(0,0,1);g(0,0,m+(f||0));for(k=a+a/2;k<2*a;k++)j.faces.push(new THREE.Face4(2*a+1,(2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,[b,b,b,b]))}k=
|
||||
0;for(a=this.faces.length;k<a;k++)f=[],m=this.faces[k],b=this.vertices[m.a],h=this.vertices[m.b],c=this.vertices[m.c],n=this.vertices[m.d],f.push(new THREE.UV(0.5+Math.atan2(b.position.x,b.position.y)/l,0.5+b.position.z/e)),f.push(new THREE.UV(0.5+Math.atan2(h.position.x,h.position.y)/l,0.5+h.position.z/e)),f.push(new THREE.UV(0.5+Math.atan2(c.position.x,c.position.y)/l,0.5+c.position.z/e)),m instanceof THREE.Face4&&f.push(new THREE.UV(0.5+Math.atan2(n.position.x,n.position.y)/l,0.5+n.position.z/
|
||||
e)),this.faceVertexUvs[0].push(f);this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;THREE.ExtrudeGeometry=function(a,b){if(typeof a!="undefined"){THREE.Geometry.call(this);var a=a instanceof Array?a:[a],c,e=a.length,f;this.shapebb=a[e-1].getBoundingBox();for(c=0;c<e;c++)f=a[c],this.addShape(f,b);this.computeCentroids();this.computeFaceNormals()}};
|
||||
THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
|
||||
THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function e(a,b,c){var e=THREE.ExtrudeGeometry.__v1,g=THREE.ExtrudeGeometry.__v2,h=THREE.ExtrudeGeometry.__v3,f=THREE.ExtrudeGeometry.__v4,j=THREE.ExtrudeGeometry.__v5,k=THREE.ExtrudeGeometry.__v6;e.set(a.x-b.x,a.y-b.y);g.set(a.x-c.x,a.y-c.y);e=e.normalize();g=g.normalize();h.set(-e.y,e.x);f.set(g.y,-g.x);j.copy(a).addSelf(h);k.copy(a).addSelf(f);if(j.equals(k))return f.clone();
|
||||
j.copy(b).addSelf(h);k.copy(c).addSelf(f);h=e.dot(f);f=k.subSelf(j).dot(f);h==0&&(console.log("Either infinite or no solutions!"),f==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));f/=h;if(f<0)return b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=Math.PI*2),anglec=(b+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(f).addSelf(j).subSelf(a).clone()}function f(a){for(z=a.length;--z>=0;){Q=z;P=z-1;P<0&&(P=a.length-
|
||||
1);for(var b=0,c=p+m*2,b=0;b<c;b++){var e=N*b,g=N*(b+1),h=T+Q+e,f=T+Q+g,l=h,e=T+P+e,g=T+P+g,n=f;l+=M;e+=M;g+=M;n+=M;G.faces.push(new THREE.Face4(l,e,g,n,null,null,A));A&&(l=b/c,e=(b+1)/c,g=j+k*2,h=(G.vertices[h].position.z+k)/g,f=(G.vertices[f].position.z+k)/g,G.faceVertexUvs[0].push([new THREE.UV(h,l),new THREE.UV(f,l),new THREE.UV(f,e),new THREE.UV(h,e)]))}}}function h(a,b,c){G.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c){a+=M;b+=M;c+=M;G.faces.push(new THREE.Face3(a,
|
||||
b,c,null,null,u));if(u){var e=B.maxY,g=B.maxX,h=G.vertices[b].position.x,b=G.vertices[b].position.y,f=G.vertices[c].position.x,c=G.vertices[c].position.y;G.faceVertexUvs[0].push([new THREE.UV(G.vertices[a].position.x/g,G.vertices[a].position.y/e),new THREE.UV(h/g,b/e),new THREE.UV(f/g,c/e)])}}var j=b.amount!==void 0?b.amount:100,k=b.bevelThickness!==void 0?b.bevelThickness:6,l=b.bevelSize!==void 0?b.bevelSize:k-2,m=b.bevelSegments!==void 0?b.bevelSegments:3,n=b.bevelEnabled!==void 0?b.bevelEnabled:
|
||||
!0,o=b.curveSegments!==void 0?b.curveSegments:12,p=b.steps!==void 0?b.steps:1,v=b.bendPath,t=b.extrudePath,w,y=!1,x=b.useSpacedPoints!==void 0?b.useSpacedPoints:!1,u=b.material,A=b.extrudeMaterial,B=this.shapebb;if(t)w=t.getPoints(o),p=w.length,y=!0,n=!1;n||(l=k=m=0);var F,E,H,G=this,M=this.vertices.length;v&&a.addWrapPath(v);o=x?a.extractAllSpacedPoints(o):a.extractAllPoints(o);v=o.shape;o=o.holes;if(t=!THREE.Shape.Utils.isClockWise(v)){v=v.reverse();E=0;for(H=o.length;E<H;E++)F=o[E],THREE.Shape.Utils.isClockWise(F)&&
|
||||
(o[E]=F.reverse());t=!1}t=THREE.Shape.Utils.triangulateShape(v,o);x=v;E=0;for(H=o.length;E<H;E++)F=o[E],v=v.concat(F);var z,C,I,K,L,J,N=v.length,D=t.length,R=[];z=0;C=x.length;Q=C-1;for(P=z+1;z<C;z++,Q++,P++)Q==C&&(Q=0),P==C&&(P=0),R[z]=e(x[z],x[Q],x[P]);var O=[],S,U=R.concat();E=0;for(H=o.length;E<H;E++){F=o[E];S=[];z=0;C=F.length;Q=C-1;for(P=z+1;z<C;z++,Q++,P++)Q==C&&(Q=0),P==C&&(P=0),S[z]=e(F[z],F[Q],F[P]);O.push(S);U=U.concat(S)}for(I=0;I<m;I++){K=I/m;L=k*(1-K);K=l*Math.sin(K*Math.PI/2);z=0;for(C=
|
||||
x.length;z<C;z++)J=c(x[z],R[z],K),h(J.x,J.y,-L);E=0;for(H=o.length;E<H;E++){F=o[E];S=O[E];z=0;for(C=F.length;z<C;z++)J=c(F[z],S[z],K),h(J.x,J.y,-L)}}K=l;for(z=0;z<N;z++)J=n?c(v[z],U[z],K):v[z],y?h(J.x,J.y+w[0].y,w[0].x):h(J.x,J.y,0);for(I=1;I<=p;I++)for(z=0;z<N;z++)J=n?c(v[z],U[z],K):v[z],y?h(J.x,J.y+w[I-1].y,w[I-1].x):h(J.x,J.y,j/p*I);for(I=m-1;I>=0;I--){K=I/m;L=k*(1-K);K=l*Math.sin(K*Math.PI/2);z=0;for(C=x.length;z<C;z++)J=c(x[z],R[z],K),h(J.x,J.y,j+L);E=0;for(H=o.length;E<H;E++){F=o[E];S=O[E];
|
||||
z=0;for(C=F.length;z<C;z++)J=c(F[z],S[z],K),y?h(J.x,J.y+w[p-1].y,w[p-1].x+L):h(J.x,J.y,j+L)}}if(n){n=N*0;for(z=0;z<D;z++)l=t[z],g(l[2]+n,l[1]+n,l[0]+n);n=N*(p+m*2);for(z=0;z<D;z++)l=t[z],g(l[0]+n,l[1]+n,l[2]+n)}else{for(z=0;z<D;z++)l=t[z],g(l[2],l[1],l[0]);for(z=0;z<D;z++)l=t[z],g(l[0]+N*p,l[1]+N*p,l[2]+N*p)}var Q,P,T=0;f(x);T+=x.length;E=0;for(H=o.length;E<H;E++)F=o[E],f(F),T+=F.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
|
||||
j.copy(b).addSelf(h);k.copy(c).addSelf(f);h=e.dot(f);f=k.subSelf(j).dot(f);h==0&&(console.log("Either infinite or no solutions!"),f==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));f/=h;if(f<0)return b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=Math.PI*2),anglec=(b+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(f).addSelf(j).subSelf(a).clone()}function f(a){for(A=a.length;--A>=0;){Q=A;P=A-1;P<0&&(P=a.length-
|
||||
1);for(var b=0,c=p+m*2,b=0;b<c;b++){var e=N*b,g=N*(b+1),h=T+Q+e,f=T+Q+g,l=h,e=T+P+e,g=T+P+g,n=f;l+=L;e+=L;g+=L;n+=L;G.faces.push(new THREE.Face4(l,e,g,n,null,null,z));z&&(l=b/c,e=(b+1)/c,g=j+k*2,h=(G.vertices[h].position.z+k)/g,f=(G.vertices[f].position.z+k)/g,G.faceVertexUvs[0].push([new THREE.UV(h,l),new THREE.UV(f,l),new THREE.UV(f,e),new THREE.UV(h,e)]))}}}function h(a,b,c){G.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c){a+=L;b+=L;c+=L;G.faces.push(new THREE.Face3(a,
|
||||
b,c,null,null,t));if(t){var e=B.maxY,g=B.maxX,h=G.vertices[b].position.x,b=G.vertices[b].position.y,f=G.vertices[c].position.x,c=G.vertices[c].position.y;G.faceVertexUvs[0].push([new THREE.UV(G.vertices[a].position.x/g,G.vertices[a].position.y/e),new THREE.UV(h/g,b/e),new THREE.UV(f/g,c/e)])}}var j=b.amount!==void 0?b.amount:100,k=b.bevelThickness!==void 0?b.bevelThickness:6,l=b.bevelSize!==void 0?b.bevelSize:k-2,m=b.bevelSegments!==void 0?b.bevelSegments:3,n=b.bevelEnabled!==void 0?b.bevelEnabled:
|
||||
!0,o=b.curveSegments!==void 0?b.curveSegments:12,p=b.steps!==void 0?b.steps:1,v=b.bendPath,u=b.extrudePath,x,y=!1,w=b.useSpacedPoints!==void 0?b.useSpacedPoints:!1,t=b.material,z=b.extrudeMaterial,B=this.shapebb;if(u)x=u.getPoints(o),p=x.length,y=!0,n=!1;n||(l=k=m=0);var F,C,H,G=this,L=this.vertices.length;v&&a.addWrapPath(v);o=w?a.extractAllSpacedPoints(o):a.extractAllPoints(o);v=o.shape;o=o.holes;if(u=!THREE.Shape.Utils.isClockWise(v)){v=v.reverse();C=0;for(H=o.length;C<H;C++)F=o[C],THREE.Shape.Utils.isClockWise(F)&&
|
||||
(o[C]=F.reverse());u=!1}u=THREE.Shape.Utils.triangulateShape(v,o);w=v;C=0;for(H=o.length;C<H;C++)F=o[C],v=v.concat(F);var A,D,I,K,M,J,N=v.length,E=u.length,R=[];A=0;D=w.length;Q=D-1;for(P=A+1;A<D;A++,Q++,P++)Q==D&&(Q=0),P==D&&(P=0),R[A]=e(w[A],w[Q],w[P]);var O=[],S,U=R.concat();C=0;for(H=o.length;C<H;C++){F=o[C];S=[];A=0;D=F.length;Q=D-1;for(P=A+1;A<D;A++,Q++,P++)Q==D&&(Q=0),P==D&&(P=0),S[A]=e(F[A],F[Q],F[P]);O.push(S);U=U.concat(S)}for(I=0;I<m;I++){K=I/m;M=k*(1-K);K=l*Math.sin(K*Math.PI/2);A=0;for(D=
|
||||
w.length;A<D;A++)J=c(w[A],R[A],K),h(J.x,J.y,-M);C=0;for(H=o.length;C<H;C++){F=o[C];S=O[C];A=0;for(D=F.length;A<D;A++)J=c(F[A],S[A],K),h(J.x,J.y,-M)}}K=l;for(A=0;A<N;A++)J=n?c(v[A],U[A],K):v[A],y?h(J.x,J.y+x[0].y,x[0].x):h(J.x,J.y,0);for(I=1;I<=p;I++)for(A=0;A<N;A++)J=n?c(v[A],U[A],K):v[A],y?h(J.x,J.y+x[I-1].y,x[I-1].x):h(J.x,J.y,j/p*I);for(I=m-1;I>=0;I--){K=I/m;M=k*(1-K);K=l*Math.sin(K*Math.PI/2);A=0;for(D=w.length;A<D;A++)J=c(w[A],R[A],K),h(J.x,J.y,j+M);C=0;for(H=o.length;C<H;C++){F=o[C];S=O[C];
|
||||
A=0;for(D=F.length;A<D;A++)J=c(F[A],S[A],K),y?h(J.x,J.y+x[p-1].y,x[p-1].x+M):h(J.x,J.y,j+M)}}if(n){n=N*0;for(A=0;A<E;A++)l=u[A],g(l[2]+n,l[1]+n,l[0]+n);n=N*(p+m*2);for(A=0;A<E;A++)l=u[A],g(l[0]+n,l[1]+n,l[2]+n)}else{for(A=0;A<E;A++)l=u[A],g(l[2],l[1],l[0]);for(A=0;A<E;A++)l=u[A],g(l[0]+N*p,l[1]+N*p,l[2]+N*p)}var Q,P,T=0;f(w);T+=w.length;C=0;for(H=o.length;C<H;C++)F=o[C],f(F),T+=F.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;
|
||||
THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
|
||||
THREE.IcosahedronGeometry=function(a){function b(a,b,c){var e=Math.sqrt(a*a+b*b+c*c);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(a/e,b/e,c/e)))-1}function c(a,b,c,e){e.faces.push(new THREE.Face3(a,b,c))}function e(a,c){var e=f.vertices[a].position,g=f.vertices[c].position;return b((e.x+g.x)/2,(e.y+g.y)/2,(e.z+g.z)/2)}var f=this,h=new THREE.Geometry;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,
|
||||
-a);b(0,1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,h);c(0,5,1,h);c(0,1,7,h);c(0,7,10,h);c(0,10,11,h);c(1,5,9,h);c(5,11,4,h);c(11,10,2,h);c(10,7,6,h);c(7,1,8,h);c(3,9,4,h);c(3,4,2,h);c(3,2,6,h);c(3,6,8,h);c(3,8,9,h);c(4,9,5,h);c(2,4,11,h);c(6,2,10,h);c(8,6,7,h);c(9,8,1,h);for(var g=0;g<this.subdivisions;g++){var a=new THREE.Geometry,j;for(j in h.faces){var k=e(h.faces[j].a,h.faces[j].b),l=e(h.faces[j].b,h.faces[j].c),m=e(h.faces[j].c,h.faces[j].a);c(h.faces[j].a,k,m,a);c(h.faces[j].b,l,
|
||||
@@ -153,18 +153,18 @@ THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;t
|
||||
for(j=0;j<e.length-1;j++)this.faces.push(new THREE.Face4(f[j],f[j+1],e[j+1],e[j])),this.faceVertexUvs[0].push([new THREE.UV(1-k/this.angle,j/a.length),new THREE.UV(1-k/this.angle,(j+1)/a.length),new THREE.UV(1-(k-b)/this.angle,(j+1)/a.length),new THREE.UV(1-(k-b)/this.angle,j/a.length)]);e=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
|
||||
THREE.PlaneGeometry=function(a,b,c,e){THREE.Geometry.call(this);var f,h=a/2,g=b/2,c=c||1,e=e||1,j=c+1,k=e+1;a/=c;var l=b/e;for(f=0;f<k;f++)for(b=0;b<j;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-h,-(f*l-g),0)));for(f=0;f<e;f++)for(b=0;b<c;b++)this.faces.push(new THREE.Face4(b+j*f,b+j*(f+1),b+1+j*(f+1),b+1+j*f)),this.faceVertexUvs[0].push([new THREE.UV(b/c,f/e),new THREE.UV(b/c,(f+1)/e),new THREE.UV((b+1)/c,(f+1)/e),new THREE.UV((b+1)/c,f/e)]);this.computeCentroids();this.computeFaceNormals()};
|
||||
THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
|
||||
THREE.SphereGeometry=function(a,b,c){THREE.Geometry.call(this);for(var a=a||50,e,f=Math.PI,h=Math.max(3,b||8),g=Math.max(2,c||6),b=[],c=0;c<g+1;c++){e=c/g;var j=a*Math.cos(e*f),k=a*Math.sin(e*f),l=[],m=0;for(e=0;e<h;e++){var n=2*e/h,o=k*Math.sin(n*f),n=k*Math.cos(n*f);(c==0||c==g)&&e>0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,o)))-1);l.push(m)}b.push(l)}for(var p,v,t,f=b.length,c=0;c<f;c++)if(h=b[c].length,c>0)for(e=0;e<h;e++){l=e==h-1;g=b[c][l?0:e+1];j=b[c][l?h-1:e];k=b[c-1][l?
|
||||
h-1:e];l=b[c-1][l?0:e+1];o=c/(f-1);p=(c-1)/(f-1);v=(e+1)/h;var n=e/h,m=new THREE.UV(1-v,o),o=new THREE.UV(1-n,o),n=new THREE.UV(1-n,p),w=new THREE.UV(1-v,p);c<b.length-1&&(p=this.vertices[g].position.clone(),v=this.vertices[j].position.clone(),t=this.vertices[k].position.clone(),p.normalize(),v.normalize(),t.normalize(),this.faces.push(new THREE.Face3(g,j,k,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(t.x,t.y,t.z)])),this.faceVertexUvs[0].push([m,o,n]));c>1&&(p=
|
||||
this.vertices[g].position.clone(),v=this.vertices[k].position.clone(),t=this.vertices[l].position.clone(),p.normalize(),v.normalize(),t.normalize(),this.faces.push(new THREE.Face3(g,k,l,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(t.x,t.y,t.z)])),this.faceVertexUvs[0].push([m,n,w]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
|
||||
THREE.SphereGeometry=function(a,b,c){THREE.Geometry.call(this);for(var a=a||50,e,f=Math.PI,h=Math.max(3,b||8),g=Math.max(2,c||6),b=[],c=0;c<g+1;c++){e=c/g;var j=a*Math.cos(e*f),k=a*Math.sin(e*f),l=[],m=0;for(e=0;e<h;e++){var n=2*e/h,o=k*Math.sin(n*f),n=k*Math.cos(n*f);(c==0||c==g)&&e>0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,o)))-1);l.push(m)}b.push(l)}for(var p,v,u,f=b.length,c=0;c<f;c++)if(h=b[c].length,c>0)for(e=0;e<h;e++){l=e==h-1;g=b[c][l?0:e+1];j=b[c][l?h-1:e];k=b[c-1][l?
|
||||
h-1:e];l=b[c-1][l?0:e+1];o=c/(f-1);p=(c-1)/(f-1);v=(e+1)/h;var n=e/h,m=new THREE.UV(1-v,o),o=new THREE.UV(1-n,o),n=new THREE.UV(1-n,p),x=new THREE.UV(1-v,p);c<b.length-1&&(p=this.vertices[g].position.clone(),v=this.vertices[j].position.clone(),u=this.vertices[k].position.clone(),p.normalize(),v.normalize(),u.normalize(),this.faces.push(new THREE.Face3(g,j,k,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(u.x,u.y,u.z)])),this.faceVertexUvs[0].push([m,o,n]));c>1&&(p=
|
||||
this.vertices[g].position.clone(),v=this.vertices[k].position.clone(),u=this.vertices[l].position.clone(),p.normalize(),v.normalize(),u.normalize(),this.faces.push(new THREE.Face3(g,k,l,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(u.x,u.y,u.z)])),this.faceVertexUvs[0].push([m,n,x]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
|
||||
THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
|
||||
THREE.TextGeometry=function(a,b){var c=(new THREE.TextPath(a,b)).toShapes();b.amount=b.height!==void 0?b.height:50;if(b.bevelThickness===void 0)b.bevelThickness=10;if(b.bevelSize===void 0)b.bevelSize=8;if(b.bevelEnabled===void 0)b.bevelEnabled=!1;if(b.bend){var e=c[c.length-1].getBoundingBox().maxX;b.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(e/2,120),new THREE.Vector2(e,0))}THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;
|
||||
THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
|
||||
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(a,b){return(new TextPath(a,b)).toShapes()},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b=
|
||||
this.getFace(),c=this.size/b.resolution,e=0,f=String(a).split(""),h=f.length,g=[],a=0;a<h;a++){var j=new THREE.Path,j=this.extractGlyphPoints(f[a],b,c,e,j);e+=j.offset;g.push(j.path)}return{paths:g,offset:e/2}},extractGlyphPoints:function(a,b,c,e,f){var h=[],g,j,k,l,m,n,o,p,v,t,w=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];if(w){if(w.o){b=w._cachedOutline||(w._cachedOutline=w.o.split(" "));k=b.length;for(a=0;a<k;)switch(j=b[a++],j){case "m":j=b[a++]*c+e;l=b[a++]*c;h.push(new THREE.Vector2(j,
|
||||
l));f.moveTo(j,l);break;case "l":j=b[a++]*c+e;l=b[a++]*c;h.push(new THREE.Vector2(j,l));f.lineTo(j,l);break;case "q":j=b[a++]*c+e;l=b[a++]*c;o=b[a++]*c+e;p=b[a++]*c;f.quadraticCurveTo(o,p,j,l);if(g=h[h.length-1]){m=g.x;n=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++){var y=g/divisions,x=THREE.Shape.Utils.b2(y,m,o,j),y=THREE.Shape.Utils.b2(y,n,p,l);h.push(new THREE.Vector2(x,y))}}break;case "b":if(j=b[a++]*c+e,l=b[a++]*c,o=b[a++]*c+e,p=b[a++]*-c,v=b[a++]*c+e,t=b[a++]*-c,f.bezierCurveTo(j,l,
|
||||
o,p,v,t),g=h[h.length-1]){m=g.x;n=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++)y=g/divisions,x=THREE.Shape.Utils.b3(y,m,o,v,j),y=THREE.Shape.Utils.b3(y,n,p,t,l),h.push(new THREE.Vector2(x,y))}}}return{offset:w.ha*c,points:h,path:f}}}};
|
||||
(function(a){var b=function(a){for(var b=a.length,f=0,h=b-1,g=0;g<b;h=g++)f+=a[h].x*a[g].y-a[g].x*a[h].y;return f*0.5};a.Triangulate=function(a,e){var f=a.length;if(f<3)return null;var h=[],g=[],j=[],k,l,m;if(b(a)>0)for(l=0;l<f;l++)g[l]=l;else for(l=0;l<f;l++)g[l]=f-1-l;var n=2*f;for(l=f-1;f>2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return j;return h}k=l;f<=k&&(k=0);l=k+1;f<=l&&(l=0);m=l+1;f<=m&&(m=0);var o;a:{o=a;var p=k,v=l,t=m,w=f,y=g,x=void 0,u=void 0,A=void 0,
|
||||
B=void 0,F=void 0,E=void 0,H=void 0,G=void 0,M=void 0,u=o[y[p]].x,A=o[y[p]].y,B=o[y[v]].x,F=o[y[v]].y,E=o[y[t]].x,H=o[y[t]].y;if(1.0E-10>(B-u)*(H-A)-(F-A)*(E-u))o=!1;else{for(x=0;x<w;x++)if(!(x==p||x==v||x==t)){var G=o[y[x]].x,M=o[y[x]].y,z=void 0,C=void 0,I=void 0,K=void 0,L=void 0,J=void 0,N=void 0,D=void 0,R=void 0,O=void 0,S=void 0,U=void 0,z=I=L=void 0,z=E-B,C=H-F,I=u-E,K=A-H,L=B-u,J=F-A,N=G-u,D=M-A,R=G-B,O=M-F,S=G-E,U=M-H,z=z*O-C*R,L=L*D-J*N,I=I*U-K*S;if(z>=0&&I>=0&&L>=0){o=!1;break a}}o=!0}}if(o){h.push([a[g[k]],
|
||||
this.getFace(),c=this.size/b.resolution,e=0,f=String(a).split(""),h=f.length,g=[],a=0;a<h;a++){var j=new THREE.Path,j=this.extractGlyphPoints(f[a],b,c,e,j);e+=j.offset;g.push(j.path)}return{paths:g,offset:e/2}},extractGlyphPoints:function(a,b,c,e,f){var h=[],g,j,k,l,m,n,o,p,v,u,x=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];if(x){if(x.o){b=x._cachedOutline||(x._cachedOutline=x.o.split(" "));k=b.length;for(a=0;a<k;)switch(j=b[a++],j){case "m":j=b[a++]*c+e;l=b[a++]*c;h.push(new THREE.Vector2(j,
|
||||
l));f.moveTo(j,l);break;case "l":j=b[a++]*c+e;l=b[a++]*c;h.push(new THREE.Vector2(j,l));f.lineTo(j,l);break;case "q":j=b[a++]*c+e;l=b[a++]*c;o=b[a++]*c+e;p=b[a++]*c;f.quadraticCurveTo(o,p,j,l);if(g=h[h.length-1]){m=g.x;n=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++){var y=g/divisions,w=THREE.Shape.Utils.b2(y,m,o,j),y=THREE.Shape.Utils.b2(y,n,p,l);h.push(new THREE.Vector2(w,y))}}break;case "b":if(j=b[a++]*c+e,l=b[a++]*c,o=b[a++]*c+e,p=b[a++]*-c,v=b[a++]*c+e,u=b[a++]*-c,f.bezierCurveTo(j,l,
|
||||
o,p,v,u),g=h[h.length-1]){m=g.x;n=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++)y=g/divisions,w=THREE.Shape.Utils.b3(y,m,o,v,j),y=THREE.Shape.Utils.b3(y,n,p,u,l),h.push(new THREE.Vector2(w,y))}}}return{offset:x.ha*c,points:h,path:f}}}};
|
||||
(function(a){var b=function(a){for(var b=a.length,f=0,h=b-1,g=0;g<b;h=g++)f+=a[h].x*a[g].y-a[g].x*a[h].y;return f*0.5};a.Triangulate=function(a,e){var f=a.length;if(f<3)return null;var h=[],g=[],j=[],k,l,m;if(b(a)>0)for(l=0;l<f;l++)g[l]=l;else for(l=0;l<f;l++)g[l]=f-1-l;var n=2*f;for(l=f-1;f>2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return j;return h}k=l;f<=k&&(k=0);l=k+1;f<=l&&(l=0);m=l+1;f<=m&&(m=0);var o;a:{o=a;var p=k,v=l,u=m,x=f,y=g,w=void 0,t=void 0,z=void 0,
|
||||
B=void 0,F=void 0,C=void 0,H=void 0,G=void 0,L=void 0,t=o[y[p]].x,z=o[y[p]].y,B=o[y[v]].x,F=o[y[v]].y,C=o[y[u]].x,H=o[y[u]].y;if(1.0E-10>(B-t)*(H-z)-(F-z)*(C-t))o=!1;else{for(w=0;w<x;w++)if(!(w==p||w==v||w==u)){var G=o[y[w]].x,L=o[y[w]].y,A=void 0,D=void 0,I=void 0,K=void 0,M=void 0,J=void 0,N=void 0,E=void 0,R=void 0,O=void 0,S=void 0,U=void 0,A=I=M=void 0,A=C-B,D=H-F,I=t-C,K=z-H,M=B-t,J=F-z,N=G-t,E=L-z,R=G-B,O=L-F,S=G-C,U=L-H,A=A*O-D*R,M=M*E-J*N,I=I*U-K*S;if(A>=0&&I>=0&&M>=0){o=!1;break a}}o=!0}}if(o){h.push([a[g[k]],
|
||||
a[g[l]],a[g[m]]]);j.push([g[k],g[l],g[m]]);k=l;for(m=l+1;m<f;k++,m++)g[k]=g[m];f--;n=2*f}}if(e)return j;return h};a.Triangulate.area=b;return a})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
|
||||
THREE.TorusGeometry=function(a,b,c,e,f){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;this.arc=f||Math.PI*2;f=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.segmentsR;c++)for(e=0;e<=this.segmentsT;e++){var h=e/this.segmentsT*this.arc,g=c/this.segmentsR*Math.PI*2;f.x=this.radius*Math.cos(h);f.y=this.radius*Math.sin(h);var j=new THREE.Vector3;j.x=(this.radius+this.tube*Math.cos(g))*Math.cos(h);j.y=(this.radius+this.tube*Math.cos(g))*Math.sin(h);j.z=
|
||||
this.tube*Math.sin(g);this.vertices.push(new THREE.Vertex(j));a.push(new THREE.UV(e/this.segmentsT,1-c/this.segmentsR));b.push(j.clone().subSelf(f).normalize())}for(c=1;c<=this.segmentsR;c++)for(e=1;e<=this.segmentsT;e++){var f=(this.segmentsT+1)*c+e-1,h=(this.segmentsT+1)*(c-1)+e-1,g=(this.segmentsT+1)*(c-1)+e,j=(this.segmentsT+1)*c+e,k=new THREE.Face4(f,h,g,j,[b[f],b[h],b[g],b[j]]);k.normal.addSelf(b[f]);k.normal.addSelf(b[h]);k.normal.addSelf(b[g]);k.normal.addSelf(b[j]);k.normal.normalize();this.faces.push(k);
|
||||
@@ -182,59 +182,59 @@ else if(a.DbgColor)g.color=a.DbgColor;if(a.colorSpecular)g.specular=h(a.colorSpe
|
||||
a.mapSpecular&&b&&f(g,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var l=THREE.ShaderUtils.lib.normal,m=THREE.UniformsUtils.clone(l.uniforms),n=g.color;j=g.specular;k=g.ambient;var o=g.shininess;m.tNormal.texture=g.normalMap;if(a.mapNormalFactor)m.uNormalScale.value=a.mapNormalFactor;if(g.map)m.tDiffuse.texture=g.map,m.enableDiffuse.value=!0;if(g.specularMap)m.tSpecular.texture=g.specularMap,m.enableSpecular.value=!0;if(g.lightMap)m.tAO.texture=
|
||||
g.lightMap,m.enableAO.value=!0;m.uDiffuseColor.value.setHex(n);m.uSpecularColor.value.setHex(j);m.uAmbientColor.value.setHex(k);m.uShininess.value=o;if(g.opacity)m.uOpacity.value=g.opacity;g=new THREE.MeshShaderMaterial({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:m,lights:!0,fog:!0})}else g=new THREE[j](g);return g},constructor:THREE.Loader};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;
|
||||
THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;THREE.JSONLoader.prototype.load=function(a){var b=this,c=a.model,e=a.callback,f=a.texture_path?a.texture_path:this.extractUrlbase(c),a=new Worker(c);a.onmessage=function(a){b.createModel(a.data,e,f);b.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
|
||||
THREE.JSONLoader.prototype.createModel=function(a,b,c){var e=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.init_materials(e,a.materials,c);(function(b){if(a.version===void 0||a.version!=2)console.error("Deprecated file format.");else{var c,f,k,l,m,n,o,p,v,t,w,y,x,u,A=a.faces;n=a.vertices;var B=a.normals,F=a.colors,E=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&E++;for(c=0;c<E;c++)e.faceUvs[c]=[],e.faceVertexUvs[c]=[];l=0;for(m=n.length;l<m;)o=new THREE.Vertex,o.position.x=n[l++]*b,o.position.y=
|
||||
n[l++]*b,o.position.z=n[l++]*b,e.vertices.push(o);l=0;for(m=A.length;l<m;){b=A[l++];n=b&1;k=b&2;c=b&4;f=b&8;p=b&16;o=b&32;t=b&64;b&=128;n?(w=new THREE.Face4,w.a=A[l++],w.b=A[l++],w.c=A[l++],w.d=A[l++],n=4):(w=new THREE.Face3,w.a=A[l++],w.b=A[l++],w.c=A[l++],n=3);if(k)k=A[l++],w.materials=e.materials[k];k=e.faces.length;if(c)for(c=0;c<E;c++)y=a.uvs[c],v=A[l++],u=y[v*2],v=y[v*2+1],e.faceUvs[c][k]=new THREE.UV(u,v);if(f)for(c=0;c<E;c++){y=a.uvs[c];x=[];for(f=0;f<n;f++)v=A[l++],u=y[v*2],v=y[v*2+1],x[f]=
|
||||
new THREE.UV(u,v);e.faceVertexUvs[c][k]=x}if(p)p=A[l++]*3,f=new THREE.Vector3,f.x=B[p++],f.y=B[p++],f.z=B[p],w.normal=f;if(o)for(c=0;c<n;c++)p=A[l++]*3,f=new THREE.Vector3,f.x=B[p++],f.y=B[p++],f.z=B[p],w.vertexNormals.push(f);if(t)o=A[l++],o=new THREE.Color(F[o]),w.color=o;if(b)for(c=0;c<n;c++)o=A[l++],o=new THREE.Color(F[o]),w.vertexColors.push(o);e.faces.push(w)}}})(f);(function(){var b,c,f,k;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b+=2)f=a.skinWeights[b],k=a.skinWeights[b+1],e.skinWeights.push(new THREE.Vector4(f,
|
||||
THREE.JSONLoader.prototype.createModel=function(a,b,c){var e=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.init_materials(e,a.materials,c);(function(b){if(a.version===void 0||a.version!=2)console.error("Deprecated file format.");else{var c,f,k,l,m,n,o,p,v,u,x,y,w,t,z=a.faces;n=a.vertices;var B=a.normals,F=a.colors,C=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&C++;for(c=0;c<C;c++)e.faceUvs[c]=[],e.faceVertexUvs[c]=[];l=0;for(m=n.length;l<m;)o=new THREE.Vertex,o.position.x=n[l++]*b,o.position.y=
|
||||
n[l++]*b,o.position.z=n[l++]*b,e.vertices.push(o);l=0;for(m=z.length;l<m;){b=z[l++];n=b&1;k=b&2;c=b&4;f=b&8;p=b&16;o=b&32;u=b&64;b&=128;n?(x=new THREE.Face4,x.a=z[l++],x.b=z[l++],x.c=z[l++],x.d=z[l++],n=4):(x=new THREE.Face3,x.a=z[l++],x.b=z[l++],x.c=z[l++],n=3);if(k)k=z[l++],x.materials=e.materials[k];k=e.faces.length;if(c)for(c=0;c<C;c++)y=a.uvs[c],v=z[l++],t=y[v*2],v=y[v*2+1],e.faceUvs[c][k]=new THREE.UV(t,v);if(f)for(c=0;c<C;c++){y=a.uvs[c];w=[];for(f=0;f<n;f++)v=z[l++],t=y[v*2],v=y[v*2+1],w[f]=
|
||||
new THREE.UV(t,v);e.faceVertexUvs[c][k]=w}if(p)p=z[l++]*3,f=new THREE.Vector3,f.x=B[p++],f.y=B[p++],f.z=B[p],x.normal=f;if(o)for(c=0;c<n;c++)p=z[l++]*3,f=new THREE.Vector3,f.x=B[p++],f.y=B[p++],f.z=B[p],x.vertexNormals.push(f);if(u)o=z[l++],o=new THREE.Color(F[o]),x.color=o;if(b)for(c=0;c<n;c++)o=z[l++],o=new THREE.Color(F[o]),x.vertexColors.push(o);e.faces.push(x)}}})(f);(function(){var b,c,f,k;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b+=2)f=a.skinWeights[b],k=a.skinWeights[b+1],e.skinWeights.push(new THREE.Vector4(f,
|
||||
k,0,0))}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b+=2)f=a.skinIndices[b],k=a.skinIndices[b+1],e.skinIndices.push(new THREE.Vector4(f,k,0,0))}e.bones=a.bones;e.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,f,k,l,m,n,o,p,v;c=0;for(f=a.morphTargets.length;c<f;c++){e.morphTargets[c]={};e.morphTargets[c].name=a.morphTargets[c].name;e.morphTargets[c].vertices=[];p=e.morphTargets[c].vertices;v=a.morphTargets[c].vertices;k=0;for(l=v.length;k<l;k+=3)m=v[k]*b,n=v[k+1]*
|
||||
b,o=v[k+2]*b,p.push(new THREE.Vertex(new THREE.Vector3(m,n,o)))}}if(a.morphColors!==void 0){c=0;for(f=a.morphColors.length;c<f;c++){e.morphColors[c]={};e.morphColors[c].name=a.morphColors[c].name;e.morphColors[c].colors=[];l=e.morphColors[c].colors;m=a.morphColors[c].colors;b=0;for(k=m.length;b<k;b+=3)n=new THREE.Color(16755200),n.setRGB(m[b],m[b+1],m[b+2]),l.push(n)}}})(f);(function(){if(a.edges!==void 0){var b,c,f;for(b=0;b<a.edges.length;b+=2)c=a.edges[b],f=a.edges[b+1],e.edges.push(new THREE.Edge(e.vertices[c],
|
||||
e.vertices[f],c,f))}})();e.computeCentroids();e.computeFaceNormals();this.hasNormals(e)&&e.computeTangents();b(e)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
|
||||
THREE.BinaryLoader.prototype={load:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b),a=(new Date).getTime(),b=new Worker(b),h=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(a){THREE.BinaryLoader.prototype.loadAjaxBuffers(a.data.buffers,a.data.materials,c,f,e,h)};b.onerror=function(a){alert("worker.onerror: "+a.message+"\n"+a.data);a.preventDefault()};
|
||||
b.postMessage(a)},loadAjaxBuffers:function(a,b,c,e,f,h){var g=new XMLHttpRequest,j=e+"/"+a,k=0;g.onreadystatechange=function(){g.readyState==4?g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,c,f,b):alert("Couldn't load ["+j+"] ["+g.status+"]"):g.readyState==3?h&&(k==0&&(k=g.getResponseHeader("Content-Length")),h({total:k,loaded:g.responseText.length})):g.readyState==2&&(k=g.getResponseHeader("Content-Length"))};g.open("GET",j,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
|
||||
g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,b,c,e){var f=function(b){function c(a,b){var e=m(a,b),f=m(a,b+1),g=m(a,b+2),h=m(a,b+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(a,b){var c=m(a,b),e=m(a,b+1),g=m(a,b+2);return(m(a,b+3)<<24)+(g<<16)+(e<<8)+c}function k(a,b){var c=m(a,b);return(m(a,b+1)<<8)+c}function l(a,b){var c=m(a,b);return c>127?c-256:c}function m(a,
|
||||
b){return a.charCodeAt(b)&255}function n(b){var c,e,g;c=f(a,b);e=f(a,b+F);g=f(a,b+E);b=k(a,b+H);THREE.BinaryLoader.prototype.f3(y,c,e,g,b)}function o(b){var c,e,g,h,l,m;c=f(a,b);e=f(a,b+F);g=f(a,b+E);h=k(a,b+H);l=f(a,b+G);m=f(a,b+M);b=f(a,b+z);THREE.BinaryLoader.prototype.f3n(y,A,c,e,g,h,l,m,b)}function p(b){var c,e,g,h;c=f(a,b);e=f(a,b+C);g=f(a,b+I);h=f(a,b+K);b=k(a,b+L);THREE.BinaryLoader.prototype.f4(y,c,e,g,h,b)}function v(b){var c,e,g,h,l,m,n,o;c=f(a,b);e=f(a,b+C);g=f(a,b+I);h=f(a,b+K);l=k(a,
|
||||
b+L);m=f(a,b+J);n=f(a,b+N);o=f(a,b+D);b=f(a,b+R);THREE.BinaryLoader.prototype.f4n(y,A,c,e,g,h,l,m,n,o,b)}function t(b){var c,e;c=f(a,b);e=f(a,b+O);b=f(a,b+S);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],B[c*2],B[c*2+1],B[e*2],B[e*2+1],B[b*2],B[b*2+1])}function w(b){var c,e,g;c=f(a,b);e=f(a,b+U);g=f(a,b+Q);b=f(a,b+P);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],B[c*2],B[c*2+1],B[e*2],B[e*2+1],B[g*2],B[g*2+1],B[b*2],B[b*2+1])}var y=this,x=0,u,A=[],B=[],F,E,H,G,M,z,C,I,K,L,J,N,D,R,O,S,
|
||||
U,Q,P,T,W,X,Y,Z,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,e,b);u={signature:a.substr(x,8),header_bytes:m(a,x+8),vertex_coordinate_bytes:m(a,x+9),normal_coordinate_bytes:m(a,x+10),uv_coordinate_bytes:m(a,x+11),vertex_index_bytes:m(a,x+12),normal_index_bytes:m(a,x+13),uv_index_bytes:m(a,x+14),material_index_bytes:m(a,x+15),nvertices:f(a,x+16),nnormals:f(a,x+16+4),nuvs:f(a,x+16+8),ntri_flat:f(a,x+16+12),ntri_smooth:f(a,x+16+16),ntri_flat_uv:f(a,x+16+20),ntri_smooth_uv:f(a,x+
|
||||
16+24),nquad_flat:f(a,x+16+28),nquad_smooth:f(a,x+16+32),nquad_flat_uv:f(a,x+16+36),nquad_smooth_uv:f(a,x+16+40)};x+=u.header_bytes;F=u.vertex_index_bytes;E=u.vertex_index_bytes*2;H=u.vertex_index_bytes*3;G=u.vertex_index_bytes*3+u.material_index_bytes;M=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes;z=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*2;C=u.vertex_index_bytes;I=u.vertex_index_bytes*2;K=u.vertex_index_bytes*3;L=u.vertex_index_bytes*4;J=u.vertex_index_bytes*
|
||||
4+u.material_index_bytes;N=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes;D=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*2;R=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*3;O=u.uv_index_bytes;S=u.uv_index_bytes*2;U=u.uv_index_bytes;Q=u.uv_index_bytes*2;P=u.uv_index_bytes*3;b=u.vertex_index_bytes*3+u.material_index_bytes;V=u.vertex_index_bytes*4+u.material_index_bytes;T=u.ntri_flat*b;W=u.ntri_smooth*(b+u.normal_index_bytes*3);X=u.ntri_flat_uv*
|
||||
(b+u.uv_index_bytes*3);Y=u.ntri_smooth_uv*(b+u.normal_index_bytes*3+u.uv_index_bytes*3);Z=u.nquad_flat*V;b=u.nquad_smooth*(V+u.normal_index_bytes*4);V=u.nquad_flat_uv*(V+u.uv_index_bytes*4);x+=function(b){for(var e,f,h,j=u.vertex_coordinate_bytes*3,k=b+u.nvertices*j;b<k;b+=j)e=c(a,b),f=c(a,b+u.vertex_coordinate_bytes),h=c(a,b+u.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(y,e,f,h);return u.nvertices*j}(x);x+=function(b){for(var c,e,f,g=u.normal_coordinate_bytes*3,h=b+u.nnormals*g;b<h;b+=
|
||||
g)c=l(a,b),e=l(a,b+u.normal_coordinate_bytes),f=l(a,b+u.normal_coordinate_bytes*2),A.push(c/127,e/127,f/127);return u.nnormals*g}(x);x+=function(b){for(var e,f,h=u.uv_coordinate_bytes*2,j=b+u.nuvs*h;b<j;b+=h)e=c(a,b),f=c(a,b+u.uv_coordinate_bytes),B.push(e,f);return u.nuvs*h}(x);T=x+T;W=T+W;X=W+X;Y=X+Y;Z=Y+Z;b=Z+b;V=b+V;(function(a){var b,c=u.vertex_index_bytes*3+u.material_index_bytes,e=c+u.uv_index_bytes*3,f=a+u.ntri_flat_uv*e;for(b=a;b<f;b+=e)n(b),t(b+c);return f-a})(W);(function(a){var b,c=u.vertex_index_bytes*
|
||||
3+u.material_index_bytes+u.normal_index_bytes*3,e=c+u.uv_index_bytes*3,f=a+u.ntri_smooth_uv*e;for(b=a;b<f;b+=e)o(b),t(b+c);return f-a})(X);(function(a){var b,c=u.vertex_index_bytes*4+u.material_index_bytes,e=c+u.uv_index_bytes*4,f=a+u.nquad_flat_uv*e;for(b=a;b<f;b+=e)p(b),w(b+c);return f-a})(b);(function(a){var b,c=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*4,e=c+u.uv_index_bytes*4,f=a+u.nquad_smooth_uv*e;for(b=a;b<f;b+=e)v(b),w(b+c);return f-a})(V);(function(a){var b,c=u.vertex_index_bytes*
|
||||
3+u.material_index_bytes,e=a+u.ntri_flat*c;for(b=a;b<e;b+=c)n(b);return e-a})(x);(function(a){var b,c=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*3,e=a+u.ntri_smooth*c;for(b=a;b<e;b+=c)o(b);return e-a})(T);(function(a){var b,c=u.vertex_index_bytes*4+u.material_index_bytes,e=a+u.nquad_flat*c;for(b=a;b<e;b+=c)p(b);return e-a})(Y);(function(a){var b,c=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*4,e=a+u.nquad_smooth*c;for(b=a;b<e;b+=c)v(b);return e-a})(Z);
|
||||
this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},f3:function(a,b,c,e,f){a.faces.push(new THREE.Face3(b,c,e,null,null,a.materials[f]))},f4:function(a,b,c,e,f,h){a.faces.push(new THREE.Face4(b,c,e,f,null,null,a.materials[h]))},f3n:function(a,b,c,e,f,h,g,j,k){var h=a.materials[h],l=b[j*
|
||||
3],m=b[j*3+1],j=b[j*3+2],n=b[k*3],o=b[k*3+1],k=b[k*3+2];a.faces.push(new THREE.Face3(c,e,f,[new THREE.Vector3(b[g*3],b[g*3+1],b[g*3+2]),new THREE.Vector3(l,m,j),new THREE.Vector3(n,o,k)],null,h))},f4n:function(a,b,c,e,f,h,g,j,k,l,m){var g=a.materials[g],n=b[k*3],o=b[k*3+1],k=b[k*3+2],p=b[l*3],v=b[l*3+1],l=b[l*3+2],t=b[m*3],w=b[m*3+1],m=b[m*3+2];a.faces.push(new THREE.Face4(c,e,f,h,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(p,v,l),new THREE.Vector3(t,w,
|
||||
m)],null,g))},uv3:function(a,b,c,e,f,h,g){var j=[];j.push(new THREE.UV(b,c));j.push(new THREE.UV(e,f));j.push(new THREE.UV(h,g));a.push(j)},uv4:function(a,b,c,e,f,h,g,j,k){var l=[];l.push(new THREE.UV(b,c));l.push(new THREE.UV(e,f));l.push(new THREE.UV(h,g));l.push(new THREE.UV(j,k));a.push(l)},constructor:THREE.BinaryLoader};
|
||||
THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
|
||||
THREE.SceneLoader.prototype={load:function(a,b){var c=this,e=new Worker(a);e.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(a){function e(a,b){return b=="relativeToHTML"?a:f+"/"+a}function j(){for(p in C.objects)if(!D.objects[p])if(x=C.objects[p],x.geometry!==void 0){if(F=D.geometries[x.geometry]){var a=!1;M=[];for(O=0;O<x.materials.length;O++)M[O]=D.materials[x.materials[O]],a=M[O]instanceof THREE.MeshShaderMaterial;a&&F.computeTangents();u=x.position;r=x.rotation;
|
||||
q=x.quaternion;s=x.scale;q=0;M.length==0&&(M[0]=new THREE.MeshFaceMaterial);M.length>1&&(M=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(F,M);object.name=p;object.position.set(u[0],u[1],u[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=x.visible;D.scene.addObject(object);D.objects[p]=object;x.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),D.scene.collisions.colliders.push(a));
|
||||
if(x.castsShadow)a=new THREE.ShadowVolume(F),D.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;x.trigger&&x.trigger.toLowerCase()!="none"&&(a={type:x.trigger,object:x},D.triggers[object.name]=a)}}else u=x.position,r=x.rotation,q=x.quaternion,s=x.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(u[0],u[1],u[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=x.visible!==void 0?x.visible:!1,D.scene.addObject(object),D.objects[p]=object,D.empties[p]=object,x.trigger&&x.trigger.toLowerCase()!="none"&&(a={type:x.trigger,object:x},D.triggers[object.name]=a)}function k(a){return function(b){D.geometries[a]=b;j();K-=1;c.onLoadComplete();m()}}function l(a){return function(b){D.geometries[a]=b}}function m(){c.callbackProgress({totalModels:J,totalTextures:N,loadedModels:J-K,loadedTextures:N-L},D);c.onLoadProgress();K==0&&L==0&&b(D)}var n,
|
||||
o,p,v,t,w,y,x,u,A,B,F,E,H,G,M,z,C,I,K,L,J,N,D;C=a.data;G=new THREE.BinaryLoader;I=new THREE.JSONLoader;L=K=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in C.objects)if(x=C.objects[p],x.meshCollider){a=!0;break}if(a)D.scene.collisions=new THREE.CollisionSystem;if(C.transform){a=C.transform.position;A=C.transform.rotation;var R=C.transform.scale;a&&D.scene.position.set(a[0],a[1],a[2]);A&&D.scene.rotation.set(A[0],
|
||||
A[1],A[2]);R&&D.scene.scale.set(R[0],R[1],R[2]);(a||A||R)&&D.scene.updateMatrix()}a=function(){L-=1;m();c.onLoadComplete()};for(t in C.cameras){A=C.cameras[t];if(A.type=="perspective")E=new THREE.Camera(A.fov,A.aspect,A.near,A.far);else if(A.type=="ortho")E=new THREE.Camera,E.projectionMatrix=THREE.Matrix4.makeOrtho(A.left,A.right,A.top,A.bottom,A.near,A.far);u=A.position;A=A.target;E.position.set(u[0],u[1],u[2]);E.target.position.set(A[0],A[1],A[2]);D.cameras[t]=E}for(v in C.lights)t=C.lights[v],
|
||||
E=t.color!==void 0?t.color:16777215,A=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(u=t.direction,z=new THREE.DirectionalLight(E,A),z.position.set(u[0],u[1],u[2]),z.position.normalize()):t.type=="point"?(u=t.position,d=t.distance,z=new THREE.PointLight(E,A,d),z.position.set(u[0],u[1],u[2])):t.type=="ambient"&&(z=new THREE.AmbientLight(E)),D.scene.addLight(z),D.lights[v]=z;for(w in C.fogs)v=C.fogs[w],v.type=="linear"?H=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(H=new THREE.FogExp2(0,
|
||||
v.density)),A=v.color,H.color.setRGB(A[0],A[1],A[2]),D.fogs[w]=H;if(D.cameras&&C.defaults.camera)D.currentCamera=D.cameras[C.defaults.camera];if(D.fogs&&C.defaults.fog)D.scene.fog=D.fogs[C.defaults.fog];A=C.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(A[0],A[1],A[2]);D.bgColorAlpha=C.defaults.bgalpha;for(n in C.geometries)if(w=C.geometries[n],w.type=="bin_mesh"||w.type=="ascii_mesh")K+=1,c.onLoadStart();J=K;for(n in C.geometries)w=C.geometries[n],w.type=="cube"?(F=new THREE.CubeGeometry(w.width,
|
||||
w.height,w.depth,w.segmentsWidth,w.segmentsHeight,w.segmentsDepth,null,w.flipped,w.sides),D.geometries[n]=F):w.type=="plane"?(F=new THREE.PlaneGeometry(w.width,w.height,w.segmentsWidth,w.segmentsHeight),D.geometries[n]=F):w.type=="sphere"?(F=new THREE.SphereGeometry(w.radius,w.segmentsWidth,w.segmentsHeight),D.geometries[n]=F):w.type=="cylinder"?(F=new THREE.CylinderGeometry(w.numSegs,w.topRad,w.botRad,w.height,w.topOffset,w.botOffset),D.geometries[n]=F):w.type=="torus"?(F=new THREE.TorusGeometry(w.radius,
|
||||
w.tube,w.segmentsR,w.segmentsT),D.geometries[n]=F):w.type=="icosahedron"?(F=new THREE.IcosahedronGeometry(w.subdivisions),D.geometries[n]=F):w.type=="bin_mesh"?G.load({model:e(w.url,C.urlBaseType),callback:k(n)}):w.type=="ascii_mesh"?I.load({model:e(w.url,C.urlBaseType),callback:k(n)}):w.type=="embedded_mesh"&&(w=C.embeds[w.id])&&I.createModel(w,l(n),"");for(y in C.textures)if(n=C.textures[y],n.url instanceof Array){L+=n.url.length;for(G=0;G<n.url.length;G++)c.onLoadStart()}else L+=1,c.onLoadStart();
|
||||
N=L;for(y in C.textures){n=C.textures[y];if(n.mapping!=void 0&&THREE[n.mapping]!=void 0)n.mapping=new THREE[n.mapping];if(n.url instanceof Array){G=[];for(var O=0;O<n.url.length;O++)G[O]=e(n.url[O],C.urlBaseType);G=THREE.ImageUtils.loadTextureCube(G,n.mapping,a)}else{G=THREE.ImageUtils.loadTexture(e(n.url,C.urlBaseType),n.mapping,a);if(THREE[n.minFilter]!=void 0)G.minFilter=THREE[n.minFilter];if(THREE[n.magFilter]!=void 0)G.magFilter=THREE[n.magFilter];if(n.repeat){G.repeat.set(n.repeat[0],n.repeat[1]);
|
||||
if(n.repeat[0]!=1)G.wrapS=THREE.RepeatWrapping;if(n.repeat[1]!=1)G.wrapT=THREE.RepeatWrapping}n.offset&&G.offset.set(n.offset[0],n.offset[1]);if(n.wrap){I={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(I[n.wrap[0]]!==void 0)G.wrapS=I[n.wrap[0]];if(I[n.wrap[1]]!==void 0)G.wrapT=I[n.wrap[1]]}}D.textures[y]=G}for(o in C.materials){y=C.materials[o];for(B in y.parameters)if(B=="envMap"||B=="map"||B=="lightMap")y.parameters[B]=D.textures[y.parameters[B]];else if(B=="shading")y.parameters[B]=
|
||||
THREE.BinaryLoader.prototype.load=function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b),a=(new Date).getTime(),b=new Worker(b),h=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(a){THREE.BinaryLoader.prototype.loadAjaxBuffers(a.data.buffers,a.data.materials,c,f,e,h)};b.onerror=function(a){alert("worker.onerror: "+a.message+"\n"+a.data);a.preventDefault()};
|
||||
b.postMessage(a)};
|
||||
THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,e,f,h){var g=new XMLHttpRequest,j=e+"/"+a,k=0;g.onreadystatechange=function(){g.readyState==4?g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,c,f,b):alert("Couldn't load ["+j+"] ["+g.status+"]"):g.readyState==3?h&&(k==0&&(k=g.getResponseHeader("Content-Length")),h({total:k,loaded:g.responseText.length})):g.readyState==2&&(k=g.getResponseHeader("Content-Length"))};g.open("GET",j,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
|
||||
g.setRequestHeader("Content-Type","text/plain");g.send(null)};
|
||||
THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,e){var f=function(b){function c(a,b){var e=m(a,b),f=m(a,b+1),g=m(a,b+2),h=m(a,b+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(a,b){var c=m(a,b),e=m(a,b+1),g=m(a,b+2);return(m(a,b+3)<<24)+(g<<16)+(e<<8)+c}function k(a,b){var c=m(a,b);return(m(a,b+1)<<8)+c}function l(a,b){var c=m(a,b);return c>127?c-256:c}function m(a,b){return a.charCodeAt(b)&255}function n(b){var c,
|
||||
e,g;c=f(a,b);e=f(a,b+F);g=f(a,b+C);b=k(a,b+H);y.faces.push(new THREE.Face3(c,e,g,null,null,y.materials[b]))}function o(b){var c,e,g,h,l,m;c=f(a,b);e=f(a,b+F);g=f(a,b+C);h=k(a,b+H);l=f(a,b+G);m=f(a,b+L);b=f(a,b+A);h=y.materials[h];var n=z[m*3],o=z[m*3+1];m=z[m*3+2];var p=z[b*3],u=z[b*3+1],b=z[b*3+2];y.faces.push(new THREE.Face3(c,e,g,[new THREE.Vector3(z[l*3],z[l*3+1],z[l*3+2]),new THREE.Vector3(n,o,m),new THREE.Vector3(p,u,b)],null,h))}function p(b){var c,e,g,h;c=f(a,b);e=f(a,b+D);g=f(a,b+I);h=f(a,
|
||||
b+K);b=k(a,b+M);y.faces.push(new THREE.Face4(c,e,g,h,null,null,y.materials[b]))}function v(b){var c,e,g,h,l,m,n,o;c=f(a,b);e=f(a,b+D);g=f(a,b+I);h=f(a,b+K);l=k(a,b+M);m=f(a,b+J);n=f(a,b+N);o=f(a,b+E);b=f(a,b+R);l=y.materials[l];var p=z[n*3],u=z[n*3+1];n=z[n*3+2];var x=z[o*3],v=z[o*3+1];o=z[o*3+2];var t=z[b*3],w=z[b*3+1],b=z[b*3+2];y.faces.push(new THREE.Face4(c,e,g,h,[new THREE.Vector3(z[m*3],z[m*3+1],z[m*3+2]),new THREE.Vector3(p,u,n),new THREE.Vector3(x,v,o),new THREE.Vector3(t,w,b)],null,l))}function u(b){var c,
|
||||
e,g,h;c=f(a,b);e=f(a,b+O);g=f(a,b+S);b=B[c*2];h=B[c*2+1];c=B[e*2];var k=y.faceVertexUvs[0];e=B[e*2+1];var l=B[g*2];g=B[g*2+1];var m=[];m.push(new THREE.UV(b,h));m.push(new THREE.UV(c,e));m.push(new THREE.UV(l,g));k.push(m)}function x(b){var c,e,g,h,k,l;c=f(a,b);e=f(a,b+U);g=f(a,b+Q);h=f(a,b+P);b=B[c*2];k=B[c*2+1];c=B[e*2];l=B[e*2+1];e=B[g*2];var m=y.faceVertexUvs[0];g=B[g*2+1];var n=B[h*2];h=B[h*2+1];var o=[];o.push(new THREE.UV(b,k));o.push(new THREE.UV(c,l));o.push(new THREE.UV(e,g));o.push(new THREE.UV(n,
|
||||
h));m.push(o)}var y=this,w=0,t,z=[],B=[],F,C,H,G,L,A,D,I,K,M,J,N,E,R,O,S,U,Q,P,T,W,X,Y,Z,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,e,b);t={signature:a.substr(w,8),header_bytes:m(a,w+8),vertex_coordinate_bytes:m(a,w+9),normal_coordinate_bytes:m(a,w+10),uv_coordinate_bytes:m(a,w+11),vertex_index_bytes:m(a,w+12),normal_index_bytes:m(a,w+13),uv_index_bytes:m(a,w+14),material_index_bytes:m(a,w+15),nvertices:f(a,w+16),nnormals:f(a,w+16+4),nuvs:f(a,w+16+8),ntri_flat:f(a,w+16+12),
|
||||
ntri_smooth:f(a,w+16+16),ntri_flat_uv:f(a,w+16+20),ntri_smooth_uv:f(a,w+16+24),nquad_flat:f(a,w+16+28),nquad_smooth:f(a,w+16+32),nquad_flat_uv:f(a,w+16+36),nquad_smooth_uv:f(a,w+16+40)};w+=t.header_bytes;F=t.vertex_index_bytes;C=t.vertex_index_bytes*2;H=t.vertex_index_bytes*3;G=t.vertex_index_bytes*3+t.material_index_bytes;L=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;A=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;D=t.vertex_index_bytes;I=t.vertex_index_bytes*
|
||||
2;K=t.vertex_index_bytes*3;M=t.vertex_index_bytes*4;J=t.vertex_index_bytes*4+t.material_index_bytes;N=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;E=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;R=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;O=t.uv_index_bytes;S=t.uv_index_bytes*2;U=t.uv_index_bytes;Q=t.uv_index_bytes*2;P=t.uv_index_bytes*3;b=t.vertex_index_bytes*3+t.material_index_bytes;V=t.vertex_index_bytes*4+t.material_index_bytes;
|
||||
T=t.ntri_flat*b;W=t.ntri_smooth*(b+t.normal_index_bytes*3);X=t.ntri_flat_uv*(b+t.uv_index_bytes*3);Y=t.ntri_smooth_uv*(b+t.normal_index_bytes*3+t.uv_index_bytes*3);Z=t.nquad_flat*V;b=t.nquad_smooth*(V+t.normal_index_bytes*4);V=t.nquad_flat_uv*(V+t.uv_index_bytes*4);w+=function(b){for(var e,f,h,j=t.vertex_coordinate_bytes*3,k=b+t.nvertices*j;b<k;b+=j)e=c(a,b),f=c(a,b+t.vertex_coordinate_bytes),h=c(a,b+t.vertex_coordinate_bytes*2),y.vertices.push(new THREE.Vertex(new THREE.Vector3(e,f,h)));return t.nvertices*
|
||||
j}(w);w+=function(b){for(var c,e,f,g=t.normal_coordinate_bytes*3,h=b+t.nnormals*g;b<h;b+=g)c=l(a,b),e=l(a,b+t.normal_coordinate_bytes),f=l(a,b+t.normal_coordinate_bytes*2),z.push(c/127,e/127,f/127);return t.nnormals*g}(w);w+=function(b){for(var e,f,h=t.uv_coordinate_bytes*2,j=b+t.nuvs*h;b<j;b+=h)e=c(a,b),f=c(a,b+t.uv_coordinate_bytes),B.push(e,f);return t.nuvs*h}(w);T=w+T;W=T+W;X=W+X;Y=X+Y;Z=Y+Z;b=Z+b;V=b+V;(function(a){var b,c=t.vertex_index_bytes*3+t.material_index_bytes,e=c+t.uv_index_bytes*3,
|
||||
f=a+t.ntri_flat_uv*e;for(b=a;b<f;b+=e)n(b),u(b+c);return f-a})(W);(function(a){var b,c=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,e=c+t.uv_index_bytes*3,f=a+t.ntri_smooth_uv*e;for(b=a;b<f;b+=e)o(b),u(b+c);return f-a})(X);(function(a){var b,c=t.vertex_index_bytes*4+t.material_index_bytes,e=c+t.uv_index_bytes*4,f=a+t.nquad_flat_uv*e;for(b=a;b<f;b+=e)p(b),x(b+c);return f-a})(b);(function(a){var b,c=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,e=c+t.uv_index_bytes*
|
||||
4,f=a+t.nquad_smooth_uv*e;for(b=a;b<f;b+=e)v(b),x(b+c);return f-a})(V);(function(a){var b,c=t.vertex_index_bytes*3+t.material_index_bytes,e=a+t.ntri_flat*c;for(b=a;b<e;b+=c)n(b);return e-a})(w);(function(a){var b,c=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,e=a+t.ntri_smooth*c;for(b=a;b<e;b+=c)o(b);return e-a})(T);(function(a){var b,c=t.vertex_index_bytes*4+t.material_index_bytes,e=a+t.nquad_flat*c;for(b=a;b<e;b+=c)p(b);return e-a})(Y);(function(a){var b,c=t.vertex_index_bytes*
|
||||
4+t.material_index_bytes+t.normal_index_bytes*4,e=a+t.nquad_smooth*c;for(b=a;b<e;b+=c)v(b);return e-a})(Z);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
|
||||
THREE.SceneLoader.prototype={load:function(a,b){var c=this,e=new Worker(a);e.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(a){function e(a,b){return b=="relativeToHTML"?a:f+"/"+a}function j(){for(p in D.objects)if(!E.objects[p])if(w=D.objects[p],w.geometry!==void 0){if(F=E.geometries[w.geometry]){var a=!1;L=[];for(O=0;O<w.materials.length;O++)L[O]=E.materials[w.materials[O]],a=L[O]instanceof THREE.MeshShaderMaterial;a&&F.computeTangents();t=w.position;r=w.rotation;
|
||||
q=w.quaternion;s=w.scale;q=0;L.length==0&&(L[0]=new THREE.MeshFaceMaterial);L.length>1&&(L=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(F,L);object.name=p;object.position.set(t[0],t[1],t[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=w.visible;E.scene.addObject(object);E.objects[p]=object;w.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),E.scene.collisions.colliders.push(a));
|
||||
if(w.castsShadow)a=new THREE.ShadowVolume(F),E.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;w.trigger&&w.trigger.toLowerCase()!="none"&&(a={type:w.trigger,object:w},E.triggers[object.name]=a)}}else t=w.position,r=w.rotation,q=w.quaternion,s=w.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(t[0],t[1],t[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=w.visible!==void 0?w.visible:!1,E.scene.addObject(object),E.objects[p]=object,E.empties[p]=object,w.trigger&&w.trigger.toLowerCase()!="none"&&(a={type:w.trigger,object:w},E.triggers[object.name]=a)}function k(a){return function(b){E.geometries[a]=b;j();K-=1;c.onLoadComplete();m()}}function l(a){return function(b){E.geometries[a]=b}}function m(){c.callbackProgress({totalModels:J,totalTextures:N,loadedModels:J-K,loadedTextures:N-M},E);c.onLoadProgress();K==0&&M==0&&b(E)}var n,
|
||||
o,p,v,u,x,y,w,t,z,B,F,C,H,G,L,A,D,I,K,M,J,N,E;D=a.data;G=new THREE.BinaryLoader;I=new THREE.JSONLoader;M=K=0;E={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in D.objects)if(w=D.objects[p],w.meshCollider){a=!0;break}if(a)E.scene.collisions=new THREE.CollisionSystem;if(D.transform){a=D.transform.position;z=D.transform.rotation;var R=D.transform.scale;a&&E.scene.position.set(a[0],a[1],a[2]);z&&E.scene.rotation.set(z[0],
|
||||
z[1],z[2]);R&&E.scene.scale.set(R[0],R[1],R[2]);(a||z||R)&&E.scene.updateMatrix()}a=function(){M-=1;m();c.onLoadComplete()};for(u in D.cameras){z=D.cameras[u];if(z.type=="perspective")C=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho")C=new THREE.Camera,C.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far);t=z.position;z=z.target;C.position.set(t[0],t[1],t[2]);C.target.position.set(z[0],z[1],z[2]);E.cameras[u]=C}for(v in D.lights)u=D.lights[v],
|
||||
C=u.color!==void 0?u.color:16777215,z=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(t=u.direction,A=new THREE.DirectionalLight(C,z),A.position.set(t[0],t[1],t[2]),A.position.normalize()):u.type=="point"?(t=u.position,d=u.distance,A=new THREE.PointLight(C,z,d),A.position.set(t[0],t[1],t[2])):u.type=="ambient"&&(A=new THREE.AmbientLight(C)),E.scene.addLight(A),E.lights[v]=A;for(x in D.fogs)v=D.fogs[x],v.type=="linear"?H=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(H=new THREE.FogExp2(0,
|
||||
v.density)),z=v.color,H.color.setRGB(z[0],z[1],z[2]),E.fogs[x]=H;if(E.cameras&&D.defaults.camera)E.currentCamera=E.cameras[D.defaults.camera];if(E.fogs&&D.defaults.fog)E.scene.fog=E.fogs[D.defaults.fog];z=D.defaults.bgcolor;E.bgColor=new THREE.Color;E.bgColor.setRGB(z[0],z[1],z[2]);E.bgColorAlpha=D.defaults.bgalpha;for(n in D.geometries)if(x=D.geometries[n],x.type=="bin_mesh"||x.type=="ascii_mesh")K+=1,c.onLoadStart();J=K;for(n in D.geometries)x=D.geometries[n],x.type=="cube"?(F=new THREE.CubeGeometry(x.width,
|
||||
x.height,x.depth,x.segmentsWidth,x.segmentsHeight,x.segmentsDepth,null,x.flipped,x.sides),E.geometries[n]=F):x.type=="plane"?(F=new THREE.PlaneGeometry(x.width,x.height,x.segmentsWidth,x.segmentsHeight),E.geometries[n]=F):x.type=="sphere"?(F=new THREE.SphereGeometry(x.radius,x.segmentsWidth,x.segmentsHeight),E.geometries[n]=F):x.type=="cylinder"?(F=new THREE.CylinderGeometry(x.numSegs,x.topRad,x.botRad,x.height,x.topOffset,x.botOffset),E.geometries[n]=F):x.type=="torus"?(F=new THREE.TorusGeometry(x.radius,
|
||||
x.tube,x.segmentsR,x.segmentsT),E.geometries[n]=F):x.type=="icosahedron"?(F=new THREE.IcosahedronGeometry(x.subdivisions),E.geometries[n]=F):x.type=="bin_mesh"?G.load({model:e(x.url,D.urlBaseType),callback:k(n)}):x.type=="ascii_mesh"?I.load({model:e(x.url,D.urlBaseType),callback:k(n)}):x.type=="embedded_mesh"&&(x=D.embeds[x.id])&&I.createModel(x,l(n),"");for(y in D.textures)if(n=D.textures[y],n.url instanceof Array){M+=n.url.length;for(G=0;G<n.url.length;G++)c.onLoadStart()}else M+=1,c.onLoadStart();
|
||||
N=M;for(y in D.textures){n=D.textures[y];if(n.mapping!=void 0&&THREE[n.mapping]!=void 0)n.mapping=new THREE[n.mapping];if(n.url instanceof Array){G=[];for(var O=0;O<n.url.length;O++)G[O]=e(n.url[O],D.urlBaseType);G=THREE.ImageUtils.loadTextureCube(G,n.mapping,a)}else{G=THREE.ImageUtils.loadTexture(e(n.url,D.urlBaseType),n.mapping,a);if(THREE[n.minFilter]!=void 0)G.minFilter=THREE[n.minFilter];if(THREE[n.magFilter]!=void 0)G.magFilter=THREE[n.magFilter];if(n.repeat){G.repeat.set(n.repeat[0],n.repeat[1]);
|
||||
if(n.repeat[0]!=1)G.wrapS=THREE.RepeatWrapping;if(n.repeat[1]!=1)G.wrapT=THREE.RepeatWrapping}n.offset&&G.offset.set(n.offset[0],n.offset[1]);if(n.wrap){I={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(I[n.wrap[0]]!==void 0)G.wrapS=I[n.wrap[0]];if(I[n.wrap[1]]!==void 0)G.wrapT=I[n.wrap[1]]}}E.textures[y]=G}for(o in D.materials){y=D.materials[o];for(B in y.parameters)if(B=="envMap"||B=="map"||B=="lightMap")y.parameters[B]=E.textures[y.parameters[B]];else if(B=="shading")y.parameters[B]=
|
||||
y.parameters[B]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(B=="blending")y.parameters[B]=THREE[y.parameters[B]]?THREE[y.parameters[B]]:THREE.NormalBlending;else if(B=="combine")y.parameters[B]=y.parameters[B]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(B=="vertexColors")if(y.parameters[B]=="face")y.parameters[B]=THREE.FaceColors;else if(y.parameters[B])y.parameters[B]=THREE.VertexColors;if(y.parameters.opacity!==void 0&&y.parameters.opacity<1)y.parameters.transparent=
|
||||
!0;if(y.parameters.normalMap){n=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(n.uniforms);G=y.parameters.color;I=y.parameters.specular;w=y.parameters.ambient;H=y.parameters.shininess;a.tNormal.texture=D.textures[y.parameters.normalMap];if(y.parameters.normalMapFactor)a.uNormalScale.value=y.parameters.normalMapFactor;if(y.parameters.map)a.tDiffuse.texture=y.parameters.map,a.enableDiffuse.value=!0;if(y.parameters.lightMap)a.tAO.texture=y.parameters.lightMap,a.enableAO.value=!0;if(y.parameters.specularMap)a.tSpecular.texture=
|
||||
D.textures[y.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(G);a.uSpecularColor.value.setHex(I);a.uAmbientColor.value.setHex(w);a.uShininess.value=H;if(y.parameters.opacity)a.uOpacity.value=y.parameters.opacity;y=new THREE.MeshShaderMaterial({fragmentShader:n.fragmentShader,vertexShader:n.vertexShader,uniforms:a,lights:!0,fog:!0})}else y=new THREE[y.type](y.parameters);D.materials[o]=y}j();c.callbackSync(D)}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};
|
||||
!0;if(y.parameters.normalMap){n=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(n.uniforms);G=y.parameters.color;I=y.parameters.specular;x=y.parameters.ambient;H=y.parameters.shininess;a.tNormal.texture=E.textures[y.parameters.normalMap];if(y.parameters.normalMapFactor)a.uNormalScale.value=y.parameters.normalMapFactor;if(y.parameters.map)a.tDiffuse.texture=y.parameters.map,a.enableDiffuse.value=!0;if(y.parameters.lightMap)a.tAO.texture=y.parameters.lightMap,a.enableAO.value=!0;if(y.parameters.specularMap)a.tSpecular.texture=
|
||||
E.textures[y.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(G);a.uSpecularColor.value.setHex(I);a.uAmbientColor.value.setHex(x);a.uShininess.value=H;if(y.parameters.opacity)a.uOpacity.value=y.parameters.opacity;y=new THREE.MeshShaderMaterial({fragmentShader:n.fragmentShader,vertexShader:n.vertexShader,uniforms:a,lights:!0,fog:!0})}else y=new THREE[y.type](y.parameters);E.materials[o]=y}j();c.callbackSync(E)}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};
|
||||
THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
|
||||
THREE.UTF8Loader.prototype={load:function(a){var b=new XMLHttpRequest,c=a.model,e=a.callback,f=a.scale!==void 0?a.scale:1,h=a.offsetX!==void 0?a.offsetX:0,g=a.offsetY!==void 0?a.offsetY:0,j=a.offsetZ!==void 0?a.offsetZ:0;b.onreadystatechange=function(){b.readyState==4?b.status==200||b.status==0?THREE.UTF8Loader.prototype.createModel(b.responseText,e,f,h,g,j):alert("Couldn't load ["+c+"] ["+b.status+"]"):b.readyState!=3&&b.readyState==2&&b.getResponseHeader("Content-Length")};b.open("GET",c,!0);b.send(null)},
|
||||
decompressMesh:function(a){var b=a.charCodeAt(0);b>=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),e=1,f=0;f<8;f++){for(var h=0,g=0;g<b;++g){var j=a.charCodeAt(g+e);h+=j>>1^-(j&1);c[8*g+f]=h}e+=b}b=a.length-e;h=new Uint16Array(b);for(f=g=0;f<b;f++)j=a.charCodeAt(f+e),h[f]=g-j,j==0&&g++;return[c,h]},createModel:function(a,b,c,e,f,h){var g=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var g=THREE.UTF8Loader.prototype.decompressMesh(a),l=[],m=[];(function(a,g,k){for(var l,m,w,
|
||||
y=a.length;k<y;k+=g)l=a[k],m=a[k+1],w=a[k+2],l=l/16383*c,m=m/16383*c,w=w/16383*c,l+=e,m+=f,w+=h,THREE.UTF8Loader.prototype.v(b,l,m,w)})(g[0],8,0);(function(a,b,c){for(var e,f,g=a.length;c<g;c+=b)e=a[c],f=a[c+1],e/=1023,f/=1023,m.push(e,f)})(g[0],8,3);(function(a,b,c){for(var e,f,g,h=a.length;c<h;c+=b)e=a[c],f=a[c+1],g=a[c+2],e=(e-512)/511,f=(f-512)/511,g=(g-512)/511,l.push(e,f,g)})(g[0],8,5);(function(a){var c,e,f,g,h,k,x,u=a.length;for(c=0;c<u;c+=3)e=a[c],f=a[c+1],g=a[c+2],THREE.UTF8Loader.prototype.f3n(b,
|
||||
l,e,f,g,0,e,f,g),h=m[e*2],e=m[e*2+1],k=m[f*2],f=m[f*2+1],x=m[g*2],g=m[g*2+1],THREE.UTF8Loader.prototype.uv3(b.faceVertexUvs[0],h,e,k,f,x,g)})(g[1]);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g)},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},f3n:function(a,b,c,e,f,h,g,j,k){var h=a.materials[h],l=b[j*3],m=b[j*3+1],j=b[j*3+2],n=b[k*3],o=b[k*3+1],k=b[k*3+2],g=new THREE.Vector3(b[g*3],b[g*3+1],b[g*
|
||||
3+2]),j=new THREE.Vector3(l,m,j),k=new THREE.Vector3(n,o,k);a.faces.push(new THREE.Face3(c,e,f,[g,j,k],null,h))},uv3:function(a,b,c,e,f,h,g){var j=[];j.push(new THREE.UV(b,c));j.push(new THREE.UV(e,f));j.push(new THREE.UV(h,g));a.push(j)},constructor:THREE.UTF8Loader};
|
||||
THREE.UTF8Loader.prototype.load=function(a){var b=new XMLHttpRequest,c=a.model,e=a.callback,f=a.scale!==void 0?a.scale:1,h=a.offsetX!==void 0?a.offsetX:0,g=a.offsetY!==void 0?a.offsetY:0,j=a.offsetZ!==void 0?a.offsetZ:0;b.onreadystatechange=function(){b.readyState==4?b.status==200||b.status==0?THREE.UTF8Loader.prototype.createModel(b.responseText,e,f,h,g,j):alert("Couldn't load ["+c+"] ["+b.status+"]"):b.readyState!=3&&b.readyState==2&&b.getResponseHeader("Content-Length")};b.open("GET",c,!0);b.send(null)};
|
||||
THREE.UTF8Loader.prototype.decompressMesh=function(a){var b=a.charCodeAt(0);b>=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),e=1,f=0;f<8;f++){for(var h=0,g=0;g<b;++g){var j=a.charCodeAt(g+e);h+=j>>1^-(j&1);c[8*g+f]=h}e+=b}b=a.length-e;h=new Uint16Array(b);for(f=g=0;f<b;f++)j=a.charCodeAt(f+e),h[f]=g-j,j==0&&g++;return[c,h]};
|
||||
THREE.UTF8Loader.prototype.createModel=function(a,b,c,e,f,h){var g=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var g=THREE.UTF8Loader.prototype.decompressMesh(a),l=[],m=[];(function(a,g,k){for(var l,m,x,y=a.length;k<y;k+=g)l=a[k],m=a[k+1],x=a[k+2],l=l/16383*c,m=m/16383*c,x=x/16383*c,l+=e,m+=f,x+=h,b.vertices.push(new THREE.Vertex(new THREE.Vector3(l,m,x)))})(g[0],8,0);(function(a,b,c){for(var e,f,g=a.length;c<g;c+=b)e=a[c],f=a[c+1],e/=1023,f/=1023,m.push(e,f)})(g[0],8,3);(function(a,
|
||||
b,c){for(var e,f,g,h=a.length;c<h;c+=b)e=a[c],f=a[c+1],g=a[c+2],e=(e-512)/511,f=(f-512)/511,g=(g-512)/511,l.push(e,f,g)})(g[0],8,5);(function(a){var c,e,f,g,h,k,w,t,z,B=a.length;for(c=0;c<B;c+=3){e=a[c];f=a[c+1];g=a[c+2];h=b;t=e;z=f;k=g;w=e;var F=f,C=g,H=h.materials[0],G=l[F*3],L=l[F*3+1],F=l[F*3+2],A=l[C*3],D=l[C*3+1],C=l[C*3+2];w=new THREE.Vector3(l[w*3],l[w*3+1],l[w*3+2]);F=new THREE.Vector3(G,L,F);C=new THREE.Vector3(A,D,C);h.faces.push(new THREE.Face3(t,z,k,[w,F,C],null,H));h=m[e*2];e=m[e*2+
|
||||
1];k=m[f*2];w=m[f*2+1];t=m[g*2];z=m[g*2+1];g=b.faceVertexUvs[0];f=k;k=w;w=[];w.push(new THREE.UV(h,e));w.push(new THREE.UV(f,k));w.push(new THREE.UV(t,z));g.push(w)}})(g[1]);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g)};
|
||||
THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(a){this.isolation=80;this.size=a;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(a,b,f){return a+(b-a)*f};this.VIntX=function(a,b,f,h,g,j,k,l,m,n){g=(g-m)/(n-m);m=this.normal_cache;b[h]=j+g*this.delta;b[h+1]=k;b[h+2]=l;f[h]=this.lerp(m[a],m[a+3],g);f[h+1]=this.lerp(m[a+1],m[a+4],g);f[h+2]=this.lerp(m[a+2],m[a+5],g)};this.VIntY=function(a,b,f,h,g,j,k,l,m,n){g=(g-m)/(n-m);m=this.normal_cache;b[h]=j;b[h+1]=k+g*this.delta;b[h+
|
||||
2]=l;b=a+this.yd*3;f[h]=this.lerp(m[a],m[b],g);f[h+1]=this.lerp(m[a+1],m[b+1],g);f[h+2]=this.lerp(m[a+2],m[b+2],g)};this.VIntZ=function(a,b,f,h,g,j,k,l,m,n){g=(g-m)/(n-m);m=this.normal_cache;b[h]=j;b[h+1]=k;b[h+2]=l+g*this.delta;b=a+this.zd*3;f[h]=this.lerp(m[a],m[b],g);f[h+1]=this.lerp(m[a+1],m[b+1],g);f[h+2]=this.lerp(m[a+2],m[b+2],g)};this.compNorm=function(a){var b=a*3;this.normal_cache[b]==0&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+
|
||||
this.yd],this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,f,h,g,j){var k=h+1,l=h+this.yd,m=h+this.zd,n=k+this.yd,o=k+this.zd,p=h+this.yd+this.zd,v=k+this.yd+this.zd,t=0,w=this.field[h],y=this.field[k],x=this.field[l],u=this.field[n],A=this.field[m],B=this.field[o],F=this.field[p],E=this.field[v];w<g&&(t|=1);y<g&&(t|=2);x<g&&(t|=8);u<g&&(t|=4);A<g&&(t|=16);B<g&&(t|=32);F<g&&(t|=128);E<g&&(t|=64);var H=THREE.edgeTable[t];if(H==0)return 0;var G=this.delta,
|
||||
M=a+G,z=b+G,G=f+G;H&1&&(this.compNorm(h),this.compNorm(k),this.VIntX(h*3,this.vlist,this.nlist,0,g,a,b,f,w,y));H&2&&(this.compNorm(k),this.compNorm(n),this.VIntY(k*3,this.vlist,this.nlist,3,g,M,b,f,y,u));H&4&&(this.compNorm(l),this.compNorm(n),this.VIntX(l*3,this.vlist,this.nlist,6,g,a,z,f,x,u));H&8&&(this.compNorm(h),this.compNorm(l),this.VIntY(h*3,this.vlist,this.nlist,9,g,a,b,f,w,x));H&16&&(this.compNorm(m),this.compNorm(o),this.VIntX(m*3,this.vlist,this.nlist,12,g,a,b,G,A,B));H&32&&(this.compNorm(o),
|
||||
this.compNorm(v),this.VIntY(o*3,this.vlist,this.nlist,15,g,M,b,G,B,E));H&64&&(this.compNorm(p),this.compNorm(v),this.VIntX(p*3,this.vlist,this.nlist,18,g,a,z,G,F,E));H&128&&(this.compNorm(m),this.compNorm(p),this.VIntY(m*3,this.vlist,this.nlist,21,g,a,b,G,A,F));H&256&&(this.compNorm(h),this.compNorm(m),this.VIntZ(h*3,this.vlist,this.nlist,24,g,a,b,f,w,A));H&512&&(this.compNorm(k),this.compNorm(o),this.VIntZ(k*3,this.vlist,this.nlist,27,g,M,b,f,y,B));H&1024&&(this.compNorm(n),this.compNorm(v),this.VIntZ(n*
|
||||
3,this.vlist,this.nlist,30,g,M,z,f,u,E));H&2048&&(this.compNorm(l),this.compNorm(p),this.VIntZ(l*3,this.vlist,this.nlist,33,g,a,z,f,x,F));t<<=4;for(g=h=0;THREE.triTable[t+g]!=-1;)a=t+g,b=a+1,f=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[f],j),g+=3,h++;return h};this.posnormtriv=function(a,b,f,h,g,j){var k=this.count*3;this.positionArray[k]=a[f];this.positionArray[k+1]=a[f+1];this.positionArray[k+2]=a[f+2];this.positionArray[k+3]=a[h];this.positionArray[k+
|
||||
this.yd],this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,f,h,g,j){var k=h+1,l=h+this.yd,m=h+this.zd,n=k+this.yd,o=k+this.zd,p=h+this.yd+this.zd,v=k+this.yd+this.zd,u=0,x=this.field[h],y=this.field[k],w=this.field[l],t=this.field[n],z=this.field[m],B=this.field[o],F=this.field[p],C=this.field[v];x<g&&(u|=1);y<g&&(u|=2);w<g&&(u|=8);t<g&&(u|=4);z<g&&(u|=16);B<g&&(u|=32);F<g&&(u|=128);C<g&&(u|=64);var H=THREE.edgeTable[u];if(H==0)return 0;var G=this.delta,
|
||||
L=a+G,A=b+G,G=f+G;H&1&&(this.compNorm(h),this.compNorm(k),this.VIntX(h*3,this.vlist,this.nlist,0,g,a,b,f,x,y));H&2&&(this.compNorm(k),this.compNorm(n),this.VIntY(k*3,this.vlist,this.nlist,3,g,L,b,f,y,t));H&4&&(this.compNorm(l),this.compNorm(n),this.VIntX(l*3,this.vlist,this.nlist,6,g,a,A,f,w,t));H&8&&(this.compNorm(h),this.compNorm(l),this.VIntY(h*3,this.vlist,this.nlist,9,g,a,b,f,x,w));H&16&&(this.compNorm(m),this.compNorm(o),this.VIntX(m*3,this.vlist,this.nlist,12,g,a,b,G,z,B));H&32&&(this.compNorm(o),
|
||||
this.compNorm(v),this.VIntY(o*3,this.vlist,this.nlist,15,g,L,b,G,B,C));H&64&&(this.compNorm(p),this.compNorm(v),this.VIntX(p*3,this.vlist,this.nlist,18,g,a,A,G,F,C));H&128&&(this.compNorm(m),this.compNorm(p),this.VIntY(m*3,this.vlist,this.nlist,21,g,a,b,G,z,F));H&256&&(this.compNorm(h),this.compNorm(m),this.VIntZ(h*3,this.vlist,this.nlist,24,g,a,b,f,x,z));H&512&&(this.compNorm(k),this.compNorm(o),this.VIntZ(k*3,this.vlist,this.nlist,27,g,L,b,f,y,B));H&1024&&(this.compNorm(n),this.compNorm(v),this.VIntZ(n*
|
||||
3,this.vlist,this.nlist,30,g,L,A,f,t,C));H&2048&&(this.compNorm(l),this.compNorm(p),this.VIntZ(l*3,this.vlist,this.nlist,33,g,a,A,f,w,F));u<<=4;for(g=h=0;THREE.triTable[u+g]!=-1;)a=u+g,b=a+1,f=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[f],j),g+=3,h++;return h};this.posnormtriv=function(a,b,f,h,g,j){var k=this.count*3;this.positionArray[k]=a[f];this.positionArray[k+1]=a[f+1];this.positionArray[k+2]=a[f+2];this.positionArray[k+3]=a[h];this.positionArray[k+
|
||||
4]=a[h+1];this.positionArray[k+5]=a[h+2];this.positionArray[k+6]=a[g];this.positionArray[k+7]=a[g+1];this.positionArray[k+8]=a[g+2];this.normalArray[k]=b[f];this.normalArray[k+1]=b[f+1];this.normalArray[k+2]=b[f+2];this.normalArray[k+3]=b[h];this.normalArray[k+4]=b[h+1];this.normalArray[k+5]=b[h+2];this.normalArray[k+6]=b[g];this.normalArray[k+7]=b[g+1];this.normalArray[k+8]=b[g+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=function(){this.count=0;
|
||||
this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,f,h,g){var j=this.size*Math.sqrt(h/g),k=f*this.size,l=b*this.size,m=a*this.size,n=Math.floor(k-j);n<1&&(n=1);k=Math.floor(k+j);k>this.size-1&&(k=this.size-1);var o=Math.floor(l-j);o<1&&(o=1);l=Math.floor(l+j);l>this.size-1&&(l=this.size-1);var p=Math.floor(m-j);p<1&&(p=1);j=Math.floor(m+j);j>this.size-1&&(j=this.size-
|
||||
1);for(var v,t,w,y,x,u;n<k;n++){m=this.size2*n;t=n/this.size-f;x=t*t;for(t=o;t<l;t++){w=m+this.size*t;v=t/this.size-b;u=v*v;for(v=p;v<j;v++)y=v/this.size-a,y=h/(1.0E-6+y*y+u+x)-g,y>0&&(this.field[w+v]+=y)}}};this.addPlaneX=function(a,b){var f,h,g,j,k,l=this.size,m=this.yd,n=this.zd,o=this.field,p=l*Math.sqrt(a/b);p>l&&(p=l);for(f=0;f<p;f++)if(h=f/l,h*=h,j=a/(1.0E-4+h)-b,j>0)for(h=0;h<l;h++){k=f+h*m;for(g=0;g<l;g++)o[n*g+k]+=j}};this.addPlaneY=function(a,b){var f,h,g,j,k,l,m=this.size,n=this.yd,o=
|
||||
1);for(var v,u,x,y,w,t;n<k;n++){m=this.size2*n;u=n/this.size-f;w=u*u;for(u=o;u<l;u++){x=m+this.size*u;v=u/this.size-b;t=v*v;for(v=p;v<j;v++)y=v/this.size-a,y=h/(1.0E-6+y*y+t+w)-g,y>0&&(this.field[x+v]+=y)}}};this.addPlaneX=function(a,b){var f,h,g,j,k,l=this.size,m=this.yd,n=this.zd,o=this.field,p=l*Math.sqrt(a/b);p>l&&(p=l);for(f=0;f<p;f++)if(h=f/l,h*=h,j=a/(1.0E-4+h)-b,j>0)for(h=0;h<l;h++){k=f+h*m;for(g=0;g<l;g++)o[n*g+k]+=j}};this.addPlaneY=function(a,b){var f,h,g,j,k,l,m=this.size,n=this.yd,o=
|
||||
this.zd,p=this.field,v=m*Math.sqrt(a/b);v>m&&(v=m);for(h=0;h<v;h++)if(f=h/m,f*=f,j=a/(1.0E-4+f)-b,j>0){k=h*n;for(f=0;f<m;f++){l=k+f;for(g=0;g<m;g++)p[o*g+l]+=j}}};this.addPlaneZ=function(a,b){var f,h,g,j,k,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(a/b);dist>size&&(dist=size);for(g=0;g<dist;g++)if(f=g/size,f*=f,j=a/(1.0E-4+f)-b,j>0){k=zd*g;for(h=0;h<size;h++){l=k+h*yd;for(f=0;f<size;f++)field[l+f]+=j}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*
|
||||
3]=0,this.field[a]=0};this.render=function(a){this.begin();var b,f,h,g,j,k,l,m,n,o=this.size-2;for(g=1;g<o;g++){n=this.size2*g;l=(g-this.halfsize)/this.halfsize;for(h=1;h<o;h++){m=n+this.size*h;k=(h-this.halfsize)/this.halfsize;for(f=1;f<o;f++)j=(f-this.halfsize)/this.halfsize,b=m+f,this.polygonize(j,k,l,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,f=[];this.render(function(h){var g,j,k,l,m,n,o,p;for(g=0;g<h.count;g++)o=g*3,m=o+1,p=o+2,j=h.positionArray[o],
|
||||
k=h.positionArray[m],l=h.positionArray[p],n=new THREE.Vector3(j,k,l),j=h.normalArray[o],k=h.normalArray[m],l=h.normalArray[p],o=new THREE.Vector3(j,k,l),o.normalize(),m=new THREE.Vertex(n),b.vertices.push(m),f.push(o);nfaces=h.count/3;for(g=0;g<nfaces;g++)o=(a+g)*3,m=o+1,p=o+2,n=f[o],j=f[m],k=f[p],o=new THREE.Face3(o,m,p,[n,j,k]),b.faces.push(o);a+=nfaces;h.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
|
||||
@@ -282,7 +282,7 @@ THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionU
|
||||
THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))};
|
||||
if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var b=this,c=this.setSize,e=this.render,f=new THREE.Camera,h=new THREE.Camera,g=new THREE.Matrix4,j=new THREE.Matrix4,k,l,m;f.useTarget=h.useTarget=!1;f.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},n=new THREE.WebGLRenderTarget(512,512,a),o=new THREE.WebGLRenderTarget(512,512,a),p=new THREE.Camera(53,1,1,1E4);p.position.z=
|
||||
2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:n},mapRight:{type:"t",value:1,texture:o}},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 v=new THREE.Scene;v.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){c.call(b,a,e);n.width=a;n.height=e;o.width=a;o.height=e};this.render=function(a,c){c.update(null,!0);if(k!==c.aspect||l!==c.near||m!==c.fov){k=c.aspect;l=c.near;m=c.fov;var y=c.projectionMatrix.clone(),x=125/30*0.5,u=x*l/125,A=l*Math.tan(m*Math.PI/360),B;g.n14=x;j.n14=-x;x=-A*k+u;B=A*k+u;y.n11=2*l/(B-x);y.n13=(B+x)/(B-x);f.projectionMatrix=y.clone();x=-A*k-u;B=A*k-u;y.n11=2*l/(B-x);
|
||||
y.n13=(B+x)/(B-x);h.projectionMatrix=y.clone()}f.matrix=c.matrixWorld.clone().multiplySelf(j);f.update(null,!0);f.position.copy(c.position);f.near=l;f.far=c.far;e.call(b,a,f,n,!0);h.matrix=c.matrixWorld.clone().multiplySelf(g);h.update(null,!0);h.position.copy(c.position);h.near=l;h.far=c.far;e.call(b,a,h,o,!0);e.call(b,v,p)}};
|
||||
var v=new THREE.Scene;v.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){c.call(b,a,e);n.width=a;n.height=e;o.width=a;o.height=e};this.render=function(a,c){c.update(null,!0);if(k!==c.aspect||l!==c.near||m!==c.fov){k=c.aspect;l=c.near;m=c.fov;var y=c.projectionMatrix.clone(),w=125/30*0.5,t=w*l/125,z=l*Math.tan(m*Math.PI/360),B;g.n14=w;j.n14=-w;w=-z*k+t;B=z*k+t;y.n11=2*l/(B-w);y.n13=(B+w)/(B-w);f.projectionMatrix=y.clone();w=-z*k-t;B=z*k-t;y.n11=2*l/(B-w);
|
||||
y.n13=(B+w)/(B-w);h.projectionMatrix=y.clone()}f.matrix=c.matrixWorld.clone().multiplySelf(j);f.update(null,!0);f.position.copy(c.position);f.near=l;f.far=c.far;e.call(b,a,f,n,!0);h.matrix=c.matrixWorld.clone().multiplySelf(g);h.update(null,!0);h.position.copy(c.position);h.near=l;h.far=c.far;e.call(b,a,h,o,!0);e.call(b,v,p)}};
|
||||
if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,e=this.render,f,h,g=new THREE.Camera,j=new THREE.Camera;b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,e){c.call(b,a,e);f=a/2;h=e};this.render=function(a,c){this.clear();g.fov=c.fov;g.aspect=0.5*c.aspect;g.near=c.near;g.far=c.far;
|
||||
g.updateProjectionMatrix();g.position.copy(c.position);g.target.position.copy(c.target.position);g.translateX(b.separation);j.projectionMatrix=g.projectionMatrix;j.position.copy(c.position);j.target.position.copy(c.target.position);j.translateX(-b.separation);this.setViewport(0,0,f,h);e.call(b,a,g);this.setViewport(f,0,f,h);e.call(b,a,j,!1)}};
|
||||
|
||||
+564
-568
File diff suppressed because it is too large
Load Diff
+1942
-792
File diff suppressed because it is too large
Load Diff
@@ -405,4 +405,4 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
|
||||
|
||||
callback( geometry );
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ THREE.Loader.prototype = {
|
||||
|
||||
},
|
||||
|
||||
extractUrlbase: function( url ) {
|
||||
extractUrlbase: function ( url ) {
|
||||
|
||||
var chunks = url.split( "/" );
|
||||
chunks.pop();
|
||||
@@ -63,11 +63,11 @@ THREE.Loader.prototype = {
|
||||
|
||||
},
|
||||
|
||||
init_materials: function( scope, materials, texture_path ) {
|
||||
init_materials: function ( scope, materials, texture_path ) {
|
||||
|
||||
scope.materials = [];
|
||||
|
||||
for ( var i = 0; i < materials.length; ++i ) {
|
||||
for ( var i = 0; i < materials.length; ++ i ) {
|
||||
|
||||
scope.materials[ i ] = [ THREE.Loader.prototype.createMaterial( materials[ i ], texture_path ) ];
|
||||
|
||||
@@ -75,7 +75,7 @@ THREE.Loader.prototype = {
|
||||
|
||||
},
|
||||
|
||||
hasNormals: function( scope ) {
|
||||
hasNormals: function ( scope ) {
|
||||
|
||||
var m, i, il = scope.materials.length;
|
||||
|
||||
@@ -136,7 +136,7 @@ THREE.Loader.prototype = {
|
||||
|
||||
}
|
||||
|
||||
function create_texture( where, name, sourceFile, repeat, offset, wrap ) {
|
||||
function create_texture ( where, name, sourceFile, repeat, offset, wrap ) {
|
||||
|
||||
var texture = document.createElement( 'canvas' );
|
||||
|
||||
@@ -174,7 +174,7 @@ THREE.Loader.prototype = {
|
||||
|
||||
}
|
||||
|
||||
function rgb2hex( rgb ) {
|
||||
function rgb2hex ( rgb ) {
|
||||
|
||||
return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255;
|
||||
|
||||
@@ -367,7 +367,7 @@ THREE.Loader.prototype = {
|
||||
return material;
|
||||
|
||||
},
|
||||
|
||||
|
||||
constructor : THREE.Loader
|
||||
|
||||
};
|
||||
|
||||
+234
-240
@@ -21,297 +21,287 @@ THREE.UTF8Loader.prototype = new THREE.UTF8Loader();
|
||||
THREE.UTF8Loader.prototype.constructor = THREE.UTF8Loader;
|
||||
|
||||
|
||||
THREE.UTF8Loader.prototype = {
|
||||
// Load UTF8 compressed models generated by objcompress
|
||||
// - parameters
|
||||
// - model (required)
|
||||
// - callback (required)
|
||||
|
||||
// Load UTF8 compressed models generated by objcompress
|
||||
// - parameters
|
||||
// - model (required)
|
||||
// - callback (required)
|
||||
THREE.UTF8Loader.prototype.load = function( parameters ) {
|
||||
|
||||
load: function( parameters ) {
|
||||
var xhr = new XMLHttpRequest(),
|
||||
url = parameters.model,
|
||||
|
||||
var xhr = new XMLHttpRequest(),
|
||||
url = parameters.model,
|
||||
callback = parameters.callback,
|
||||
callback_progress = null,
|
||||
|
||||
callback = parameters.callback,
|
||||
callback_progress = null,
|
||||
scale = parameters.scale !== undefined ? parameters.scale : 1,
|
||||
offsetX = parameters.offsetX !== undefined ? parameters.offsetX : 0,
|
||||
offsetY = parameters.offsetY !== undefined ? parameters.offsetY : 0,
|
||||
offsetZ = parameters.offsetZ !== undefined ? parameters.offsetZ : 0;
|
||||
|
||||
scale = parameters.scale !== undefined ? parameters.scale : 1,
|
||||
offsetX = parameters.offsetX !== undefined ? parameters.offsetX : 0,
|
||||
offsetY = parameters.offsetY !== undefined ? parameters.offsetY : 0,
|
||||
offsetZ = parameters.offsetZ !== undefined ? parameters.offsetZ : 0;
|
||||
var length = 0;
|
||||
|
||||
var length = 0;
|
||||
xhr.onreadystatechange = function() {
|
||||
|
||||
xhr.onreadystatechange = function() {
|
||||
if ( xhr.readyState == 4 ) {
|
||||
|
||||
if ( xhr.readyState == 4 ) {
|
||||
if ( xhr.status == 200 || xhr.status == 0 ) {
|
||||
|
||||
if ( xhr.status == 200 || xhr.status == 0 ) {
|
||||
THREE.UTF8Loader.prototype.createModel( xhr.responseText, callback, scale, offsetX, offsetY, offsetZ );
|
||||
|
||||
THREE.UTF8Loader.prototype.createModel( xhr.responseText, callback, scale, offsetX, offsetY, offsetZ );
|
||||
} else {
|
||||
|
||||
} else {
|
||||
|
||||
alert( "Couldn't load [" + url + "] [" + xhr.status + "]" );
|
||||
|
||||
}
|
||||
|
||||
} else if ( xhr.readyState == 3 ) {
|
||||
|
||||
if ( callback_progress ) {
|
||||
|
||||
if ( length == 0 ) {
|
||||
|
||||
length = xhr.getResponseHeader( "Content-Length" );
|
||||
|
||||
}
|
||||
|
||||
callback_progress( { total: length, loaded: xhr.responseText.length } );
|
||||
|
||||
}
|
||||
|
||||
} else if ( xhr.readyState == 2 ) {
|
||||
|
||||
length = xhr.getResponseHeader( "Content-Length" );
|
||||
alert( "Couldn't load [" + url + "] [" + xhr.status + "]" );
|
||||
|
||||
}
|
||||
|
||||
} else if ( xhr.readyState == 3 ) {
|
||||
|
||||
if ( callback_progress ) {
|
||||
|
||||
if ( length == 0 ) {
|
||||
|
||||
length = xhr.getResponseHeader( "Content-Length" );
|
||||
|
||||
}
|
||||
|
||||
callback_progress( { total: length, loaded: xhr.responseText.length } );
|
||||
|
||||
}
|
||||
|
||||
} else if ( xhr.readyState == 2 ) {
|
||||
|
||||
length = xhr.getResponseHeader( "Content-Length" );
|
||||
|
||||
}
|
||||
|
||||
xhr.open( "GET", url, true );
|
||||
xhr.send( null );
|
||||
}
|
||||
|
||||
},
|
||||
xhr.open( "GET", url, true );
|
||||
xhr.send( null );
|
||||
|
||||
// UTF-8 decoder from webgl-loader
|
||||
// http://code.google.com/p/webgl-loader/
|
||||
};
|
||||
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you
|
||||
// may not use this file except in compliance with the License. You
|
||||
// may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License.
|
||||
// UTF-8 decoder from webgl-loader
|
||||
// http://code.google.com/p/webgl-loader/
|
||||
|
||||
decompressMesh: function ( str ) {
|
||||
// Copyright 2011 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you
|
||||
// may not use this file except in compliance with the License. You
|
||||
// may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
// implied. See the License for the specific language governing
|
||||
// permissions and limitations under the License.
|
||||
|
||||
var num_verts = str.charCodeAt( 0 );
|
||||
THREE.UTF8Loader.prototype.decompressMesh = function ( str ) {
|
||||
|
||||
if ( num_verts >= 0xE000 ) {
|
||||
var num_verts = str.charCodeAt( 0 );
|
||||
|
||||
num_verts -= 0x0800;
|
||||
if ( num_verts >= 0xE000 ) {
|
||||
|
||||
num_verts -= 0x0800;
|
||||
|
||||
}
|
||||
|
||||
num_verts ++;
|
||||
|
||||
var attribs_out = new Float32Array( 8 * num_verts );
|
||||
|
||||
var offset = 1;
|
||||
|
||||
for ( var i = 0; i < 8; i ++ ) {
|
||||
|
||||
var prev_attrib = 0;
|
||||
|
||||
for ( var j = 0; j < num_verts; ++ j ) {
|
||||
|
||||
var code = str.charCodeAt( j + offset );
|
||||
|
||||
prev_attrib += ( code >> 1 ) ^ ( - ( code & 1 ) );
|
||||
|
||||
attribs_out[ 8 * j + i ] = prev_attrib;
|
||||
|
||||
}
|
||||
|
||||
num_verts ++;
|
||||
offset += num_verts;
|
||||
|
||||
var attribs_out = new Float32Array( 8 * num_verts );
|
||||
}
|
||||
|
||||
var offset = 1;
|
||||
var num_indices = str.length - offset;
|
||||
|
||||
for ( var i = 0; i < 8; i ++ ) {
|
||||
var indices_out = new Uint16Array( num_indices );
|
||||
|
||||
var prev_attrib = 0;
|
||||
var index_high_water_mark = 0;
|
||||
|
||||
for ( var j = 0; j < num_verts; ++ j ) {
|
||||
for ( var i = 0; i < num_indices; i ++ ) {
|
||||
|
||||
var code = str.charCodeAt( j + offset );
|
||||
var code = str.charCodeAt( i + offset );
|
||||
|
||||
prev_attrib += ( code >> 1 ) ^ ( - ( code & 1 ) );
|
||||
indices_out[ i ] = index_high_water_mark - code;
|
||||
|
||||
attribs_out[ 8 * j + i ] = prev_attrib;
|
||||
if ( code == 0 ) {
|
||||
|
||||
}
|
||||
|
||||
offset += num_verts;
|
||||
index_high_water_mark ++;
|
||||
|
||||
}
|
||||
|
||||
var num_indices = str.length - offset;
|
||||
}
|
||||
|
||||
var indices_out = new Uint16Array( num_indices );
|
||||
return [ attribs_out, indices_out ];
|
||||
|
||||
var index_high_water_mark = 0;
|
||||
};
|
||||
|
||||
for ( var i = 0; i < num_indices; i ++ ) {
|
||||
THREE.UTF8Loader.prototype.createModel = function ( data, callback, scale, offsetX, offsetY, offsetZ ) {
|
||||
|
||||
var code = str.charCodeAt( i + offset );
|
||||
var Model = function ( texture_path ) {
|
||||
|
||||
indices_out[ i ] = index_high_water_mark - code;
|
||||
//var s = (new Date).getTime();
|
||||
|
||||
if ( code == 0 ) {
|
||||
var scope = this;
|
||||
|
||||
index_high_water_mark ++;
|
||||
scope.materials = [];
|
||||
|
||||
THREE.Geometry.call( this );
|
||||
|
||||
var buffers = THREE.UTF8Loader.prototype.decompressMesh( data );
|
||||
|
||||
var normals = [],
|
||||
uvs = [];
|
||||
|
||||
init_vertices( buffers[ 0 ], 8, 0 );
|
||||
init_uvs( buffers[ 0 ], 8, 3 );
|
||||
init_normals( buffers[ 0 ], 8, 5 );
|
||||
|
||||
init_faces( buffers[ 1 ] );
|
||||
|
||||
this.computeCentroids();
|
||||
this.computeFaceNormals();
|
||||
//this.computeTangents();
|
||||
|
||||
//var e = (new Date).getTime();
|
||||
|
||||
//console.log( "utf8 data parse time: " + (e-s) + " ms" );
|
||||
|
||||
function init_vertices( data, stride, offset ) {
|
||||
|
||||
var i, x, y, z,
|
||||
end = data.length;
|
||||
|
||||
for( i = offset; i < end; i += stride ) {
|
||||
|
||||
x = data[ i ];
|
||||
y = data[ i + 1 ];
|
||||
z = data[ i + 2 ];
|
||||
|
||||
// fix scale and offsets
|
||||
|
||||
x = ( x / 16383 ) * scale;
|
||||
y = ( y / 16383 ) * scale;
|
||||
z = ( z / 16383 ) * scale;
|
||||
|
||||
x += offsetX;
|
||||
y += offsetY;
|
||||
z += offsetZ;
|
||||
|
||||
vertex( scope, x, y, z );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function init_normals( data, stride, offset ) {
|
||||
|
||||
var i, x, y, z,
|
||||
end = data.length;
|
||||
|
||||
for( i = offset; i < end; i += stride ) {
|
||||
|
||||
x = data[ i ];
|
||||
y = data[ i + 1 ];
|
||||
z = data[ i + 2 ];
|
||||
|
||||
// normalize to <-1,1>
|
||||
|
||||
x = ( x - 512 ) / 511;
|
||||
y = ( y - 512 ) / 511;
|
||||
z = ( z - 512 ) / 511;
|
||||
|
||||
normals.push( x, y, z );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function init_uvs( data, stride, offset ) {
|
||||
|
||||
var i, u, v,
|
||||
end = data.length;
|
||||
|
||||
for( i = offset; i < end; i += stride ) {
|
||||
|
||||
u = data[ i ];
|
||||
v = data[ i + 1 ];
|
||||
|
||||
// normalize to <0,1>
|
||||
|
||||
u /= 1023;
|
||||
v /= 1023;
|
||||
|
||||
uvs.push( u, v );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function init_faces( indices ) {
|
||||
|
||||
var i,
|
||||
a, b, c,
|
||||
u1, v1, u2, v2, u3, v3,
|
||||
m,
|
||||
end = indices.length;
|
||||
|
||||
m = 0; // all faces defaulting to material 0
|
||||
|
||||
for( i = 0; i < end; i += 3 ) {
|
||||
|
||||
a = indices[ i ];
|
||||
b = indices[ i + 1 ];
|
||||
c = indices[ i + 2 ];
|
||||
|
||||
f3n( scope, normals, a, b, c, m, a, b, c );
|
||||
|
||||
u1 = uvs[ a * 2 ];
|
||||
v1 = uvs[ a * 2 + 1 ];
|
||||
|
||||
u2 = uvs[ b * 2 ];
|
||||
v2 = uvs[ b * 2 + 1 ];
|
||||
|
||||
u3 = uvs[ c * 2 ];
|
||||
v3 = uvs[ c * 2 + 1 ];
|
||||
|
||||
uv3( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return [ attribs_out, indices_out ];
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
createModel: function ( data, callback, scale, offsetX, offsetY, offsetZ ) {
|
||||
|
||||
var Model = function ( texture_path ) {
|
||||
|
||||
//var s = (new Date).getTime();
|
||||
|
||||
var scope = this;
|
||||
|
||||
scope.materials = [];
|
||||
|
||||
THREE.Geometry.call( this );
|
||||
|
||||
var buffers = THREE.UTF8Loader.prototype.decompressMesh( data );
|
||||
|
||||
var normals = [],
|
||||
uvs = [];
|
||||
|
||||
init_vertices( buffers[ 0 ], 8, 0 );
|
||||
init_uvs( buffers[ 0 ], 8, 3 );
|
||||
init_normals( buffers[ 0 ], 8, 5 );
|
||||
|
||||
init_faces( buffers[ 1 ] );
|
||||
|
||||
this.computeCentroids();
|
||||
this.computeFaceNormals();
|
||||
//this.computeTangents();
|
||||
|
||||
//var e = (new Date).getTime();
|
||||
|
||||
//console.log( "utf8 data parse time: " + (e-s) + " ms" );
|
||||
|
||||
function init_vertices( data, stride, offset ) {
|
||||
|
||||
var i, x, y, z,
|
||||
end = data.length;
|
||||
|
||||
for( i = offset; i < end; i += stride ) {
|
||||
|
||||
x = data[ i ];
|
||||
y = data[ i + 1 ];
|
||||
z = data[ i + 2 ];
|
||||
|
||||
// fix scale and offsets
|
||||
|
||||
x = ( x / 16383 ) * scale;
|
||||
y = ( y / 16383 ) * scale;
|
||||
z = ( z / 16383 ) * scale;
|
||||
|
||||
x += offsetX;
|
||||
y += offsetY;
|
||||
z += offsetZ;
|
||||
|
||||
THREE.UTF8Loader.prototype.v( scope, x, y, z );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function init_normals( data, stride, offset ) {
|
||||
|
||||
var i, x, y, z,
|
||||
end = data.length;
|
||||
|
||||
for( i = offset; i < end; i += stride ) {
|
||||
|
||||
x = data[ i ];
|
||||
y = data[ i + 1 ];
|
||||
z = data[ i + 2 ];
|
||||
|
||||
// normalize to <-1,1>
|
||||
|
||||
x = ( x - 512 ) / 511;
|
||||
y = ( y - 512 ) / 511;
|
||||
z = ( z - 512 ) / 511;
|
||||
|
||||
normals.push( x, y, z );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function init_uvs( data, stride, offset ) {
|
||||
|
||||
var i, u, v,
|
||||
end = data.length;
|
||||
|
||||
for( i = offset; i < end; i += stride ) {
|
||||
|
||||
u = data[ i ];
|
||||
v = data[ i + 1 ];
|
||||
|
||||
// normalize to <0,1>
|
||||
|
||||
u /= 1023;
|
||||
v /= 1023;
|
||||
|
||||
uvs.push( u, v );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function init_faces( indices ) {
|
||||
|
||||
var i,
|
||||
a, b, c,
|
||||
u1, v1, u2, v2, u3, v3,
|
||||
m,
|
||||
end = indices.length;
|
||||
|
||||
m = 0; // all faces defaulting to material 0
|
||||
|
||||
for( i = 0; i < end; i += 3 ) {
|
||||
|
||||
a = indices[ i ];
|
||||
b = indices[ i + 1 ];
|
||||
c = indices[ i + 2 ];
|
||||
|
||||
THREE.UTF8Loader.prototype.f3n( scope, normals, a, b, c, m, a, b, c );
|
||||
|
||||
u1 = uvs[ a * 2 ];
|
||||
v1 = uvs[ a * 2 + 1 ];
|
||||
|
||||
u2 = uvs[ b * 2 ];
|
||||
v2 = uvs[ b * 2 + 1 ];
|
||||
|
||||
u3 = uvs[ c * 2 ];
|
||||
v3 = uvs[ c * 2 + 1 ];
|
||||
|
||||
THREE.UTF8Loader.prototype.uv3( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Model.prototype = new THREE.Geometry();
|
||||
Model.prototype.constructor = Model;
|
||||
|
||||
callback( new Model() );
|
||||
|
||||
},
|
||||
|
||||
|
||||
v: function( scope, x, y, z ) {
|
||||
function vertex ( scope, x, y, z ) {
|
||||
|
||||
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
f3n: function( scope, normals, a, b, c, mi, na, nb, nc ) {
|
||||
function f3n ( scope, normals, a, b, c, mi, na, nb, nc ) {
|
||||
|
||||
var material = scope.materials[ mi ],
|
||||
|
||||
@@ -333,9 +323,9 @@ THREE.UTF8Loader.prototype = {
|
||||
|
||||
scope.faces.push( new THREE.Face3( a, b, c, [ na, nb, nc ], null, material ) );
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
uv3: function( where, u1, v1, u2, v2, u3, v3 ) {
|
||||
function uv3 ( where, u1, v1, u2, v2, u3, v3 ) {
|
||||
|
||||
var uv = [];
|
||||
uv.push( new THREE.UV( u1, v1 ) );
|
||||
@@ -343,8 +333,12 @@ THREE.UTF8Loader.prototype = {
|
||||
uv.push( new THREE.UV( u3, v3 ) );
|
||||
where.push( uv );
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
constructor : THREE.UTF8Loader
|
||||
|
||||
Model.prototype = new THREE.Geometry();
|
||||
Model.prototype.constructor = Model;
|
||||
|
||||
callback( new Model() );
|
||||
|
||||
};
|
||||
|
||||
@@ -290,7 +290,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
||||
|
||||
};
|
||||
|
||||
this.getContext = function() {
|
||||
this.getContext = function () {
|
||||
|
||||
return _gl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user