zz85 14 anni fa
parent
commit
8be77c8830

+ 37 - 1
src/extras/geometries/Curve.js

@@ -191,7 +191,7 @@ THREE.SplineCurve = function ( points ) {
 };
 
 THREE.SplineCurve.prototype = new THREE.Curve();
-THREE.SplineCurve.prototype.constructor = THREE.CubicBezierCurve;
+THREE.SplineCurve.prototype.constructor = THREE.SplineCurve;
 
 
 
@@ -217,6 +217,42 @@ THREE.SplineCurve.prototype.getPoint = function ( t /* between 0 .. 1 */) {
 
 }
 
+
+
+THREE.ArcCurve = function ( aX, aY, aRadius,
+                                 aStartAngle, aEndAngle, aClockwise ) {
+	this.aX = aX;
+	this.aY = aY;
+	this.aRadius = aRadius;
+	this.aStartAngle = aStartAngle;
+	this.aEndAngle = aEndAngle;
+	this.aClockwise;
+};
+
+THREE.ArcCurve.prototype = new THREE.Curve();
+THREE.ArcCurve.prototype.constructor = THREE.ArcCurve;
+
+
+
+/* Basic function to overwrite and implement */
+THREE.ArcCurve.prototype.getPoint = function ( t /* between 0 .. 1 */) {
+			
+	var deltaAngle = this.aEndAngle - this.aStartAngle;
+	if (this.aClockwise) {
+		t = 1 - t;
+	}
+	var angle = this.aStartAngle + t * deltaAngle;
+
+	var tx = this.aX + this.aRadius * Math.cos(angle);
+	var ty = this.aY + this.aRadius * Math.sin(angle);
+
+	return new THREE.Vector2( tx, ty );
+	
+}
+
+
+
+
 THREE.Curve.Utils = {
 	tangentQuadraticBezier: function (t, p0, p1, p2 ) {
 		return 2 * ( 1 - t ) * ( p1 - p0 ) + 2 * t * ( p2 - p1 ) ;

+ 1 - 1
src/extras/geometries/ExtrudeGeometry.js

@@ -30,7 +30,7 @@ THREE.ExtrudeGeometry = function( shape, options ) {
 
 	THREE.Geometry.call( this );
 
-    var vertices = shape.getPoints(); // getPoints | getSpacedPoints() you can get variable divisions by dividing by total lenght
+    var vertices = shape.getSpacedPoints(); // getPoints | getSpacedPoints() you can get variable divisions by dividing by total lenght
 	var reverse = THREE.FontUtils.Triangulate.area( vertices ) > 0 ;
 	if (reverse) {
 		//faces = THREE.FontUtils.Triangulate( vertices.reverse(), true );

+ 16 - 0
src/extras/geometries/Path.js

@@ -126,6 +126,10 @@ THREE.Path.prototype.arc = function(aX, aY, aRadius,
                                  aStartAngle, aEndAngle, aClockwise) {
 	
 	var args = Array.prototype.slice.call( arguments );
+	var curve = new THREE.ArcCurve( aX, aY, aRadius,
+	                                 aStartAngle, aEndAngle, aClockwise );
+	this.curves.push( curve );
+	
 	this.actions.push( { action: THREE.PathActions.ARC, args: args } );
    
 
@@ -142,6 +146,18 @@ return sine(disnt) * ampt
 THREE.Path.prototype.addExprFunc = function(exprName, func) {
 };
 */
+
+
+THREE.Path.prototype.getSpacedPoints = function(divisions) {
+	if (!divisions) divisions = 40;
+	var pts = [];
+	for (var i=0; i< divisions;i++) {
+		pts.push(this.getPoint(i/divisions));
+		//if(!this.getPoint(i/divisions)) throw "DIE";
+	}
+	//console.log(pts);
+	return pts;
+}
 	
 /* Return an array of vectors based on contour of the path */
 

+ 6 - 17
src/extras/geometries/Shape.js

@@ -19,17 +19,13 @@ THREE.Shape = function ( ) {
 THREE.Shape.prototype = new THREE.Path();
 THREE.Shape.prototype.constructor = THREE.Path;
 
-THREE.Shape.prototype.getSpacedPoints = function(divisions) {
-	if (!divisions) divisions = 40;
-	var pts = [];
-	for (var i=0; i< divisions;i++) {
-		pts.push(this.getPoint(i/divisions));
-		if(!this.getPoint(i/divisions)) throw "DIE";
-	}
-	//console.log(pts);
-	return pts;
-}
+/* Convenience method to return ExtrudeGeometry */
+THREE.Shape.prototype.extrude = function( options ) {
 
+	var extruded =  new THREE.ExtrudeGeometry( this, options );
+	return extruded;
+
+};
 
 THREE.Shape.Utils = {
 	triangulate2 : function(pts) {
@@ -81,11 +77,4 @@ THREE.Shape.Utils = {
 	}
 	
 };
-/* Convenience method to return ExtrudeGeometry */
-
-THREE.Shape.prototype.extrude = function( options ) {
 
-	var extruded =  new THREE.ExtrudeGeometry( this, options );
-	return extruded;
-
-};