Browse Source

Merge branch 'master' of http://github.com/mrdoob/three.js

alteredq 14 years ago
parent
commit
377a71faa5

+ 1 - 1
build/Three.js

@@ -337,7 +337,7 @@ za*X+ca,J+za*(X+1)+ca,J+1+za*(X+1)+ca,J+1+za*X+ca,null,N));t.uvs.push([new THREE
 k[B]);this.sides.px&&m("z","y",1*j,-1,b,c,-w,this.materials[0]);this.sides.nx&&m("z","y",-1*j,-1,b,c,w,this.materials[1]);this.sides.py&&m("x","z",1*j,1,a,b,u,this.materials[2]);this.sides.ny&&m("x","z",1*j,-1,a,b,-u,this.materials[3]);this.sides.pz&&m("x","y",1*j,-1,a,c,o,this.materials[4]);this.sides.nz&&m("x","y",-1*j,-1,a,c,-o,this.materials[5]);(function(){for(var F=[],x=[],G=0,y=t.vertices.length;G<y;G++){for(var L=t.vertices[G],J=!1,Y=0,N=F.length;Y<N;Y++){var f=F[Y];if(L.position.x==f.position.x&&
 L.position.y==f.position.y&&L.position.z==f.position.z){x[G]=Y;J=!0;break}}if(!J){x[G]=F.length;F.push(new THREE.Vertex(L.position.clone()))}}G=0;for(y=t.faces.length;G<y;G++){L=t.faces[G];L.a=x[L.a];L.b=x[L.b];L.c=x[L.c];L.d=x[L.d]}t.vertices=F})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 var Cylinder=function(a,c,b,d,e,g){function h(t,w,u){j.vertices.push(new THREE.Vertex(new THREE.Vector3(t,w,u)))}THREE.Geometry.call(this);var j=this,k=Math.PI,m=d/2;for(d=0;d<a;d++)h(Math.sin(2*k*d/a)*c,Math.cos(2*k*d/a)*c,-m);for(d=0;d<a;d++)h(Math.sin(2*k*d/a)*b,Math.cos(2*k*d/a)*b,m);for(d=0;d<a;d++)j.faces.push(new THREE.Face4(d,d+a,a+(d+1)%a,(d+1)%a));if(b>0){h(0,0,-m-(g||0));for(d=a;d<a+a/2;d++)j.faces.push(new THREE.Face4(2*a,(2*d-2*a)%a,(2*d-2*a+1)%a,(2*d-2*a+2)%a))}if(c>0){h(0,0,m+(e||0));
-for(d=a+a/2;d<2*a;d++)j.faces.push(new THREE.Face4((2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
+for(d=a+a/2;d<2*a;d++)j.faces.push(new THREE.Face4(2*a+1,(2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
 var Icosahedron=function(a){function c(w,u,o){var v=Math.sqrt(w*w+u*u+o*o);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(w/v,u/v,o/v)))-1}function b(w,u,o,v){v.faces.push(new THREE.Face3(w,u,o))}function d(w,u){var o=e.vertices[w].position,v=e.vertices[u].position;return c((o.x+v.x)/2,(o.y+v.y)/2,(o.z+v.z)/2)}var e=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
 1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var j in g.faces){var k=d(g.faces[j].a,g.faces[j].b),m=d(g.faces[j].b,g.faces[j].c),t=d(g.faces[j].c,g.faces[j].a);b(g.faces[j].a,k,t,h);b(g.faces[j].b,m,k,h);b(g.faces[j].c,
 t,m,h);b(k,m,t,h)}g.faces=h.faces}e.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;

+ 1 - 1
build/custom/ThreeExtras.js

@@ -45,7 +45,7 @@ var Cube=function(a,d,b,c,g,e,f,h,j){function l(z,w,x,o,D,A,I,C){var E,F,J=c||1,
 l("z","y",1*h,-1,b,d,-t,this.materials[0]);this.sides.nx&&l("z","y",-1*h,-1,b,d,t,this.materials[1]);this.sides.py&&l("x","z",1*h,1,a,b,n,this.materials[2]);this.sides.ny&&l("x","z",1*h,-1,a,b,-n,this.materials[3]);this.sides.pz&&l("x","y",1*h,-1,a,d,m,this.materials[4]);this.sides.nz&&l("x","y",-1*h,-1,a,d,-m,this.materials[5]);(function(){for(var z=[],w=[],x=0,o=k.vertices.length;x<o;x++){for(var D=k.vertices[x],A=!1,I=0,C=z.length;I<C;I++){var E=z[I];if(D.position.x==E.position.x&&D.position.y==
 E.position.y&&D.position.z==E.position.z){w[x]=I;A=!0;break}}if(!A){w[x]=z.length;z.push(new THREE.Vertex(D.position.clone()))}}x=0;for(o=k.faces.length;x<o;x++){D=k.faces[x];D.a=w[D.a];D.b=w[D.b];D.c=w[D.c];D.d=w[D.d]}k.vertices=z})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 var Cylinder=function(a,d,b,c,g,e){function f(k,t,n){h.vertices.push(new THREE.Vertex(new THREE.Vector3(k,t,n)))}THREE.Geometry.call(this);var h=this,j=Math.PI,l=c/2;for(c=0;c<a;c++)f(Math.sin(2*j*c/a)*d,Math.cos(2*j*c/a)*d,-l);for(c=0;c<a;c++)f(Math.sin(2*j*c/a)*b,Math.cos(2*j*c/a)*b,l);for(c=0;c<a;c++)h.faces.push(new THREE.Face4(c,c+a,a+(c+1)%a,(c+1)%a));if(b>0){f(0,0,-l-(e||0));for(c=a;c<a+a/2;c++)h.faces.push(new THREE.Face4(2*a,(2*c-2*a)%a,(2*c-2*a+1)%a,(2*c-2*a+2)%a))}if(d>0){f(0,0,l+(g||0));
-for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4((2*c-2*a+2)%a+a,(2*c-2*a+1)%a+a,(2*c-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
+for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2*a+1)%a+a,(2*c-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
 var Icosahedron=function(a){function d(t,n,m){var p=Math.sqrt(t*t+n*n+m*m);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(t/p,n/p,m/p)))-1}function b(t,n,m,p){p.faces.push(new THREE.Face3(t,n,m))}function c(t,n){var m=g.vertices[t].position,p=g.vertices[n].position;return d((m.x+p.x)/2,(m.y+p.y)/2,(m.z+p.z)/2)}var g=this,e=new THREE.Geometry,f;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;d(-1,a,0);d(1,a,0);d(-1,-a,0);d(1,-a,0);d(0,-1,a);d(0,1,a);d(0,-1,-a);d(0,
 1,-a);d(a,0,-1);d(a,0,1);d(-a,0,-1);d(-a,0,1);b(0,11,5,e);b(0,5,1,e);b(0,1,7,e);b(0,7,10,e);b(0,10,11,e);b(1,5,9,e);b(5,11,4,e);b(11,10,2,e);b(10,7,6,e);b(7,1,8,e);b(3,9,4,e);b(3,4,2,e);b(3,2,6,e);b(3,6,8,e);b(3,8,9,e);b(4,9,5,e);b(2,4,11,e);b(6,2,10,e);b(8,6,7,e);b(9,8,1,e);for(a=0;a<this.subdivisions;a++){f=new THREE.Geometry;for(var h in e.faces){var j=c(e.faces[h].a,e.faces[h].b),l=c(e.faces[h].b,e.faces[h].c),k=c(e.faces[h].c,e.faces[h].a);b(e.faces[h].a,j,k,f);b(e.faces[h].b,l,j,f);b(e.faces[h].c,
 k,l,f);b(j,l,k,f)}e.faces=f.faces}g.faces=e.faces;delete e;delete f;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;

+ 2 - 0
examples/canvas_interactive_voxelpainter.html

@@ -149,6 +149,8 @@
 						voxel.position.x = Math.floor( position.x / 50 ) * 50 + 25;
 						voxel.position.y = Math.floor( position.y / 50 ) * 50 + 25;
 						voxel.position.z = Math.floor( position.z / 50 ) * 50 + 25;
+						voxel.matrixAutoUpdate = false;
+						voxel.updateMatrix();
 						voxel.overdraw = true;
 						scene.addObject( voxel );
 

+ 2 - 1
examples/webgl_interactive_voxelpainter.html

@@ -189,7 +189,8 @@
 
 						var voxel = new THREE.Mesh( cubeGeo, cubeMaterial );
 						voxel.position.copy( voxelPosition );
-
+						voxel.matrixAutoUpdate = false;
+						voxel.updateMatrix();
 						scene.addObject( voxel );
 
 					}

+ 2 - 2
examples/webgl_particles_billboards.html

@@ -70,7 +70,7 @@
 
 				sprite = ImageUtils.loadTexture( "textures/sprites/circle.png" );
 
-				for ( i = 0; i < 5000; i++ ) {
+				for ( i = 0; i < 10000; i++ ) {
 
 					x = 2000 * Math.random() - 1000;
 					y = 2000 * Math.random() - 1000;
@@ -95,7 +95,7 @@
 				light.position.z = 1;
 				scene.addLight( light );
 
-				renderer = new THREE.WebGLRenderer( { clearAlpha: 1 });
+				renderer = new THREE.WebGLRenderer( { antialias: false, clearAlpha: 1 });
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 

+ 1 - 1
examples/webgl_particles_billboards_colors.html

@@ -99,7 +99,7 @@
 				light.position.z = 1;
 				scene.addLight( light );
 
-				renderer = new THREE.WebGLRenderer( { clearAlpha: 1 });
+				renderer = new THREE.WebGLRenderer( { antialias: false, clearAlpha: 1 });
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 

+ 1 - 1
examples/webgl_particles_random.html

@@ -97,7 +97,7 @@
 
 				}
 
-				renderer = new THREE.WebGLRenderer();
+				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 

+ 1 - 1
examples/webgl_particles_sprites.html

@@ -102,7 +102,7 @@
 
 				}
 
-				renderer = new THREE.WebGLRenderer( { clearAlpha: 1 });
+				renderer = new THREE.WebGLRenderer( { antialias: false, clearAlpha: 1 });
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 

+ 5 - 5
src/core/Matrix4.js

@@ -72,20 +72,20 @@ THREE.Matrix4.prototype = {
 		var x = THREE.Matrix4.__v1, y = THREE.Matrix4.__v2, z = THREE.Matrix4.__v3;
 
 		z.sub( eye, center ).normalize();
-		
+
 		if ( z.length() === 0 ) {
-			
+
 			z.z = 1;
 
 		}
-		
+
 		x.cross( up, z ).normalize();
 
 		if ( x.length() === 0 ) {
-			
+
 			z.x += 0.0001;
 			x.cross( up, z ).normalize();
-			
+
 		}
 
 		y.cross( z, x ).normalize();

+ 20 - 4
src/extras/geometries/Cylinder.js

@@ -1,6 +1,7 @@
 /**
  * @author kile / http://kile.stravaganza.org/
- * @author mr.doob / http://mrdoob.com/ 
+ * @author mr.doob / http://mrdoob.com/
+ * @author fuzzthink
  */
 
 var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset ) {
@@ -29,7 +30,12 @@ var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset
 
 	for ( i = 0; i < numSegs; i++ ) {
 
-		f4( i, i + numSegs, numSegs + ( i + 1 ) % numSegs, ( i + 1 ) % numSegs );
+		f4(
+			i,
+			i + numSegs,
+			numSegs + ( i + 1 ) % numSegs,
+			( i + 1 ) % numSegs
+		);
 
 	}
 
@@ -41,7 +47,12 @@ var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset
 
 		for ( i = numSegs; i < numSegs + ( numSegs / 2 ); i++ ) {
 
-			f4( 2 * numSegs, ( 2 * i - 2 * numSegs ) % numSegs, ( 2 * i - 2 * numSegs + 1 ) % numSegs, ( 2 * i - 2 * numSegs + 2 ) % numSegs );
+			f4(
+				2 * numSegs,
+				( 2 * i - 2 * numSegs ) % numSegs,
+				( 2 * i - 2 * numSegs + 1 ) % numSegs,
+				( 2 * i - 2 * numSegs + 2 ) % numSegs
+			);
 
 		}
 
@@ -55,7 +66,12 @@ var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset
 
 		for ( i = numSegs + ( numSegs / 2 ); i < 2 * numSegs; i ++ ) {
 
-			f4( ( 2 * i - 2 * numSegs + 2 ) % numSegs + numSegs, ( 2 * i - 2 * numSegs + 1 ) % numSegs + numSegs, ( 2 * i - 2 * numSegs ) % numSegs+numSegs, 2 * numSegs + 1 );
+			f4(
+				2 * numSegs + 1,
+				( 2 * i - 2 * numSegs + 2 ) % numSegs + numSegs,
+				( 2 * i - 2 * numSegs + 1 ) % numSegs + numSegs,
+				( 2 * i - 2 * numSegs ) % numSegs + numSegs
+			);
 
 		}