|
@@ -100,7 +100,7 @@ THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.
|
|
|
return a}};THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
|
|
|
THREE.Face4.prototype={constructor:THREE.Face4,clone:function(){var a=new THREE.Face4(this.a,this.b,this.c,this.d);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b<c;b++)a.vertexNormals[b]=this.vertexNormals[b].clone();b=0;for(c=this.vertexColors.length;b<c;b++)a.vertexColors[b]=this.vertexColors[b].clone();b=0;for(c=this.vertexTangents.length;b<c;b++)a.vertexTangents[b]=this.vertexTangents[b].clone();
|
|
|
return a}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},lerpSelf:function(a,b){this.u=this.u+(a.u-this.u)*b;this.v=this.v+(a.v-this.v)*b;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
|
|
|
-THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.name="";this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=false};
|
|
|
+THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.name="";this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=false;this.dynamic=true};
|
|
|
THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a);for(var c=0,d=this.vertices.length;c<d;c++)a.multiplyVector3(this.vertices[c]);c=0;for(d=this.faces.length;c<d;c++){var e=this.faces[c];b.multiplyVector3(e.normal);for(var f=0,g=e.vertexNormals.length;f<g;f++)b.multiplyVector3(e.vertexNormals[f]);a.multiplyVector3(e.centroid)}},computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,
|
|
|
0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a]);c.centroid.addSelf(this.vertices[c.b]);c.centroid.addSelf(this.vertices[c.c]);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a]);c.centroid.addSelf(this.vertices[c.b]);c.centroid.addSelf(this.vertices[c.c]);c.centroid.addSelf(this.vertices[c.d]);c.centroid.divideScalar(4)}}},computeFaceNormals:function(){var a,b,c,d,e,f,g=new THREE.Vector3,h=new THREE.Vector3;a=0;for(b=this.faces.length;a<
|
|
|
b;a++){c=this.faces[a];d=this.vertices[c.a];e=this.vertices[c.b];f=this.vertices[c.c];g.sub(f,e);h.sub(d,e);g.crossSelf(h);g.isZero()||g.normalize();c.normal.copy(g)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices===void 0){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];
|
|
@@ -652,11 +652,11 @@ if(a.button===0||a.button===2){w=c;l.set(a.clientX,a.clientY)}else if(a.button==
|
|
|
THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,g,h,i,l,m){var n,o=d||1,p=e||1,q=h/2,r=i/2,s=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){n="y";p=f||1}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){n="x";o=f||1}var t=o+1,x=p+1,X=h/o,N=i/p,aa=new THREE.Vector3;aa[n]=l>0?1:-1;for(h=0;h<x;h++)for(i=0;i<t;i++){var ca=new THREE.Vector3;ca[a]=(i*X-q)*c;ca[b]=(h*N-r)*g;ca[n]=l;j.vertices.push(ca)}for(h=0;h<p;h++)for(i=0;i<o;i++){a=new THREE.Face4(i+
|
|
|
t*h+s,i+t*(h+1)+s,i+1+t*(h+1)+s,i+1+t*h+s);a.normal.copy(aa);a.vertexNormals.push(aa.clone(),aa.clone(),aa.clone(),aa.clone());a.materialIndex=m;j.faces.push(a);j.faceVertexUvs[0].push([new THREE.UV(i/o,1-h/p),new THREE.UV(i/o,1-(h+1)/p),new THREE.UV((i+1)/o,1-(h+1)/p),new THREE.UV((i+1)/o,1-h/p)])}}THREE.Geometry.call(this);var j=this,l=a/2,m=b/2,n=c/2,p,r,o,q,s,x;if(g!==void 0){if(g instanceof Array)this.materials=g;else{this.materials=[];for(p=0;p<6;p++)this.materials.push(g)}p=0;q=1;r=2;s=3;o=
|
|
|
4;x=5}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=void 0)for(var t in h)this.sides[t]!==void 0&&(this.sides[t]=h[t]);this.sides.px&&i("z","y",-1,-1,c,b,l,p);this.sides.nx&&i("z","y",1,-1,c,b,-l,q);this.sides.py&&i("x","z",1,1,a,c,m,r);this.sides.ny&&i("x","z",1,-1,a,c,-m,s);this.sides.pz&&i("x","y",1,-1,a,b,n,o);this.sides.nz&&i("x","y",-1,-1,a,b,-n,x);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=Object.create(THREE.Geometry.prototype);
|
|
|
-THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);var a=a!==void 0?a:20,b=b!==void 0?b:20,c=c!==void 0?c:100,g=c/2,d=d||8,e=e||1,h,i,j=[],l=[];for(i=0;i<=e;i++){var m=[],n=[],p=i/e,r=p*(b-a)+a;for(h=0;h<=d;h++){var o=h/d,q=new THREE.Vector3;q.x=r*Math.sin(o*Math.PI*2);q.y=-p*c+g;q.z=r*Math.cos(o*Math.PI*2);this.vertices.push(q);m.push(this.vertices.length-1);n.push(new THREE.UV(o,p))}j.push(m);l.push(n)}c=(b-a)/c;for(h=0;h<d;h++){if(a!==0){m=this.vertices[j[0][h]].clone();n=this.vertices[j[0][h+
|
|
|
-1]].clone()}else{m=this.vertices[j[1][h]].clone();n=this.vertices[j[1][h+1]].clone()}m.setY(Math.sqrt(m.x*m.x+m.z*m.z)*c).normalize();n.setY(Math.sqrt(n.x*n.x+n.z*n.z)*c).normalize();for(i=0;i<e;i++){var p=j[i][h],r=j[i+1][h],o=j[i+1][h+1],q=j[i][h+1],s=m.clone(),x=m.clone(),t=n.clone(),w=n.clone(),z=l[i][h].clone(),C=l[i+1][h].clone(),E=l[i+1][h+1].clone(),A=l[i][h+1].clone();this.faces.push(new THREE.Face4(p,r,o,q,[s,x,t,w]));this.faceVertexUvs[0].push([z,C,E,A])}}if(!f&&a>0){this.vertices.push(new THREE.Vector3(0,
|
|
|
-g,0));for(h=0;h<d;h++){p=j[0][h];r=j[0][h+1];o=this.vertices.length-1;s=new THREE.Vector3(0,1,0);x=new THREE.Vector3(0,1,0);t=new THREE.Vector3(0,1,0);z=l[0][h].clone();C=l[0][h+1].clone();E=new THREE.UV(C.u,0);this.faces.push(new THREE.Face3(p,r,o,[s,x,t]));this.faceVertexUvs[0].push([z,C,E])}}if(!f&&b>0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;h<d;h++){p=j[i][h+1];r=j[i][h];o=this.vertices.length-1;s=new THREE.Vector3(0,-1,0);x=new THREE.Vector3(0,-1,0);t=new THREE.Vector3(0,-1,0);
|
|
|
-z=l[i][h+1].clone();C=l[i][h].clone();E=new THREE.UV(C.u,1);this.faces.push(new THREE.Face3(p,r,o,[s,x,t]));this.faceVertexUvs[0].push([z,C,E])}}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry=function(a,b){if(typeof a!=="undefined"){THREE.Geometry.call(this);a=a instanceof Array?a:[a];this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeCentroids();this.computeFaceNormals()}};
|
|
|
-THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
|
|
|
+THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);var a=a!==void 0?a:20,b=b!==void 0?b:20,c=c!==void 0?c:100,g=c/2,d=d||8,e=e||1,h,i,j=[],l=[];for(i=0;i<=e;i++){var m=[],n=[],p=i/e,r=p*(b-a)+a;for(h=0;h<=d;h++){var o=h/d,q=new THREE.Vector3;q.x=r*Math.sin(o*Math.PI*2);q.y=-p*c+g;q.z=r*Math.cos(o*Math.PI*2);this.vertices.push(q);m.push(this.vertices.length-1);n.push(new THREE.UV(o,1-p))}j.push(m);l.push(n)}c=(b-a)/c;for(h=0;h<d;h++){if(a!==0){m=this.vertices[j[0][h]].clone();n=
|
|
|
+this.vertices[j[0][h+1]].clone()}else{m=this.vertices[j[1][h]].clone();n=this.vertices[j[1][h+1]].clone()}m.setY(Math.sqrt(m.x*m.x+m.z*m.z)*c).normalize();n.setY(Math.sqrt(n.x*n.x+n.z*n.z)*c).normalize();for(i=0;i<e;i++){var p=j[i][h],r=j[i+1][h],o=j[i+1][h+1],q=j[i][h+1],s=m.clone(),x=m.clone(),t=n.clone(),w=n.clone(),z=l[i][h].clone(),C=l[i+1][h].clone(),E=l[i+1][h+1].clone(),A=l[i][h+1].clone();this.faces.push(new THREE.Face4(p,r,o,q,[s,x,t,w]));this.faceVertexUvs[0].push([z,C,E,A])}}if(!f&&a>
|
|
|
+0){this.vertices.push(new THREE.Vector3(0,g,0));for(h=0;h<d;h++){p=j[0][h];r=j[0][h+1];o=this.vertices.length-1;s=new THREE.Vector3(0,1,0);x=new THREE.Vector3(0,1,0);t=new THREE.Vector3(0,1,0);z=l[0][h].clone();C=l[0][h+1].clone();E=new THREE.UV(C.u,0);this.faces.push(new THREE.Face3(p,r,o,[s,x,t]));this.faceVertexUvs[0].push([z,C,E])}}if(!f&&b>0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;h<d;h++){p=j[i][h+1];r=j[i][h];o=this.vertices.length-1;s=new THREE.Vector3(0,-1,0);x=new THREE.Vector3(0,
|
|
|
+-1,0);t=new THREE.Vector3(0,-1,0);z=l[i][h+1].clone();C=l[i][h].clone();E=new THREE.UV(C.u,1);this.faces.push(new THREE.Face3(p,r,o,[s,x,t]));this.faceVertexUvs[0].push([z,C,E])}}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype);
|
|
|
+THREE.ExtrudeGeometry=function(a,b){if(typeof a!=="undefined"){THREE.Geometry.call(this);a=a instanceof Array?a:[a];this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
|
|
|
THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);i.copy(a).addSelf(g);if(h.equals(i))return g.clone();
|
|
|
h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);if(f===0){console.log("Either infinite or no solutions!");g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions.")}g=g/f;if(g<0){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=a+Math.PI*2);c=(b+a)/2;a=-Math.cos(c);c=-Math.sin(c);return new THREE.Vector2(a,c)}return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(c,d){var e,f;for(I=c.length;--I>=0;){e=I;f=I-1;f<0&&(f=
|
|
|
c.length-1);for(var g=0,h=n+l*2,g=0;g<h;g++){var i=N*g,j=N*(g+1),m=d+e+i,i=d+f+i,o=d+f+j,j=d+e+j,p=c,q=g,r=h,s=e,u=f,m=m+M,i=i+M,o=o+M,j=j+M;J.faces.push(new THREE.Face4(m,i,o,j,null,null,x));m=t.generateSideWallUV(J,a,p,b,m,i,o,j,q,r,s,u);J.faceVertexUvs[0].push(m)}}}function f(a,b,c){J.vertices.push(new THREE.Vector3(a,b,c))}function g(c,d,e,f){c=c+M;d=d+M;e=e+M;J.faces.push(new THREE.Face3(c,d,e,null,null,s));c=f?t.generateBottomUV(J,a,b,c,d,e):t.generateTopUV(J,a,b,c,d,e);J.faceVertexUvs[0].push(c)}
|