Bläddra i källkod

Some refactoring of ExtrudeGeometry\s useSpacedPoints as an option to parameter in THREE.Shape

zz85 13 år sedan
förälder
incheckning
a513d010b1
3 ändrade filer med 16 tillägg och 17 borttagningar
  1. 5 0
      src/extras/core/Path.js
  2. 10 0
      src/extras/core/Shape.js
  3. 1 17
      src/extras/geometries/ExtrudeGeometry.js

+ 5 - 0
src/extras/core/Path.js

@@ -206,6 +206,11 @@ THREE.Path.prototype.getSpacedPoints = function ( divisions, closedPath ) {
 
 THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
+	if (this.useSpacedPoints) {
+		console.log('tata');
+		return this.getSpacedPoints( divisions, closedPath );
+	}
+
 	divisions = divisions || 12;
 
 	var points = [];

+ 10 - 0
src/extras/core/Shape.js

@@ -74,6 +74,16 @@ THREE.Shape.prototype.extractAllPoints = function ( divisions ) {
 
 };
 
+THREE.Shape.prototype.extractPoints = function ( divisions ) {
+
+	if (this.useSpacedPoints) {
+		return this.getSpacedPointsHoles(divisions);
+	}
+
+	return this.extractAllPoints(divisions);
+
+};
+
 //
 // THREE.Shape.prototype.extractAllPointsWithBend = function ( divisions, bend ) {
 //

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

@@ -10,8 +10,6 @@
  *  curveSegments: 	<int>,		// number of points on the curves
  *  steps: 			<int>,		// number of points for z-side extrusions / used for subdivding extrude spline too
  *
- *	useSpacedPoints: <boolean>,	// Use equal space distances for triangulation shapes
- *
  *  bevelEnabled:	<bool>,			// turn on bevel
  *  bevelThickness: <float>, 		// how deep into text bevel goes
  *  bevelSize:		<float>, 		// how far from text outline is bevel
@@ -86,8 +84,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 	var extrudePath = options.extrudePath;
 	var extrudePts, extrudeByPath = false;
 
-	var useSpacedPoints = options.useSpacedPoints !== undefined ? options.useSpacedPoints : false;
-
 	var material = options.material;
 	var extrudeMaterial = options.extrudeMaterial;
 
@@ -129,19 +125,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 
 	}
 
-	var shapePoints;
-
-	if ( ! useSpacedPoints ) {
-
-	  	shapePoints = shape.extractAllPoints( curveSegments ); //
-
-	} else {
-
-		// QN - Would it be better to pass useSpacePoints parameter to shape, just like bendpath ?
-
-		shapePoints = shape.extractAllSpacedPoints( curveSegments ) // for points with equal divisions
-
-	}
+	var shapePoints = shape.extractPoints();
 
     var vertices = shapePoints.shape;
 	var holes = shapePoints.holes;