diff --git a/src/extras/geometries/ExtrudeGeometry.js b/src/extras/geometries/ExtrudeGeometry.js index 30a2dd15..07a2f2a8 100644 --- a/src/extras/geometries/ExtrudeGeometry.js +++ b/src/extras/geometries/ExtrudeGeometry.js @@ -4,7 +4,10 @@ **/ THREE.ExtrudeGeometry = function( shapes, options ) { - + if( typeof( shapes ) == "undefined" ) { + shapes = []; + } + THREE.Geometry.call( this ); shapes = shapes instanceof Array ? shapes : [ shapes ]; @@ -12,8 +15,9 @@ THREE.ExtrudeGeometry = function( shapes, options ) { var s=0, sl = shapes.length, shape; for (;s 0; b -- ) { + for ( b = 0; b < bevelSegments; b ++ ) { + //for ( b = bevelSegments; b > 0; b -- ) { t = b / bevelSegments; - z = bevelThickness * t; + z = bevelThickness * ( 1-t); - // Formula could probably be simplified - //bs = bevelSize * (Math.sin ((1-t) * Math.PI/2 )) ; //bevelSize * t ; - bs = bevelSize * (1-t) ; + //z = bevelThickness * t; + bs = bevelSize * (Math.sin ((t) * Math.PI/2 )) ; // curved + //bs = bevelSize * t ; // linear // contract shape for ( i = 0, il = contour.length; i < il; i++ ) { @@ -284,8 +288,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) { } - console.log(bs); - + // expand holes for ( h = 0, hl = holes.length; h < hl; h++ ) { @@ -306,17 +309,17 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) { } + bs = bevelSize; // Back facing vertices for ( i = 0; i < vlen; i ++ ) { - vert = vertices[ i ]; - //v( vert.x, vert.y, 0 ); + //vert = vertices[ i ]; + vert = scalePt2(vertices[ i ], verticesMovements[i], bs); if ( !extrudeByPath ) { - vert = scalePt2(vert, verticesMovements[i], bs); v( vert.x, vert.y, 0 ); } else { @@ -336,10 +339,11 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) { for ( i = 0; i < vlen; i ++ ) { - vert = vertices[ i ]; + //vert = vertices[ i ]; + vert = scalePt2(vertices[ i ], verticesMovements[i], bs); if ( !extrudeByPath ) { - vert = scalePt2(vert, verticesMovements[i], bs); + v( vert.x, vert.y, amount / steps * s ); } else { @@ -355,17 +359,20 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) { // Add bevel segments planes - for ( b = 1; b <= bevelSegments; b ++ ) { - + //for ( b = 1; b <= bevelSegments; b ++ ) { + for ( b = bevelSegments-1; b >= 0; b -- ) { + t = b / bevelSegments; - z = bevelThickness * t; - bs = bevelSize * ( 1-Math.sin ( ( 1 - t ) * Math.PI/2 ) ); + z = bevelThickness * (1-t); + //bs = bevelSize * ( 1-Math.sin ( ( 1 - t ) * Math.PI/2 ) ); + bs = bevelSize * Math.sin ( t * Math.PI/2 ) ; // contract shape for ( i = 0, il = contour.length; i < il; i++ ) { - vert = scalePt( contour[ i ], contourCentroid, bs, false ); + vert = scalePt2(contour[i], contourMovements[i], bs); + //vert = scalePt( contour[ i ], contourCentroid, bs, false ); v( vert.x, vert.y, amount + z); } @@ -375,10 +382,12 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) { for ( h = 0, hl = holes.length; h < hl; h++ ) { ahole = holes[ h ]; + oneHoleMovements = holesMovements[h]; for ( i = 0, il = ahole.length; i < il; i++ ) { - vert = scalePt( ahole[ i ], holesCentroids[h], bs, true ); + //vert = scalePt( ahole[ i ], holesCentroids[h], bs, true ); + vert = scalePt2(ahole[i], oneHoleMovements[i], bs); if ( !extrudeByPath ) { diff --git a/src/extras/geometries/Path.js b/src/extras/geometries/Path.js index bed94c0c..a9516c1d 100644 --- a/src/extras/geometries/Path.js +++ b/src/extras/geometries/Path.js @@ -747,13 +747,14 @@ THREE.Path.prototype.toShapes = function() { } - console.log(subPaths); + //console.log(subPaths); + if (subPaths.length ==0) return []; var holesFirst = !THREE.Shape.Utils.isClockWise(subPaths[0].getPoints()); var tmpShape, shapes = []; var tmpPath; - console.log("Holes first", holesFirst); + //console.log("Holes first", holesFirst); if (holesFirst) { tmpShape = new THREE.Shape(); @@ -768,11 +769,11 @@ THREE.Path.prototype.toShapes = function() { shapes.push(tmpShape); tmpShape = new THREE.Shape(); - console.log('cw', i); + //console.log('cw', i); } else { tmpShape.holes.push(tmpPath); - console.log('ccw', i); + //console.log('ccw', i); } @@ -799,7 +800,7 @@ THREE.Path.prototype.toShapes = function() { shapes.push(tmpShape); } - console.log("shape", shapes); + //console.log("shape", shapes); return shapes; }; diff --git a/src/extras/geometries/TextGeometry.js b/src/extras/geometries/TextGeometry.js index e8665f25..f9c11ae4 100644 --- a/src/extras/geometries/TextGeometry.js +++ b/src/extras/geometries/TextGeometry.js @@ -35,35 +35,18 @@ * */ -THREE.TextGeometry = function ( text, parameters ) { - THREE.Geometry.call( this ); +THREE.TextPath = function ( text, parameters ) { + + THREE.Path.call( this ); this.parameters = parameters || {}; this.set( text ); }; -/* - var text3d = new TextGeometry(text); - - FactoryStyle - var text3d = FontUtils.createText(text); - var textPath = new TextPath(text); - var textShapes = textPath.toShapes(); - var text3d = new ExtrudeGeometry(textShapes, options); - - var textShapes = FontUtils.getTextShapes(text); - text3d = new ExtrudeGeometry(textShapes, options); - - - */ - -THREE.TextGeometry.prototype = new THREE.Geometry(); -THREE.TextGeometry.prototype.constructor = THREE.TextGeometry; - -THREE.TextGeometry.prototype.set = function ( text, parameters ) { +THREE.TextPath.prototype.set = function ( text, parameters ) { this.text = text; var parameters = parameters || this.parameters; @@ -92,7 +75,9 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) { }; -THREE.TextGeometry.prototype.get = function () { + + +THREE.TextPath.prototype.toShapes = function () { // Get a Font data json object @@ -104,18 +89,51 @@ THREE.TextGeometry.prototype.get = function () { for (var p=0, pl = paths.length; p