提交 befc98a0 编写于 作者: A alteredq

Refactored bounding box to use 2x Vector3 instead of custom object.

上级 b1ef3409
......@@ -89,10 +89,9 @@ this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new TH
d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,
b,c,d,e,f,B){h=a.vertices[b].position;i=a.vertices[c].position;k=a.vertices[d].position;j=g[e];o=g[f];p=g[B];m=i.x-h.x;q=k.x-h.x;n=i.y-h.y;s=k.y-h.y;r=i.z-h.z;u=k.z-h.z;t=o.u-j.u;z=p.u-j.u;A=o.v-j.v;E=p.v-j.v;D=1/(t*E-z*A);y.set((E*m-A*q)*D,(E*n-A*s)*D,(E*r-A*u)*D);K.set((t*q-z*m)*D,(t*s-z*n)*D,(t*u-z*r)*D);w[b].addSelf(y);w[c].addSelf(y);w[d].addSelf(y);G[b].addSelf(K);G[c].addSelf(K);G[d].addSelf(K)}var b,c,d,e,f,g,h,i,k,j,o,p,m,q,n,s,r,u,t,z,A,E,D,B,w=[],G=[],y=new THREE.Vector3,K=new THREE.Vector3,
$=new THREE.Vector3,Q=new THREE.Vector3,Y=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)w[b]=new THREE.Vector3,G[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var S=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)Y.copy(f.vertexNormals[d]),e=f[S[d]],
B=w[e],$.copy(B),$.subSelf(Y.multiplyScalar(Y.dot(B))).normalize(),Q.cross(f.vertexNormals[d],B),e=Q.dot(G[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,e)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=
this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=
0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=
c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
B=w[e],$.copy(B),$.subSelf(Y.multiplyScalar(Y.dot(B))).normalize(),Q.cross(f.vertexNormals[d],B),e=Q.dot(G[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,i,k,j,o,p;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=f===0?f:f-1;c[1]=f;c[2]=f>this.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;k=this.points[c[0]];j=this.points[c[1]];
o=this.points[c[2]];p=this.points[c[3]];h=g*g;i=g*h;d.x=b(k.x,j.x,o.x,p.x,g,h,i);d.y=b(k.y,j.y,o.y,p.y,g,h,i);d.z=b(k.z,j.z,o.z,p.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),g.copy(d),i+=g.distanceTo(f),
f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=i,e=b);h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],i=new THREE.Vector3,j=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=j.chunks[b]-j.chunks[b-1];g=Math.ceil(a*c/j.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+c*(1/g)*(f-e),d=this.getPoint(d),h.push(i.copy(d).clone());h.push(i.copy(this.points[b]).clone())}this.points=
......@@ -352,8 +351,8 @@ g;d++)i.push(new THREE.UV(e[d].u,e[d].v));b.faceVertexUvs[0].push(i)}return b},r
f=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,f);else if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;f=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(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b));return THREE.GeometryUtils.random()*(c+
g)<c?THREE.GeometryUtils.randomPointInTriangle(d,e,b):THREE.GeometryUtils.randomPointInTriangle(e,f,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return k[e]>a?b(c,e-1):k[e]<a?b(e+1,d):e}return b(0,k.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,i=0,k=[],j,o,p,m;for(e=0;e<h;e++){d=f[e];if(d instanceof THREE.Face3)j=g[d.a].position,o=g[d.b].position,p=g[d.c].position,d._area=THREE.GeometryUtils.triangleArea(j,o,p);else if(d instanceof
THREE.Face4)j=g[d.a].position,o=g[d.b].position,p=g[d.c].position,m=g[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(j,o,m),d._area2=THREE.GeometryUtils.triangleArea(o,p,m),d._area=d._area1+d._area2;i+=d._area;k[e]=i}d=[];g={};for(e=0;e<b;e++)h=THREE.GeometryUtils.random()*i,h=c(h),d[e]=THREE.GeometryUtils.randomPointInFace(f[h],a,!0),g[h]?g[h]+=1:g[h]=1;return d},triangleArea:function(a,b,c){var d,e=THREE.GeometryUtils.__v1;e.sub(a,b);d=e.length();e.sub(a,c);a=e.length();e.sub(b,c);c=e.length();
b=0.5*(d+a+c);return Math.sqrt(b*(b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=new THREE.Vector3;b.x=-0.5*(a.boundingBox.x[1]+a.boundingBox.x[0]);b.y=-0.5*(a.boundingBox.y[1]+a.boundingBox.y[0]);b.z=-0.5*(a.boundingBox.z[1]+a.boundingBox.z[0]);a.applyMatrix((new THREE.Matrix4).setTranslation(b.x,b.y,b.z));a.computeBoundingBox();return b},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,f=d.length;e<f;e++)d[e].u!==1&&(d[e].u-=Math.floor(d[e].u)),
d[e].v!==1&&(d[e].v-=Math.floor(d[e].v))}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
b=0.5*(d+a+c);return Math.sqrt(b*(b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).setTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,f=d.length;e<f;e++)d[e].u!==1&&(d[e].u-=Math.floor(d[e].u)),d[e].v!==1&&(d[e].v-=Math.floor(d[e].v))}};THREE.GeometryUtils.random=THREE.Math.random16;
THREE.GeometryUtils.__v1=new THREE.Vector3;
THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],f=new THREE.Texture(e,b),b=e.loadCount=0;for(d=a.length;b<d;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(e.loadCount===6)f.needsUpdate=!0;c&&c(this)},e[b].crossOrigin="",e[b].src=a[b];return f},getNormalMap:function(a,b){var c=function(a){var b=
Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]};b|=1;var d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),k=i.data,j=0;j<d;j++)for(var o=1;o<e;o++){var p=o-1<0?e-1:o-1,m=(o+1)%e,q=j-1<0?d-1:j-1,n=(j+1)%d,s=[],r=[0,0,h[(o*d+j)*4]/255*b];s.push([-1,0,h[(o*d+q)*4]/255*b]);s.push([-1,-1,h[(p*d+q)*4]/255*b]);s.push([0,-1,h[(p*d+j)*4]/255*b]);s.push([1,
-1,h[(p*d+n)*4]/255*b]);s.push([1,0,h[(o*d+n)*4]/255*b]);s.push([1,1,h[(m*d+n)*4]/255*b]);s.push([0,1,h[(m*d+j)*4]/255*b]);s.push([-1,1,h[(m*d+q)*4]/255*b]);p=[];q=s.length;for(m=0;m<q;m++){var n=s[m],u=s[(m+1)%q],n=[n[0]-r[0],n[1]-r[1],n[2]-r[2]],u=[u[0]-r[0],u[1]-r[1],u[2]-r[2]];p.push(c([n[1]*u[2]-n[2]*u[1],n[2]*u[0]-n[0]*u[2],n[0]*u[1]-n[1]*u[0]]))}s=[0,0,0];for(m=0;m<p.length;m++)s[0]+=p[m][0],s[1]+=p[m][1],s[2]+=p[m][2];s[0]/=p.length;s[1]/=p.length;s[2]/=p.length;r=(o*d+j)*4;k[r]=(s[0]+1)/
......
......@@ -88,13 +88,13 @@ this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new TH
d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,
b,c,d,e,f,D){j=a.vertices[b].position;n=a.vertices[c].position;k=a.vertices[d].position;l=g[e];h=g[f];m=g[D];o=n.x-j.x;p=k.x-j.x;i=n.y-j.y;q=k.y-j.y;F=n.z-j.z;x=k.z-j.z;I=h.u-l.u;G=m.u-l.u;r=h.v-l.v;C=m.v-l.v;y=1/(I*C-G*r);E.set((C*o-r*p)*y,(C*i-r*q)*y,(C*F-r*x)*y);O.set((I*p-G*o)*y,(I*q-G*i)*y,(I*x-G*F)*y);t[b].addSelf(E);t[c].addSelf(E);t[d].addSelf(E);A[b].addSelf(O);A[c].addSelf(O);A[d].addSelf(O)}var b,c,d,e,f,g,j,n,k,l,h,m,o,p,i,q,F,x,I,G,r,C,y,D,t=[],A=[],E=new THREE.Vector3,O=new THREE.Vector3,
$=new THREE.Vector3,U=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)t[b]=new THREE.Vector3,A[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var K=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)J.copy(f.vertexNormals[d]),e=f[K[d]],
D=t[e],$.copy(D),$.subSelf(J.multiplyScalar(J.dot(D))).normalize(),U.cross(f.vertexNormals[d],D),e=U.dot(A[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,e)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=
this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=
0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=
c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};
THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;
THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
D=t[e],$.copy(D),$.subSelf(J.multiplyScalar(J.dot(D))).normalize(),U.cross(f.vertexNormals[d],D),e=U.dot(A[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=new THREE.Light;
......
......@@ -7,10 +7,10 @@ n=h.id;t=p[n];if(t===void 0)t=a.materials.length,p[n]=t,a.materials.push(h);r.ma
0;for(c=e.length;a<c;a++){var h=e[a],i,k,j=h.vertexNormals,q=h.vertexColors;h instanceof THREE.Face3?i=new THREE.Face3(h.a,h.b,h.c):h instanceof THREE.Face4&&(i=new THREE.Face4(h.a,h.b,h.c,h.d));i.normal.copy(h.normal);d=0;for(f=j.length;d<f;d++)k=j[d],i.vertexNormals.push(k.clone());i.color.copy(h.color);d=0;for(f=q.length;d<f;d++)k=q[d],i.vertexColors.push(k.clone());i.materialIndex=h.materialIndex;i.centroid.copy(h.centroid);b.faces.push(i)}a=0;for(c=g.length;a<c;a++){e=g[a];i=[];d=0;for(f=e.length;d<
f;d++)i.push(new THREE.UV(e[d].u,e[d].v));b.faceVertexUvs[0].push(i)}return b},randomPointInTriangle:function(a,b,c){var d,e,g,f=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();e=THREE.GeometryUtils.random();d+e>1&&(d=1-d,e=1-e);g=1-d-e;f.copy(a);f.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);f.addSelf(h);h.copy(c);h.multiplyScalar(g);f.addSelf(h);return f},randomPointInFace:function(a,b,c){var d,e,g;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,e=b.vertices[a.b].position,
g=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,g);else if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;g=b.vertices[a.c].position;var b=b.vertices[a.d].position,f;c?a._area1&&a._area2?(c=a._area1,f=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b),a._area1=c,a._area2=f):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b));return THREE.GeometryUtils.random()*(c+
f)<c?THREE.GeometryUtils.randomPointInTriangle(d,e,b):THREE.GeometryUtils.randomPointInTriangle(e,g,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(d,c){if(c<d)return d;var e=d+Math.floor((c-d)/2);return k[e]>a?b(d,e-1):k[e]<a?b(e+1,c):e}return b(0,k.length-1)}var d,e,g=a.faces,f=a.vertices,h=g.length,i=0,k=[],j,q,p,m;for(e=0;e<h;e++){d=g[e];if(d instanceof THREE.Face3)j=f[d.a].position,q=f[d.b].position,p=f[d.c].position,d._area=THREE.GeometryUtils.triangleArea(j,q,p);else if(d instanceof
f)<c?THREE.GeometryUtils.randomPointInTriangle(d,e,b):THREE.GeometryUtils.randomPointInTriangle(e,g,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return k[e]>a?b(c,e-1):k[e]<a?b(e+1,d):e}return b(0,k.length-1)}var d,e,g=a.faces,f=a.vertices,h=g.length,i=0,k=[],j,q,p,m;for(e=0;e<h;e++){d=g[e];if(d instanceof THREE.Face3)j=f[d.a].position,q=f[d.b].position,p=f[d.c].position,d._area=THREE.GeometryUtils.triangleArea(j,q,p);else if(d instanceof
THREE.Face4)j=f[d.a].position,q=f[d.b].position,p=f[d.c].position,m=f[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(j,q,m),d._area2=THREE.GeometryUtils.triangleArea(q,p,m),d._area=d._area1+d._area2;i+=d._area;k[e]=i}d=[];f={};for(e=0;e<b;e++)h=THREE.GeometryUtils.random()*i,h=c(h),d[e]=THREE.GeometryUtils.randomPointInFace(g[h],a,!0),f[h]?f[h]+=1:f[h]=1;return d},triangleArea:function(a,b,c){var d,e=THREE.GeometryUtils.__v1;e.sub(a,b);d=e.length();e.sub(a,c);a=e.length();e.sub(b,c);c=e.length();
b=0.5*(d+a+c);return Math.sqrt(b*(b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=new THREE.Vector3;b.x=-0.5*(a.boundingBox.x[1]+a.boundingBox.x[0]);b.y=-0.5*(a.boundingBox.y[1]+a.boundingBox.y[0]);b.z=-0.5*(a.boundingBox.z[1]+a.boundingBox.z[0]);a.applyMatrix((new THREE.Matrix4).setTranslation(b.x,b.y,b.z));a.computeBoundingBox();return b},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,g=d.length;e<g;e++)d[e].u!==1&&(d[e].u-=Math.floor(d[e].u)),
d[e].v!==1&&(d[e].v-=Math.floor(d[e].v))}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
b=0.5*(d+a+c);return Math.sqrt(b*(b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).setTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,g=d.length;e<g;e++)d[e].u!==1&&(d[e].u-=Math.floor(d[e].u)),d[e].v!==1&&(d[e].v-=Math.floor(d[e].v))}};THREE.GeometryUtils.random=THREE.Math.random16;
THREE.GeometryUtils.__v1=new THREE.Vector3;
THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],g=new THREE.Texture(e,b),b=e.loadCount=0;for(d=a.length;b<d;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(e.loadCount===6)g.needsUpdate=!0;c&&c(this)},e[b].crossOrigin="",e[b].src=a[b];return g},getNormalMap:function(a,b){var c=function(a){var b=
Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]};b|=1;var d=a.width,e=a.height,g=document.createElement("canvas");g.width=d;g.height=e;var f=g.getContext("2d");f.drawImage(a,0,0);for(var h=f.getImageData(0,0,d,e).data,i=f.createImageData(d,e),k=i.data,j=0;j<d;j++)for(var q=1;q<e;q++){var p=q-1<0?e-1:q-1,m=(q+1)%e,l=j-1<0?d-1:j-1,n=(j+1)%d,r=[],o=[0,0,h[(q*d+j)*4]/255*b];r.push([-1,0,h[(q*d+l)*4]/255*b]);r.push([-1,-1,h[(p*d+l)*4]/255*b]);r.push([0,-1,h[(p*d+j)*4]/255*b]);r.push([1,
-1,h[(p*d+n)*4]/255*b]);r.push([1,0,h[(q*d+n)*4]/255*b]);r.push([1,1,h[(m*d+n)*4]/255*b]);r.push([0,1,h[(m*d+j)*4]/255*b]);r.push([-1,1,h[(m*d+l)*4]/255*b]);p=[];l=r.length;for(m=0;m<l;m++){var n=r[m],s=r[(m+1)%l],n=[n[0]-o[0],n[1]-o[1],n[2]-o[2]],s=[s[0]-o[0],s[1]-o[1],s[2]-o[2]];p.push(c([n[1]*s[2]-n[2]*s[1],n[2]*s[0]-n[0]*s[2],n[0]*s[1]-n[1]*s[0]]))}r=[0,0,0];for(m=0;m<p.length;m++)r[0]+=p[m][0],r[1]+=p[m][1],r[2]+=p[m][2];r[0]/=p.length;r[1]/=p.length;r[2]/=p.length;o=(q*d+j)*4;k[o]=(r[0]+1)/
......@@ -75,10 +75,10 @@ isolatedPts:l,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Uti
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,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},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,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+
this.b3p3(a,e)}};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,d=b.font!==void 0?b.font:"helvetiker",e=b.weight!==void 0?b.weight:"normal",g=b.style!==void 0?b.style:"normal";THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=g};
THREE.TextPath.prototype.toShapes=function(){for(var a=THREE.FontUtils.drawText(this.text).paths,b=[],c=0,d=a.length;c<d;c++)Array.prototype.push.apply(b,a[c].toShapes());return b};
THREE.AnimationHandler=function(){var a=[],b={},c={update:function(b){for(var d=0;d<a.length;d++)a[d].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){b[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(a.initialized!==!0){for(var d=0;d<a.hierarchy.length;d++){for(var c=0;c<a.hierarchy[d].keys.length;c++){if(a.hierarchy[d].keys[c].time<
0)a.hierarchy[d].keys[c].time=0;if(a.hierarchy[d].keys[c].rot!==void 0&&!(a.hierarchy[d].keys[c].rot instanceof THREE.Quaternion)){var h=a.hierarchy[d].keys[c].rot;a.hierarchy[d].keys[c].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[d].keys.length&&a.hierarchy[d].keys[0].morphTargets!==void 0){h={};for(c=0;c<a.hierarchy[d].keys.length;c++)for(var i=0;i<a.hierarchy[d].keys[c].morphTargets.length;i++){var k=a.hierarchy[d].keys[c].morphTargets[i];h[k]=-1}a.hierarchy[d].usedMorphTargets=
h;for(c=0;c<a.hierarchy[d].keys.length;c++){var j={};for(k in h){for(i=0;i<a.hierarchy[d].keys[c].morphTargets.length;i++)if(a.hierarchy[d].keys[c].morphTargets[i]===k){j[k]=a.hierarchy[d].keys[c].morphTargetsInfluences[i];break}i===a.hierarchy[d].keys[c].morphTargets.length&&(j[k]=0)}a.hierarchy[d].keys[c].morphTargetsInfluences=j}}for(c=1;c<a.hierarchy[d].keys.length;c++)a.hierarchy[d].keys[c].time===a.hierarchy[d].keys[c-1].time&&(a.hierarchy[d].keys.splice(c,1),c--);for(c=0;c<a.hierarchy[d].keys.length;c++)a.hierarchy[d].keys[c].index=
c}c=parseInt(a.length*a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(d=0;d<a.hierarchy.length;d++)a.JIT.hierarchy.push(Array(c));a.initialized=!0}},get:function(a){if(typeof a==="string")return b[a]?b[a]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+a),null)},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};c.LINEAR=
THREE.AnimationHandler=function(){var a=[],b={},c={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){b[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(a.initialized!==!0){for(var c=0;c<a.hierarchy.length;c++){for(var d=0;d<a.hierarchy[c].keys.length;d++){if(a.hierarchy[c].keys[d].time<
0)a.hierarchy[c].keys[d].time=0;if(a.hierarchy[c].keys[d].rot!==void 0&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[c].keys.length&&a.hierarchy[c].keys[0].morphTargets!==void 0){h={};for(d=0;d<a.hierarchy[c].keys.length;d++)for(var i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++){var k=a.hierarchy[c].keys[d].morphTargets[i];h[k]=-1}a.hierarchy[c].usedMorphTargets=
h;for(d=0;d<a.hierarchy[c].keys.length;d++){var j={};for(k in h){for(i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++)if(a.hierarchy[c].keys[d].morphTargets[i]===k){j[k]=a.hierarchy[c].keys[d].morphTargetsInfluences[i];break}i===a.hierarchy[c].keys[d].morphTargets.length&&(j[k]=0)}a.hierarchy[c].keys[d].morphTargetsInfluences=j}}for(d=1;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].time===a.hierarchy[c].keys[d-1].time&&(a.hierarchy[c].keys.splice(d,1),d--);for(d=0;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].index=
d}d=parseInt(a.length*a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(c=0;c<a.hierarchy.length;c++)a.JIT.hierarchy.push(Array(d));a.initialized=!0}},get:function(a){if(typeof a==="string")return b[a]?b[a]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+a),null)},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};c.LINEAR=
0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c,d){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=c!==void 0?c:THREE.AnimationHandler.LINEAR;this.JITCompile=d!==void 0?d:!0;this.points=[];this.target=new THREE.Vector3};
THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=b!==void 0?b:0;var c,d=this.hierarchy.length,e;for(c=0;c<d;c++){e=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)e.useQuaternion=!0;e.matrixAutoUpdate=!0;if(e.animationCache===void 0)e.animationCache={},e.animationCache.prevKey={pos:0,rot:0,scl:0},e.animationCache.nextKey={pos:0,rot:0,scl:0},e.animationCache.originalMatrix=e instanceof
THREE.Bone?e.skinMatrix:e.matrix;var g=e.animationCache.prevKey;e=e.animationCache.nextKey;g.pos=this.data.hierarchy[c].keys[0];g.rot=this.data.hierarchy[c].keys[0];g.scl=this.data.hierarchy[c].keys[0];e.pos=this.getNextKeyWith("pos",c,1);e.rot=this.getNextKeyWith("rot",c,1);e.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
......
......@@ -88,13 +88,13 @@ this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new TH
d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,
b,c,d,e,f,A){h=a.vertices[b].position;l=a.vertices[c].position;i=a.vertices[d].position;k=g[e];j=g[f];n=g[A];m=l.x-h.x;o=i.x-h.x;p=l.y-h.y;u=i.y-h.y;F=l.z-h.z;v=i.z-h.z;D=j.u-k.u;s=n.u-k.u;t=j.v-k.v;B=n.v-k.v;x=1/(D*B-s*t);I.set((B*m-t*o)*x,(B*p-t*u)*x,(B*F-t*v)*x);z.set((D*o-s*m)*x,(D*u-s*p)*x,(D*v-s*F)*x);H[b].addSelf(I);H[c].addSelf(I);H[d].addSelf(I);C[b].addSelf(z);C[c].addSelf(z);C[d].addSelf(z)}var b,c,d,e,f,g,h,l,i,k,j,n,m,o,p,u,F,v,D,s,t,B,x,y,H=[],C=[],I=new THREE.Vector3,z=new THREE.Vector3,
L=new THREE.Vector3,J=new THREE.Vector3,M=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)H[b]=new THREE.Vector3,C[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var N=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)M.copy(f.vertexNormals[d]),e=f[N[d]],
y=H[e],L.copy(y),L.subSelf(M.multiplyScalar(M.dot(y))).normalize(),J.cross(f.vertexNormals[d],y),e=J.dot(C[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4(L.x,L.y,L.z,e)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=
this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=
0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=
c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};
THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;
THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
y=H[e],L.copy(y),L.subSelf(M.multiplyScalar(M.dot(y))).normalize(),J.cross(f.vertexNormals[d],y),e=J.dot(C[e]),e=e<0?-1:1,f.vertexTangents[d]=new THREE.Vector4(L.x,L.y,L.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
e)].join("_"),a[d]===void 0?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];f=0;for(g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=e!==void 0?e:0.1;this.far=f!==void 0?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((b!==void 0?b:43.25)/(a*2));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=new THREE.Light;
......
......@@ -88,10 +88,9 @@ this.faces[a],d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new TH
c[d.b].addSelf(d.normal),c[d.c].addSelf(d.normal),c[d.d].addSelf(d.normal));a=0;for(b=this.vertices.length;a<b;a++)c[a].normalize();a=0;for(b=this.faces.length;a<b;a++)d=this.faces[a],d instanceof THREE.Face3?(d.vertexNormals[0].copy(c[d.a]),d.vertexNormals[1].copy(c[d.b]),d.vertexNormals[2].copy(c[d.c])):d instanceof THREE.Face4&&(d.vertexNormals[0].copy(c[d.a]),d.vertexNormals[1].copy(c[d.b]),d.vertexNormals[2].copy(c[d.c]),d.vertexNormals[3].copy(c[d.d]))},computeTangents:function(){function a(a,
b,d,c,f,g,O){i=a.vertices[b].position;l=a.vertices[d].position;k=a.vertices[c].position;j=h[f];p=h[g];s=h[O];w=l.x-i.x;n=k.x-i.x;E=l.y-i.y;y=k.y-i.y;J=l.z-i.z;P=k.z-i.z;Q=p.u-j.u;V=s.u-j.u;C=p.v-j.v;D=s.v-j.v;N=1/(Q*D-V*C);ha.set((D*w-C*n)*N,(D*E-C*y)*N,(D*J-C*P)*N);ca.set((Q*n-V*w)*N,(Q*y-V*E)*N,(Q*P-V*J)*N);ma[b].addSelf(ha);ma[d].addSelf(ha);ma[c].addSelf(ha);ua[b].addSelf(ca);ua[d].addSelf(ca);ua[c].addSelf(ca)}var b,d,c,f,g,h,i,l,k,j,p,s,w,n,E,y,J,P,Q,V,C,D,N,O,ma=[],ua=[],ha=new THREE.Vector3,
ca=new THREE.Vector3,pa=new THREE.Vector3,ja=new THREE.Vector3,xa=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++)ma[b]=new THREE.Vector3,ua[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++)g=this.faces[b],h=this.faceVertexUvs[0][b],g instanceof THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var va=["a","b","c","d"];b=0;for(d=this.faces.length;b<d;b++){g=this.faces[b];for(c=0;c<g.vertexNormals.length;c++)xa.copy(g.vertexNormals[c]),
f=g[va[c]],O=ma[f],pa.copy(O),pa.subSelf(xa.multiplyScalar(xa.dot(O))).normalize(),ja.cross(g.vertexNormals[c],O),f=ja.dot(ua[f]),f=f<0?-1:1,g.vertexTangents[c]=new THREE.Vector4(pa.x,pa.y,pa.z,f)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.vertices.length;b<
d;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=
0,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],d=[],c,f=Math.pow(10,4),g,h;g=0;for(h=this.vertices.length;g<h;g++)c=this.vertices[g].position,c=[Math.round(c.x*f),Math.round(c.y*f),Math.round(c.z*f)].join("_"),a[c]===void 0?(a[c]=g,b.push(this.vertices[g]),d[g]=b.length-1):d[g]=d[a[c]];g=0;for(h=this.faces.length;g<h;g++)if(a=this.faces[g],a instanceof THREE.Face3)a.a=d[a.a],a.b=d[a.b],a.c=
d[a.c];else if(a instanceof THREE.Face4)a.a=d[a.a],a.b=d[a.b],a.c=d[a.c],a.d=d[a.d];this.vertices=b}};THREE.GeometryCount=0;
f=g[va[c]],O=ma[f],pa.copy(O),pa.subSelf(xa.multiplyScalar(xa.dot(O))).normalize(),ja.cross(g.vertexNormals[c],O),f=ja.dot(ua[f]),f=f<0?-1:1,g.vertexTangents[c]=new THREE.Vector4(pa.x,pa.y,pa.z,f)}this.hasTangents=!0},computeBoundingBox:function(){if(this.vertices.length>0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,d=this.boundingBox.max,c=1,f=this.vertices.length;c<
f;c++){a=this.vertices[c].position;if(a.x<b.x)b.x=a.x;else if(a.x>d.x)d.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>d.y)d.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>d.z)d.z=a.z}}},computeBoundingSphere:function(){for(var a=0,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},mergeVertices:function(){var a={},b=[],d=[],c,f=Math.pow(10,4),g,h;g=0;for(h=this.vertices.length;g<h;g++)c=this.vertices[g].position,c=[Math.round(c.x*f),Math.round(c.y*f),
Math.round(c.z*f)].join("_"),a[c]===void 0?(a[c]=g,b.push(this.vertices[g]),d[g]=b.length-1):d[g]=d[a[c]];g=0;for(h=this.faces.length;g<h;g++)if(a=this.faces[g],a instanceof THREE.Face3)a.a=d[a.a],a.b=d[a.b],a.c=d[a.c];else if(a instanceof THREE.Face4)a.a=d[a.a],a.b=d[a.b],a.c=d[a.c],a.d=d[a.d];this.vertices=b}};THREE.GeometryCount=0;
THREE.Spline=function(a){function b(a,b,d,c,f,g,h){a=(d-a)*0.5;c=(c-b)*0.5;return(2*(b-d)+a+c)*h+(-3*(b-d)-2*a-c)*g+a*f+b}this.points=a;var d=[],c={x:0,y:0,z:0},f,g,h,i,l,k,j,p,s;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){f=(this.points.length-1)*a;g=Math.floor(f);h=f-g;d[0]=g===0?g:g-1;d[1]=g;d[2]=g>this.points.length-2?g:g+1;d[3]=g>this.points.length-3?g:g+2;k=this.points[d[0]];j=this.points[d[1]];
p=this.points[d[2]];s=this.points[d[3]];i=h*h;l=h*i;c.x=b(k.x,j.x,p.x,s.x,h,i,l);c.y=b(k.y,j.y,p.y,s.y,h,i,l);c.z=b(k.z,j.z,p.z,s.z,h,i,l);return c};this.getControlPointsArray=function(){var a,b,d=this.points.length,c=[];for(a=0;a<d;a++)b=this.points[a],c[a]=[b.x,b.y,b.z];return c};this.getLength=function(a){var b,d,c,f=b=b=0,g=new THREE.Vector3,h=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);d=this.points.length*a;g.copy(this.points[0]);for(a=1;a<d;a++)b=a/d,c=this.getPoint(b),h.copy(c),j+=h.distanceTo(g),
g.copy(c),b*=this.points.length-1,b=Math.floor(b),b!=f&&(i[b]=j,f=b);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(a){var b,d,c,f,g,h,i=[],j=new THREE.Vector3,k=this.getLength();i.push(j.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){d=k.chunks[b]-k.chunks[b-1];h=Math.ceil(a*d/k.total);f=(b-1)/(this.points.length-1);g=b/(this.points.length-1);for(d=1;d<h-1;d++)c=f+d*(1/h)*(g-f),c=this.getPoint(c),i.push(j.copy(c).clone());i.push(j.copy(this.points[b]).clone())}this.points=
......
......@@ -87,7 +87,7 @@
});
text3d.computeBoundingBox();
var centerOffset = -0.5 * ( text3d.boundingBox.x[ 1 ] - text3d.boundingBox.x[ 0 ] );
var centerOffset = -0.5 * ( text3d.boundingBox.max.x - text3d.boundingBox.min.x );
var textMaterial = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, overdraw: true } );
text = new THREE.Mesh( text3d, textMaterial );
......
......@@ -92,7 +92,7 @@
});
text3d.computeBoundingBox();
var centerOffset = -0.5 * ( text3d.boundingBox.x[ 1 ] - text3d.boundingBox.x[ 0 ] );
var centerOffset = -0.5 * ( text3d.boundingBox.max.x - text3d.boundingBox.min.x );
var textMaterial = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, overdraw: true } );
......@@ -174,26 +174,26 @@
//hearts circleLines
var material = new THREE.ParticleCanvasMaterial( { program: hearts, blending:THREE.AdditiveBlending } );
material.color.setHSV(hue, 0.5, 1);
material.color.setHSV(hue, 0.5, 1);
hue += 0.001;
if (hue>1) hue-=1;
particle = new THREE.Particle( material );
particle.scale.x = particle.scale.y = Math.random() * 20 +20;
particleCloud.add( particle );
particleCloud.add( particle );
return particle;
};
var onParticleCreated = function(p) {
var position = p.position;
p.target.position = position;
p.target.position = position;
};
var onParticleDead = function(particle) {
particle.target.visible = false;
particleCloud.remove(particle.target);
particleCloud.remove(particle.target);
};
sparksEmitter = new SPARKS.Emitter(new SPARKS.SteadyCounter(160));
......@@ -210,7 +210,7 @@
sparksEmitter.addAction(new SPARKS.Age());
//sparksEmitter.addAction(new SPARKS.Accelerate(0.2));
sparksEmitter.addAction(new SPARKS.Move());
sparksEmitter.addAction(new SPARKS.Move());
sparksEmitter.addAction(new SPARKS.RandomDrift(50,50,2000));
sparksEmitter.addCallback("created", onParticleCreated);
......
......@@ -20,9 +20,7 @@ THREE.Car = function () {
// - other wheels are mirrored against car root
// - if necessary back wheels can be offset manually
this.wheelOffsetX = 0;
this.wheelOffsetY = 0;
this.wheelOffsetZ = 0;
this.wheelOffset = new THREE.Vector3();
this.wheelDiameter = 1;
......@@ -266,15 +264,10 @@ THREE.Car = function () {
var bb = scope.wheelGeometry.boundingBox;
var dx = 0.5 * ( bb.x[ 1 ] + bb.x[ 0 ] );
var dy = 0.5 * ( bb.y[ 1 ] + bb.y[ 0 ] );
var dz = 0.5 * ( bb.z[ 1 ] + bb.z[ 0 ] );
scope.wheelOffset.add( bb.min, bb.max );
scope.wheelOffset.multiplyScalar( 0.5 );
scope.wheelOffsetX = dx;
scope.wheelOffsetY = dy;
scope.wheelOffsetZ = dz;
scope.wheelDiameter = bb.y[ 1 ] - bb.y[ 0 ];
scope.wheelDiameter = bb.max.y - bb.min.y;
THREE.GeometryUtils.center( scope.wheelGeometry );
......@@ -282,8 +275,8 @@ THREE.Car = function () {
// rig the car
var delta,
s = scope.modelScale,
var s = scope.modelScale,
delta = new THREE.Vector3(),
faceMaterial = new THREE.MeshFaceMaterial();
// body
......@@ -295,7 +288,7 @@ THREE.Car = function () {
// front left wheel
delta = new THREE.Vector3( s * scope.wheelOffsetX, s * scope.wheelOffsetY, s * scope.wheelOffsetZ );
delta.multiply( scope.wheelOffset, new THREE.Vector3( s, s, s ) );
scope.frontLeftWheelRoot.position.addSelf( delta );
......@@ -307,7 +300,7 @@ THREE.Car = function () {
// front right wheel
delta = new THREE.Vector3( -s * scope.wheelOffsetX, s * scope.wheelOffsetY, s * scope.wheelOffsetZ );
delta.multiply( scope.wheelOffset, new THREE.Vector3( -s, s, s ) );
scope.frontRightWheelRoot.position.addSelf( delta );
......@@ -321,7 +314,8 @@ THREE.Car = function () {
// back left wheel
delta = new THREE.Vector3( s * scope.wheelOffsetX, s * scope.wheelOffsetY, - s * scope.wheelOffsetZ - scope.backWheelOffset );
delta.multiply( scope.wheelOffset, new THREE.Vector3( s, s, -s ) );
delta.z -= scope.backWheelOffset;
scope.backLeftWheelMesh = new THREE.Mesh( scope.wheelGeometry, faceMaterial );
......@@ -332,7 +326,8 @@ THREE.Car = function () {
// back right wheel
delta = new THREE.Vector3( -s * scope.wheelOffsetX, s * scope.wheelOffsetY, - s * scope.wheelOffsetZ - scope.backWheelOffset )
delta.multiply( scope.wheelOffset, new THREE.Vector3( -s, s, -s ) );
delta.z -= scope.backWheelOffset;
scope.backRightWheelMesh = new THREE.Mesh( scope.wheelGeometry, faceMaterial );
......
......@@ -493,7 +493,7 @@
}
var centerOffset = -0.5 * ( textGeo.boundingBox.x[ 1 ] - textGeo.boundingBox.x[ 0 ] );
var centerOffset = -0.5 * ( textGeo.boundingBox.max.x - textGeo.boundingBox.min.x );
textMesh1 = new THREE.Mesh( textGeo, faceMaterial );
......
......@@ -592,23 +592,26 @@
var bb = shadowObject.geometry.boundingBox;
var dimensions = new THREE.Vector3();
dimensions.sub( bb.max, bb.min );
var margin = 0.15,
width = bb.z[ 1 ] - bb.z[ 0 ],
height = bb.x[ 1 ] - bb.x[ 0 ],
depth = bb.y[ 1 ] - bb.y[ 0 ],
width = dimensions.z,
height = dimensions.x,
depth = dimensions.y,
left = bb.z[ 0 ] - margin * width,
right = bb.z[ 1 ] + margin * width,
left = bb.min.z - margin * width,
right = bb.max.z + margin * width,
top = bb.x[ 1 ] + margin * height,
bottom = bb.x[ 0 ] - margin * height,
top = bb.max.x + margin * height,
bottom = bb.min.x - margin * height,
near = bb.y[ 1 ] + margin * depth,
far = bb.y[ 0 ] - margin * depth;
near = bb.max.y + margin * depth,
far = bb.min.y - margin * depth;
var topCamera = new THREE.OrthographicCamera( left, right, top, bottom, near, far );
topCamera.position.y = bb.y[ 1 ];
topCamera.position.y = bb.max.y;
topCamera.lookAt( shadowScene.position );
var renderShadow = new THREE.RenderPass( shadowScene, topCamera );
......@@ -669,8 +672,8 @@
var bb = object.bodyMesh.geometry.boundingBox;
var ss = object.modelScale * 1.0;
var shadowWidth = ss * ( bb.z[ 1 ] - bb.z[ 0 ] );
var shadowHeight = 1.25 * ss * ( bb.x[ 1 ] - bb.x[ 0 ] );
var shadowWidth = ss * ( bb.max.z - bb.min.z );
var shadowHeight = 1.25 * ss * ( bb.max.x - bb.min.x );
var shadowPlane = new THREE.PlaneGeometry( shadowWidth, shadowHeight );
var shadowMaterial = new THREE.MeshBasicMaterial( { color: 0xffffff, opacity: 0.5, transparent: true,
......
......@@ -280,8 +280,7 @@
mesh: mesh, vertices: geometry.vertices, vertices_tmp: vertices_tmp, vl: vl,
down: 0, up: 0, direction: 0, speed: 35, delay: Math.floor( 200 + 200 * Math.random() ),
started: false, start: Math.floor( 100 + 200 * Math.random() ),
dynamic: dynamic,
bb: geometry.boundingBox
dynamic: dynamic
} );
}
......@@ -298,7 +297,7 @@
function render () {
delta = 10 * clock.getDelta();;
delta = 10 * clock.getDelta();
delta = delta < 2 ? delta : 2;
......
......@@ -173,7 +173,7 @@
text3d.computeVertexNormals();
text3d.computeBoundingBox();
var centerOffset = -0.5 * ( text3d.boundingBox.x[ 1 ] - text3d.boundingBox.x[ 0 ] );
var centerOffset = -0.5 * ( text3d.boundingBox.max.x - text3d.boundingBox.min.x );
text = new THREE.Mesh( text3d, new THREE.MeshFaceMaterial() );
......
......@@ -206,7 +206,7 @@
});
textGeo.computeBoundingBox();
var centerOffset = -0.5 * ( textGeo.boundingBox.x[ 1 ] - textGeo.boundingBox.x[ 0 ] );
var centerOffset = -0.5 * ( textGeo.boundingBox.max.x - textGeo.boundingBox.min.x );
var textMaterial = new THREE.MeshPhongMaterial( { color: 0xff0000, specular: 0xffffff, ambient: 0xaa0000 } );
......
......@@ -341,45 +341,55 @@ THREE.Geometry.prototype = {
computeBoundingBox: function () {
var vertex;
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 ] };
var position, firstPosition = this.vertices[ 0 ].position;
if ( ! this.boundingBox ) {
this.boundingBox = { min: firstPosition.clone(), max: firstPosition.clone() };
} else {
this.boundingBox.min.copy( firstPosition );
this.boundingBox.max.copy( firstPosition );
}
var min = this.boundingBox.min,
max = this.boundingBox.max;
for ( var v = 1, vl = this.vertices.length; v < vl; v ++ ) {
vertex = this.vertices[ v ];
position = this.vertices[ v ].position;
if ( vertex.position.x < this.boundingBox.x[ 0 ] ) {
if ( position.x < min.x ) {
this.boundingBox.x[ 0 ] = vertex.position.x;
min.x = position.x;
} else if ( vertex.position.x > this.boundingBox.x[ 1 ] ) {
} else if ( position.x > max.x ) {
this.boundingBox.x[ 1 ] = vertex.position.x;
max.x = position.x;
}
if ( vertex.position.y < this.boundingBox.y[ 0 ] ) {
if ( position.y < min.y ) {
this.boundingBox.y[ 0 ] = vertex.position.y;
min.y = position.y;
} else if ( vertex.position.y > this.boundingBox.y[ 1 ] ) {
} else if ( position.y > max.y ) {
this.boundingBox.y[ 1 ] = vertex.position.y;
max.y = position.y;
}
if ( vertex.position.z < this.boundingBox.z[ 0 ] ) {
if ( position.z < min.z ) {
this.boundingBox.z[ 0 ] = vertex.position.z;
min.z = position.z;
} else if ( vertex.position.z > this.boundingBox.z[ 1 ] ) {
} else if ( position.z > max.z ) {
this.boundingBox.z[ 1 ] = vertex.position.z;
max.z = position.z;
}
......
......@@ -482,11 +482,12 @@ THREE.GeometryUtils = {
geometry.computeBoundingBox();
var bb = geometry.boundingBox;
var offset = new THREE.Vector3();
offset.x = - 0.5 * ( geometry.boundingBox.x[ 1 ] + geometry.boundingBox.x[ 0 ] );
offset.y = - 0.5 * ( geometry.boundingBox.y[ 1 ] + geometry.boundingBox.y[ 0 ] );
offset.z = - 0.5 * ( geometry.boundingBox.z[ 1 ] + geometry.boundingBox.z[ 0 ] );
offset.add( bb.min, bb.max );
offset.multiplyScalar( -0.5 );
geometry.applyMatrix( new THREE.Matrix4().setTranslation( offset.x, offset.y, offset.z ) );
geometry.computeBoundingBox();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册