diff --git a/build/Three.js b/build/Three.js index 2ca85181..0d0936b1 100755 --- a/build/Three.js +++ b/build/Three.js @@ -51,7 +51,7 @@ multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,e=a.z,g=this.x,h=this.y,j THREE.Quaternion.slerp=function(a,c,b,d){var e=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(e)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; THREE.Face4=function(a,c,b,d,e,g,h){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)};THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}}; -THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[];this.faceVertexUvs=[];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; +THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", @@ -333,7 +333,7 @@ this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.win this.phi=(this.phi-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.horizontalAngleMap.srcRange;q=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(q[1]-q[0])/(y[1]-y[0])+q[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,o,t,x)};this.onMouseMove=function(o){this.mouseX=o.clientX-this.windowHalfX;this.mouseY=o.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),j=new Cube(10,10,20),k=new Cube(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,h);a.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(a)}else{this.animation= c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(o,t){return function(){t.apply(o,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; -var Cube=function(a,c,b,d,e,g,h,j,k){function o(J,F,K,z,I,Q,Z,V){var f,fa,R=d||1,W=e||1,na=I/2,N=Q/2,xa=t.vertices.length;if(J=="x"&&F=="y"||J=="y"&&F=="x")f="z";else if(J=="x"&&F=="z"||J=="z"&&F=="x"){f="y";W=g||1}else if(J=="z"&&F=="y"||J=="y"&&F=="z"){f="x";R=g||1}var ta=R+1,qa=W+1;I/=R;var ua=Q/W;for(fa=0;fa0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,j,y)))-1);o.push(t)}c.push(o)}var q,A,H;e=c.length;this.faceVertexUvs[0]=[];for(b=0;b0)for(d=0;d1){q=this.vertices[h].position.clone();A=this.vertices[k].position.clone();H=this.vertices[o].position.clone();q.normalize();A.normalize();H.normalize();this.faces.push(new THREE.Face3(h,k,o,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([t,x,J])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry; -Sphere.prototype.constructor=Sphere; +0;j0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,j,y)))-1);o.push(t)}c.push(o)}var q,A,H;e=c.length;for(b=0;b0)for(d=0;d1){q=this.vertices[h].position.clone(); +A=this.vertices[k].position.clone();H=this.vertices[o].position.clone();q.normalize();A.normalize();H.normalize();this.faces.push(new THREE.Face3(h,k,o,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([t,x,J])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b= -1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; +1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; var TorusKnot=function(a,c,b,d,e,g,h){function j(x,y,q,A,H,J){y=q/A*x;q=Math.cos(y);return new THREE.Vector3(H*(2+q)*0.5*Math.cos(x),H*(2+q)*Math.sin(x)*0.5,J*H*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a




Generating world...
three.js - minecraft demo. featuring painterly pack
(left click: forward, right click: backward)
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/webgl_geometry_minecraft_ao.html b/examples/webgl_geometry_minecraft_ao.html index 65056cd8..6764e372 100644 --- a/examples/webgl_geometry_minecraft_ao.html +++ b/examples/webgl_geometry_minecraft_ao.html @@ -291,7 +291,7 @@ function setUVTile( face, s, t ) { - var j, uv = cube.uvs[ face ]; + var j, uv = cube.faceVertexUvs[ 0 ][ face ]; for ( j = 0; j < uv.length; j++ ) { uv[ j ].u += s * (unit+2*padding); @@ -372,9 +372,9 @@ // set UV tiles - for ( i = 0; i < cube.uvs.length; i++ ) { + for ( i = 0; i < cube.faceVertexUvs[ 0 ].length; i++ ) { - uv = cube.uvs[ i ]; + uv = cube.faceVertexUvs[ 0 ][ i ]; for ( j = 0; j < uv.length; j++ ) { diff --git a/examples/webgl_objconvert_test.html b/examples/webgl_objconvert_test.html index 5c5cd5b4..724b5fa5 100644 --- a/examples/webgl_objconvert_test.html +++ b/examples/webgl_objconvert_test.html @@ -42,91 +42,8 @@

 
-
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
-		
+
 		
 		
 		
@@ -279,8 +196,8 @@
 					callbackMale   = function( geometry ) { createScene( geometry,  90, 50, FLOOR, 105 ) },
 					callbackFemale = function( geometry ) { createScene( geometry, -80, 50, FLOOR, 0 ) };
 
-				//loader.load( { model: "obj/male02/Male02_slim.js", callback: callbackMale } );
-				//loader.load( { model: "obj/female02/Female02_slim.js", callback: callbackFemale } );
+				loader.load( { model: "obj/male02/Male02_slim.js", callback: callbackMale } );
+				loader.load( { model: "obj/female02/Female02_slim.js", callback: callbackFemale } );
 
 				//loader.loadBinary( { model: "obj/male02/Male02_bin.js", callback: callbackMale } );
 				//loader.loadBinary( { model: "obj/female02/Female02_bin.js", callback: callbackFemale } );
diff --git a/src/core/Geometry.js b/src/core/Geometry.js
index 5ebbb4c3..22c61617 100644
--- a/src/core/Geometry.js
+++ b/src/core/Geometry.js
@@ -14,8 +14,8 @@ THREE.Geometry = function () {
 
 	this.faces = [];
 
-	this.faceUvs = [];
-	this.faceVertexUvs = [];
+	this.faceUvs = [[]];
+	this.faceVertexUvs = [[]];
 
 	this.morphTargets = [];
 
diff --git a/src/extras/GeometryUtils.js b/src/extras/GeometryUtils.js
index 88f91e46..5de0a4cf 100644
--- a/src/extras/GeometryUtils.js
+++ b/src/extras/GeometryUtils.js
@@ -5,14 +5,14 @@ var GeometryUtils = {
 		var isMesh = object2 instanceof THREE.Mesh,
 		vertexPosition = geometry1.vertices.length,
 		facePosition = geometry1.faces.length,
-		uvPosition = geometry1.uvs.length,
+		uvPosition = geometry1.faceVertexUvs[ 0 ].length,
 		geometry2 = isMesh ? object2.geometry : object2,
 		vertices1 = geometry1.vertices,
 		vertices2 = geometry2.vertices,
 		faces1 = geometry1.faces,
 		faces2 = geometry2.faces,
-		uvs1 = geometry1.uvs,
-		uvs2 = geometry2.uvs;
+		uvs1 = geometry1.faceVertexUvs[ 0 ],
+		uvs2 = geometry2.faceVertexUvs[ 0 ];
 
 		isMesh && object2.matrixAutoUpdate && object2.updateMatrix();
 
diff --git a/src/extras/geometries/Cube.js b/src/extras/geometries/Cube.js
index 47336635..622835ea 100644
--- a/src/extras/geometries/Cube.js
+++ b/src/extras/geometries/Cube.js
@@ -6,7 +6,7 @@
 var Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, segmentsDepth, materials, flipped, sides ) {
 
 	THREE.Geometry.call( this );
-
+	
 	var scope = this,
 	width_half = width / 2,
 	height_half = height / 2,
@@ -106,8 +106,6 @@ var Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, segme
 			}
 
 		}
-
-		scope.faceVertexUvs[ 0 ] = [];
 		
 		for( iy = 0; iy < gridY; iy++ ) {
 
diff --git a/src/extras/geometries/Lathe.js b/src/extras/geometries/Lathe.js
index 04d95c70..137f4f06 100644
--- a/src/extras/geometries/Lathe.js
+++ b/src/extras/geometries/Lathe.js
@@ -5,7 +5,7 @@
 function Lathe( points, steps, angle ) {
 
 	THREE.Geometry.call( this );
-
+	
 	this.steps = steps || 12;
 	this.angle = angle || 2 * Math.PI;
 
@@ -47,7 +47,7 @@ function Lathe( points, steps, angle ) {
 		for ( var j = 0; j < oldInds.length - 1; j ++ ) {
 
 			this.faces.push( new THREE.Face4( newInds[ j ], newInds[ j + 1 ], oldInds[ j + 1 ], oldInds[ j ] ) );
-			this.uvs.push( [
+			this.faceVertexUvs[ 0 ].push( [
 
 				new THREE.UV( r / angle, j / points.length ),
 				new THREE.UV( r / angle, ( j + 1 ) / points.length ),
diff --git a/src/extras/geometries/Plane.js b/src/extras/geometries/Plane.js
index 9ccf39c5..433341fb 100644
--- a/src/extras/geometries/Plane.js
+++ b/src/extras/geometries/Plane.js
@@ -30,8 +30,6 @@ var Plane = function ( width, height, segmentsWidth, segmentsHeight ) {
 		}
 
 	}
-
-	this.faceVertexUvs[ 0 ] = [];
 	
 	for( iy = 0; iy < gridY; iy++ ) {
 
diff --git a/src/extras/geometries/Sphere.js b/src/extras/geometries/Sphere.js
index b710c739..354cf4eb 100644
--- a/src/extras/geometries/Sphere.js
+++ b/src/extras/geometries/Sphere.js
@@ -45,8 +45,6 @@ var Sphere = function ( radius, segmentsWidth, segmentsHeight ) {
 
 	var n1, n2, n3, iVerNum = aVtc.length;
 
-	this.faceVertexUvs[ 0 ] = [];
-
 	for ( j = 0; j < iVerNum; j++ ) {
 
 		var iHorNum = aVtc[ j ].length;
diff --git a/src/extras/geometries/Torus.js b/src/extras/geometries/Torus.js
index 8e6d5422..a4bb2e1b 100644
--- a/src/extras/geometries/Torus.js
+++ b/src/extras/geometries/Torus.js
@@ -13,55 +13,66 @@ var Torus = function ( radius, tube, segmentsR, segmentsT ) {
 	this.segmentsT = segmentsT || 6;
 
 	var temp_uv = [];
+	
+	THREE.Geometry.call( this );
 
-	THREE.Geometry.call(this);
+	for ( var j = 0; j <= this.segmentsR; ++j ) {
+
+		for ( var i = 0; i <= this.segmentsT; ++i ) {
 
-	for (var j = 0; j <= this.segmentsR; ++j) {
-		for (var i = 0; i <= this.segmentsT; ++i) {
 			var u = i / this.segmentsT * 2 * Math.PI;
 			var v = j / this.segmentsR * 2 * Math.PI;
 			var x = (this.radius + this.tube*Math.cos(v))*Math.cos(u);
 			var y = (this.radius + this.tube*Math.cos(v))*Math.sin(u);
 			var z = this.tube*Math.sin(v);
 
-			vert(x, y, z);
+			vert( x, y, z );
+
+			temp_uv.push( [i/this.segmentsT, 1 - j/this.segmentsR] );
 
-			temp_uv.push([i/this.segmentsT, 1 - j/this.segmentsR]);
 		}
 	}
 
 
-	for (var j = 1; j <= this.segmentsR; ++j) {
-		for (var i = 1; i <= this.segmentsT; ++i) {
+	for ( var j = 1; j <= this.segmentsR; ++j ) {
+
+		for ( var i = 1; i <= this.segmentsT; ++i ) {
+
 			var a = (this.segmentsT + 1)*j + i;
 			var b = (this.segmentsT + 1)*j + i - 1;
 			var c = (this.segmentsT + 1)*(j - 1) + i - 1;
 			var d = (this.segmentsT + 1)*(j - 1) + i;
 
-			f4(a,b,c,d);
+			f4( a, b, c,d );
 
-			this.uvs.push( [new THREE.UV( temp_uv[a][0], temp_uv[a][1] ),
+			this.faceVertexUvs[ 0 ].push( [new THREE.UV( temp_uv[a][0], temp_uv[a][1] ),
 							new THREE.UV( temp_uv[b][0], temp_uv[b][1] ),
 							new THREE.UV( temp_uv[c][0], temp_uv[c][1] ),
 							new THREE.UV( temp_uv[d][0], temp_uv[d][1] )
 							] );
 		}
+
 	}
 
 	delete temp_uv;
+
 	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
 
 	function vert( x, y, z ) {
+
 		scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
-	}
+
+	};
 
 	function f4( a, b, c, d ) {
-		scope.faces.push( new THREE.Face4( a, b, c, d ) );
-	}
 
-}
+		scope.faces.push( new THREE.Face4( a, b, c, d ) );
+
+	};
+
+};
 
 Torus.prototype = new THREE.Geometry();
 Torus.prototype.constructor = Torus;
diff --git a/src/extras/geometries/TorusKnot.js b/src/extras/geometries/TorusKnot.js
index d03a95be..9e1174b9 100644
--- a/src/extras/geometries/TorusKnot.js
+++ b/src/extras/geometries/TorusKnot.js
@@ -7,7 +7,7 @@ var TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale
 
 	var scope = this;
 	THREE.Geometry.call( this );
-
+	
 	this.radius = radius || 200;
 	this.tube = tube || 40;
 	this.segmentsR = segmentsR || 64;
@@ -26,6 +26,7 @@ var TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale
 		this.grid[ i ] = new Array( this.segmentsT );
 
 		for ( var j = 0; j < this.segmentsT; ++ j ) {
+
 			var u = i / this.segmentsR * 2 * this.p * Math.PI;
 			var v = j / this.segmentsT * 2 * Math.PI;
 			var p = getPos( u, v, this.q, this.p, this.radius, this.heightScale );
@@ -66,10 +67,12 @@ var TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale
 			var uvc = new THREE.UV( i / this.segmentsR, ( j + 1 ) / this.segmentsT );
 			var uvd = new THREE.UV( ( i + 1 ) / this.segmentsR, ( j + 1 ) / this.segmentsT );
 
-			f3(a, b, c);
-			this.uvs.push( [ uva,uvb,uvc ] );
-			f3(d, c, b);
-			this.uvs.push( [ uvd,uvc,uvb ] );
+			f3( a, b, c );
+			this.faceVertexUvs[ 0 ].push( [ uva,uvb,uvc ] );
+			
+			f3( d, c, b );
+			this.faceVertexUvs[ 0 ].push( [ uvd,uvc,uvb ] );
+
 		}
 	}
 
@@ -106,7 +109,7 @@ var TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale
 
 	}
 
-}
+};
 
 TorusKnot.prototype = new THREE.Geometry();
 TorusKnot.prototype.constructor = TorusKnot;