Browse Source

Updated Curve.js, Updated builds

zz85 14 years ago
parent
commit
61a407f37b

File diff suppressed because it is too large
+ 455 - 451
build/Three.js


+ 2 - 4
examples/canvas_geometry_subdivison.html

@@ -106,9 +106,9 @@
 				//PlaneGeometry not supported
 				//PlaneGeometry not supported
 				
 				
 				// quick fix for duplicated vertices
 				// quick fix for duplicated vertices
-				// /geometry.checkDupVertices( true );
+				geometry.checkDupVertices( true );
 				
 				
-				console.log(geometry);
+				//console.log(geometry);
 				
 				
 				smooth = createSubdivision(geometry, 2);
 				smooth = createSubdivision(geometry, 2);
 				
 				
@@ -131,8 +131,6 @@
 
 
 						context.fillText(i, 0,0);
 						context.fillText(i, 0,0);
 						
 						
-						
-						
 					};
 					};
 					
 					
 
 

+ 4 - 23
src/core/Geometry.js

@@ -14,7 +14,7 @@ THREE.Geometry = function () {
 
 
 	this.faces = [];
 	this.faces = [];
 
 
-	this.edges = [];
+	//this.edges = [];
 
 
 	this.faceUvs = [[]];
 	this.faceUvs = [[]];
 	this.faceVertexUvs = [[]];
 	this.faceVertexUvs = [[]];
@@ -487,9 +487,7 @@ THREE.Geometry.prototype = {
 				// to triangles: a,b,d / b,c,d
 				// to triangles: a,b,d / b,c,d
 				// shared edge is: b,d
 				// shared edge is: b,d
 
 
-				// should shared edge be included?
-				// comment out if not
-
+				// add edge B-D only if you wish to slice a face4
 				// hash = edge_hash( face.b, face.d ); 
 				// hash = edge_hash( face.b, face.d ); 
 				// addToMap( vfMap, hash, i );
 				// addToMap( vfMap, hash, i );
 
 
@@ -513,6 +511,7 @@ THREE.Geometry.prototype = {
 		
 		
 	
 	
 		this.vfMap = vfMap;
 		this.vfMap = vfMap;
+		this.edges = [];
 		
 		
 		var numOfEdges = 0;
 		var numOfEdges = 0;
 		for (i in vfMap) {
 		for (i in vfMap) {
@@ -525,25 +524,7 @@ THREE.Geometry.prototype = {
 		
 		
 		//console.log('vfMap', vfMap, 'this.edges',this.edges, 'numOfEdges', numOfEdges);
 		//console.log('vfMap', vfMap, 'this.edges',this.edges, 'numOfEdges', numOfEdges);
 
 
-		// Not sure what the below does.
-		
-		// for( i = 0, il = this.edges.length; i < il; i ++ ) {
-		// 
-		// 	edge = this.edges[ i ];
-		// 
-		// 	v1 = edge.vertexIndices[ 0 ];
-		// 	v2 = edge.vertexIndices[ 1 ];
-		// 
-		// 	edge.faceIndices = vfMap[ edge_hash( v1, v2 ) ].array;
-		// 
-		// 	for( j = 0; j < edge.faceIndices.length; j ++ ) {
-		// 
-		// 		faceIndex = edge.faceIndices[ j ];
-		// 		edge.faces.push( this.faces[ faceIndex ] );
-		// 
-		// 	}
-		// 
-		// }
+		return vfMap;
 
 
 	}, 
 	}, 
 	
 	

+ 78 - 0
src/extras/core/Curve.js

@@ -4,12 +4,19 @@
  *
  *
  * This file contains following classes:
  * This file contains following classes:
  *
  *
+ * -- 2d classes --
  * THREE.Curve
  * THREE.Curve
  * THREE.LineCurve
  * THREE.LineCurve
  * THREE.QuadraticBezierCurve
  * THREE.QuadraticBezierCurve
  * THREE.CubicBezierCurve
  * THREE.CubicBezierCurve
  * THREE.SplineCurve
  * THREE.SplineCurve
  * THREE.ArcCurve
  * THREE.ArcCurve
+ * 
+ * -- 3d classes --
+ * THREE.LineCurve3
+ * THREE.QuadraticBezierCurve3
+ * THREE.CubicBezierCurve3
+ * THREE.SplineCurve3
  *
  *
  **/
  **/
 
 
@@ -660,3 +667,74 @@ THREE.QuadraticBezierCurve3 = THREE.Curve.create(
 	}
 	}
 
 
 );
 );
+
+
+
+/**************************************************************
+ *	Cubic Bezier 3D curve
+ **************************************************************/
+
+THREE.CubicBezierCurve3 = THREE.Curve.create(
+
+	function ( v0, v1, v2, v3 ) {
+
+		this.v0 = v0;
+		this.v1 = v1;
+		this.v2 = v2;
+		this.v3 = v3;
+
+	},
+
+	function ( t ) {
+
+		var tx, ty, tz;
+
+		tx = THREE.Shape.Utils.b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x );
+		ty = THREE.Shape.Utils.b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y );
+		tz = THREE.Shape.Utils.b3( t, this.v0.z, this.v1.z, this.v2.z, this.v3.z );
+
+		return new THREE.Vector3( tx, ty, tz );
+
+	}
+
+);
+
+
+
+/**************************************************************
+ *	Spline 3D curve
+ **************************************************************/
+
+
+THREE.SplineCurve3 = THREE.Curve.create(
+
+	function ( points /* array of Vector3 */) {
+
+		this.points = points;
+		
+	},
+
+	function ( t ) {
+
+		var v = new THREE.Vector3();
+		var c = [];
+		var points = this.points, point, intPoint, weight;
+		point = ( points.length - 1 ) * t;
+
+		intPoint = Math.floor( point );
+		weight = point - intPoint;
+
+		c[ 0 ] = intPoint == 0 ? intPoint : intPoint - 1;
+		c[ 1 ] = intPoint;
+		c[ 2 ] = intPoint > points.length - 2 ? intPoint : intPoint + 1;
+		c[ 3 ] = intPoint > points.length - 3 ? intPoint : intPoint + 2;
+
+		v.x = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].x, points[ c[ 1 ] ].x, points[ c[ 2 ] ].x, points[ c[ 3 ] ].x, weight );
+		v.y = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].y, points[ c[ 1 ] ].y, points[ c[ 2 ] ].y, points[ c[ 3 ] ].y, weight );
+		v.z = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].z, points[ c[ 1 ] ].z, points[ c[ 2 ] ].z, points[ c[ 3 ] ].z, weight );
+
+		return v;
+
+	}
+
+);

+ 0 - 3
src/extras/geometries/ExtrudeGeometry.js

@@ -54,9 +54,6 @@ THREE.ExtrudeGeometry = function( shapes, options ) {
 	}
 	}
 
 
 
 
-	// UVs to be added
-	// How can we create UVs on this?
-
 	this.computeCentroids();
 	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 

Some files were not shown because too many files changed in this diff