Explorar el Código

Just adjusting some formatting in ExtrudeGeometry

zz85 hace 13 años
padre
commit
0de29f2da9
Se han modificado 2 ficheros con 26 adiciones y 13 borrados
  1. 13 1
      examples/webgl_geometry_shapes.html
  2. 13 12
      src/extras/geometries/ExtrudeGeometry.js

+ 13 - 1
examples/webgl_geometry_shapes.html

@@ -341,6 +341,7 @@
 
 
 				//splineShape.debug( document.getElementById("debug") );
 				//splineShape.debug( document.getElementById("debug") );
 
 
+				// TODO 3d path?
 				var extrudePath = new THREE.Path();
 				var extrudePath = new THREE.Path();
 
 
 				extrudePath.moveTo( 0, 0 );
 				extrudePath.moveTo( 0, 0 );
@@ -348,8 +349,19 @@
 				extrudePath.quadraticCurveTo( 80, 60, 160, 10 );
 				extrudePath.quadraticCurveTo( 80, 60, 160, 10 );
 				extrudePath.quadraticCurveTo( 240, -40, 320, 10 );
 				extrudePath.quadraticCurveTo( 240, -40, 320, 10 );
 
 
-				extrudeSettings.extrudePath = extrudePath;
+				// QUICK HACK, conversion from 2d to 3d spline
+				// Still broken and need fixes.
+				var apath = new THREE.SplineCurve3();
+				var tmpPoints = extrudePath.getPoints();
+				for (t in tmpPoints) {
+					var tmpPt = tmpPoints[t];
+					apath.points.push(new THREE.Vector3(tmpPt.x, tmpPt.y,0 ));
+				}
+
+
+				extrudeSettings.extrudePath = apath;
 				extrudeSettings.bevelEnabled = false;
 				extrudeSettings.bevelEnabled = false;
+				extrudeSettings.steps = 20;
 
 
 				var splineShape3d = splineShape.extrude( extrudeSettings );
 				var splineShape3d = splineShape.extrude( extrudeSettings );
 				var splinePoints = splineShape.createPointsGeometry( );
 				var splinePoints = splineShape.createPointsGeometry( );

+ 13 - 12
src/extras/geometries/ExtrudeGeometry.js

@@ -411,6 +411,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
     var normal = new THREE.Vector3();
     var normal = new THREE.Vector3();
     var position2 = new THREE.Vector3();
     var position2 = new THREE.Vector3();
     var lastBinormal = new THREE.Vector3(1, 0, 0);
     var lastBinormal = new THREE.Vector3(1, 0, 0);
+    var cx, cy;
 
 
 	// Back facing vertices
 	// Back facing vertices
 
 
@@ -434,8 +435,8 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
             binormal.cross(tangent, normal).normalize();
             binormal.cross(tangent, normal).normalize();
             lastBinormal = binormal;
             lastBinormal = binormal;
 
 
-            var cx = vert.x;
-            var cy = vert.y;
+            cx = vert.x;
+            cy = vert.y;
 
 
             position2.copy(splinePt);
             position2.copy(splinePt);
             position2.x += cx * normal.x + cy * binormal.x;
             position2.x += cx * normal.x + cy * binormal.x;
@@ -469,18 +470,18 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
 
 
 				tangent = extrudePath.getTangentAt((s - 1)/steps );
 				tangent = extrudePath.getTangentAt((s - 1)/steps );
 
 
-	            normal.cross(lastBinormal, tangent).normalize();
-	            binormal.cross(tangent, normal).normalize();
-	            lastBinormal = binormal;
+				normal.cross(lastBinormal, tangent).normalize();
+				binormal.cross(tangent, normal).normalize();
+				lastBinormal = binormal;
 
 
-	            var cx = vert.x;
-	            var cy = vert.y;
+				cx = vert.x;
+				cy = vert.y;
 
 
-	            position2.copy(splinePt);
-	            position2.x += cx * normal.x + cy * binormal.x;
-	            position2.y += cx * normal.y + cy * binormal.y;
-	            position2.z += cx * normal.z + cy * binormal.z;
-            	v( position2.x, position2.y, position2.z );
+				position2.copy(splinePt);
+				position2.x += cx * normal.x + cy * binormal.x;
+				position2.y += cx * normal.y + cy * binormal.y;
+				position2.z += cx * normal.z + cy * binormal.z;
+				v( position2.x, position2.y, position2.z );
 
 
 			}
 			}