提交 114d3587 编写于 作者: M Mr.doob

Removed bend stuff from ExtrudeGeometry and TextGeometry.

Uhm, some day it would be nice to rewrite all this Shape/Path/Curve/CurvePath code...
上级 b6861b3e
......@@ -30162,30 +30162,28 @@ THREE.CylinderGeometry.prototype = Object.create( THREE.Geometry.prototype );
*
* parameters = {
*
* size: <float>, // size of the text
* height: <float>, // thickness to extrude text
* curveSegments: <int>, // number of points on the curves
* steps: <int>, // number of points for z-side extrusions / used for subdividing segements of extrude spline too
amount: <int>, // Amount
* size: <float>, // size of the text
* height: <float>, // thickness to extrude text
* curveSegments: <int>, // number of points on the curves
* steps: <int>, // number of points for z-side extrusions / used for subdividing segements of extrude spline too
* amount: <int>, // Amount
*
* bevelEnabled: <bool>, // turn on bevel
* bevelThickness: <float>, // how deep into text bevel goes
* bevelSize: <float>, // how far from text outline is bevel
* bevelSegments: <int>, // number of bevel layers
* bevelEnabled: <bool>, // turn on bevel
* bevelThickness: <float>, // how deep into text bevel goes
* bevelSize: <float>, // how far from text outline is bevel
* bevelSegments: <int>, // number of bevel layers
*
* extrudePath: <THREE.CurvePath> // 3d spline path to extrude shape along. (creates Frames if .frames aren't defined)
* frames: <THREE.TubeGeometry.FrenetFrames> // containing arrays of tangents, normals, binormals
* bendPath: <THREE.CurvePath> // 2d path for bend the shape around x/y plane
* extrudePath: <THREE.CurvePath> // 3d spline path to extrude shape along. (creates Frames if .frames aren't defined)
* frames: <THREE.TubeGeometry.FrenetFrames> // containing arrays of tangents, normals, binormals
*
* material: <int> // material index for front and back faces
* extrudeMaterial: <int> // material index for extrusion and beveled faces
* uvGenerator: <Object> // object that provides UV generator functions
* material: <int> // material index for front and back faces
* extrudeMaterial: <int> // material index for extrusion and beveled faces
* uvGenerator: <Object> // object that provides UV generator functions
*
* }
**/
* }
**/
THREE.ExtrudeGeometry = function( shapes, options ) {
THREE.ExtrudeGeometry = function ( shapes, options ) {
if ( typeof( shapes ) === "undefined" ) {
shapes = [];
......@@ -30215,7 +30213,7 @@ THREE.ExtrudeGeometry = function( shapes, options ) {
THREE.ExtrudeGeometry.prototype = Object.create( THREE.Geometry.prototype );
THREE.ExtrudeGeometry.prototype.addShapeList = function(shapes, options) {
THREE.ExtrudeGeometry.prototype.addShapeList = function ( shapes, options ) {
var sl = shapes.length;
for ( var s = 0; s < sl; s ++ ) {
......@@ -30224,7 +30222,7 @@ THREE.ExtrudeGeometry.prototype.addShapeList = function(shapes, options) {
}
};
THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
var amount = options.amount !== undefined ? options.amount : 100;
......@@ -30238,8 +30236,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
var steps = options.steps !== undefined ? options.steps : 1;
var bendPath = options.bendPath;
var extrudePath = options.extrudePath;
var extrudePts, extrudeByPath = false;
......@@ -30267,9 +30263,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
// Reuse TNB from TubeGeomtry for now.
// TODO1 - have a .isClosed in spline?
splineTube = options.frames !== undefined ?
options.frames :
new THREE.TubeGeometry.FrenetFrames(extrudePath, steps, false);
splineTube = options.frames !== undefined ? options.frames : new THREE.TubeGeometry.FrenetFrames(extrudePath, steps, false);
// console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);
......@@ -30297,15 +30291,9 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
var shapesOffset = this.vertices.length;
if ( bendPath ) {
shape.addWrapPath( bendPath );
}
var shapePoints = shape.extractPoints();
var vertices = shapePoints.shape;
var vertices = shapePoints.shape;
var holes = shapePoints.holes;
var reverse = !THREE.Shape.Utils.isClockWise( vertices ) ;
......@@ -30334,18 +30322,8 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
var faces = THREE.Shape.Utils.triangulateShape ( vertices, holes );
//var faces = THREE.Shape.Utils.triangulate2( vertices, holes );
// Would it be better to move points after triangulation?
// shapePoints = shape.extractAllPointsWithBend( curveSegments, bendPath );
// vertices = shapePoints.shape;
// holes = shapePoints.holes;
//console.log(faces);
////
/// Handle Vertices
////
/* Vertices */
var contour = vertices; // vertices has all points but contour has only points of circumference
......@@ -30372,9 +30350,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
cont, clen = contour.length;
//------
// Find directions for point movement
//
var RAD_TO_DEGREES = 180 / Math.PI;
......@@ -30687,11 +30663,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
}
////
/// Handle Faces
////
/* Faces */
// Top and bottom faces
......@@ -30823,8 +30795,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
// normal, color, material
scope.faces.push( new THREE.Face3( a, b, c, null, null, material ) );
var uvs = isBottom ? uvgen.generateBottomUV( scope, shape, options, a, b, c )
: uvgen.generateTopUV( scope, shape, options, a, b, c );
var uvs = isBottom ? uvgen.generateBottomUV( scope, shape, options, a, b, c ) : uvgen.generateTopUV( scope, shape, options, a, b, c );
scope.faceVertexUvs[ 0 ].push( uvs );
......@@ -30847,8 +30818,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
};
THREE.ExtrudeGeometry.WorldUVGenerator = {
generateTopUV: function( geometry, extrudedShape, extrudeOptions, indexA, indexB, indexC ) {
......@@ -30878,6 +30847,7 @@ THREE.ExtrudeGeometry.WorldUVGenerator = {
generateSideWallUV: function( geometry, extrudedShape, wallContour, extrudeOptions,
indexA, indexB, indexC, indexD, stepIndex, stepsLength,
contourIndex1, contourIndex2 ) {
var ax = geometry.vertices[ indexA ].x,
ay = geometry.vertices[ indexA ].y,
az = geometry.vertices[ indexA ].z,
......@@ -31163,15 +31133,12 @@ THREE.SphereGeometry.prototype = Object.create( THREE.Geometry.prototype );
* bevelEnabled: <bool>, // turn on bevel
* bevelThickness: <float>, // how deep into text bevel goes
* bevelSize: <float>, // how far from text outline is bevel
*
* bend: <bool> // bend according to hardcoded curve (generates bendPath)
* bendPath: <curve> // wraps text according to bend Path
* }
*
*/
/* Usage Examples
// TextGeometry wrapper
var text3d = new TextGeometry( text, options );
......@@ -31180,7 +31147,7 @@ THREE.SphereGeometry.prototype = Object.create( THREE.Geometry.prototype );
var textShapes = THREE.FontUtils.generateShapes( text, options );
var text3d = new ExtrudeGeometry( textShapes, options );
*/
......@@ -31198,19 +31165,6 @@ THREE.TextGeometry = function ( text, parameters ) {
if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
if ( parameters.bend ) {
var b = textShapes[ textShapes.length - 1 ].getBoundingBox();
var max = b.maxX;
parameters.bendPath = new THREE.QuadraticBezierCurve(
new THREE.Vector2( 0, 0 ),
new THREE.Vector2( max / 2, 120 ),
new THREE.Vector2( max, 0 )
);
}
THREE.ExtrudeGeometry.call( this, textShapes, parameters );
};
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -34,7 +34,7 @@
<div id="container"></div>
<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> webgl - buffergeometry</div>
<script src="../build/three.js"></script>
<script src="../build/three.min.js"></script>
<script src="js/Detector.js"></script>
<script src="js/Stats.js"></script>
......
......@@ -95,7 +95,6 @@
bevelSize = 1.5,
bevelSegments = 10,
bevelEnabled = true,
bend = false,
font = "helvetiker", // helvetiker, optimer, gentilis, droid sans, droid serif
weight = "bold", // normal bold
......@@ -158,8 +157,6 @@
bevelEnabled: bevelEnabled,
bevelSegments: bevelSegments,
bend: bend,
steps: steps
});
......
......@@ -33,7 +33,6 @@
<span class="button" id="font">change font</span>,
<span class="button" id="weight">change weight</span>,
<span class="button" id="bevel">change bevel</span>,
<span class="button" id="bend">bend</span>,
<span class="button" id="postprocessing">change postprocessing</span>,
<a id="permalink" href="#">permalink</a>
</div>
......@@ -95,27 +94,29 @@
bevelSize = 1.5,
bevelSegments = 3,
bevelEnabled = true,
bend = true,
font = "optimer", // helvetiker, optimer, gentilis, droid sans, droid serif
weight = "bold", // normal bold
style = "normal"; // normal italic
font = "optimer", // helvetiker, optimer, gentilis, droid sans, droid serif
weight = "bold", // normal bold
style = "normal"; // normal italic
var mirror = true;
var fontMap = {
"helvetiker" : 0,
"optimer" : 1,
"gentilis" : 2,
"droid sans" : 3,
"droid serif" : 4
"helvetiker": 0,
"optimer": 1,
"gentilis": 2,
"droid sans": 3,
"droid serif": 4
};
var weightMap = {
"normal" : 0,
"bold" : 1
}
"normal": 0,
"bold": 1
};
var reverseFontMap = {};
var reverseWeightMap = {};
......@@ -196,8 +197,7 @@
var weighthash = hash.substring( 7, 8 );
var pphash = hash.substring( 8, 9 );
var bevelhash = hash.substring( 9, 10 );
var bendhash = hash.substring( 10, 11 );
var texthash = hash.substring( 12 );
var texthash = hash.substring( 10 );
hex = colorhash;
pointLight.color.setHex( parseInt( colorhash, 16 ) );
......@@ -207,7 +207,6 @@
postprocessing.enabled = parseInt( pphash );
bevelEnabled = parseInt( bevelhash );
bend = parseInt( bendhash );
text = decodeURI( texthash );
......@@ -322,13 +321,6 @@
}, false );
document.getElementById( "bend" ).addEventListener( 'click', function() {
bend = !bend;
refreshText();
}, false );
document.getElementById( "postprocessing" ).addEventListener( 'click', function() {
postprocessing.enabled = !postprocessing.enabled;
......@@ -393,8 +385,7 @@
function updatePermalink() {
var link = hex + fontMap[ font ] + weightMap[ weight ] + boolToNum( postprocessing.enabled ) + boolToNum( bevelEnabled )
+ boolToNum( bend ) + "#" + encodeURI( text );
var link = hex + fontMap[ font ] + weightMap[ weight ] + boolToNum( postprocessing.enabled ) + boolToNum( bevelEnabled ) + "#" + encodeURI( text );
permalink.href = "#" + link;
window.location.hash = link;
......@@ -464,8 +455,6 @@
bevelSize: bevelSize,
bevelEnabled: bevelEnabled,
bend: bend,
material: 0,
extrudeMaterial: 1
......
......@@ -5,30 +5,28 @@
*
* parameters = {
*
* size: <float>, // size of the text
* height: <float>, // thickness to extrude text
* curveSegments: <int>, // number of points on the curves
* steps: <int>, // number of points for z-side extrusions / used for subdividing segements of extrude spline too
amount: <int>, // Amount
* size: <float>, // size of the text
* height: <float>, // thickness to extrude text
* curveSegments: <int>, // number of points on the curves
* steps: <int>, // number of points for z-side extrusions / used for subdividing segements of extrude spline too
* amount: <int>, // Amount
*
* bevelEnabled: <bool>, // turn on bevel
* bevelThickness: <float>, // how deep into text bevel goes
* bevelSize: <float>, // how far from text outline is bevel
* bevelSegments: <int>, // number of bevel layers
* bevelEnabled: <bool>, // turn on bevel
* bevelThickness: <float>, // how deep into text bevel goes
* bevelSize: <float>, // how far from text outline is bevel
* bevelSegments: <int>, // number of bevel layers
*
* extrudePath: <THREE.CurvePath> // 3d spline path to extrude shape along. (creates Frames if .frames aren't defined)
* frames: <THREE.TubeGeometry.FrenetFrames> // containing arrays of tangents, normals, binormals
* bendPath: <THREE.CurvePath> // 2d path for bend the shape around x/y plane
* extrudePath: <THREE.CurvePath> // 3d spline path to extrude shape along. (creates Frames if .frames aren't defined)
* frames: <THREE.TubeGeometry.FrenetFrames> // containing arrays of tangents, normals, binormals
*
* material: <int> // material index for front and back faces
* extrudeMaterial: <int> // material index for extrusion and beveled faces
* uvGenerator: <Object> // object that provides UV generator functions
* material: <int> // material index for front and back faces
* extrudeMaterial: <int> // material index for extrusion and beveled faces
* uvGenerator: <Object> // object that provides UV generator functions
*
* }
**/
* }
**/
THREE.ExtrudeGeometry = function( shapes, options ) {
THREE.ExtrudeGeometry = function ( shapes, options ) {
if ( typeof( shapes ) === "undefined" ) {
shapes = [];
......@@ -58,7 +56,7 @@ THREE.ExtrudeGeometry = function( shapes, options ) {
THREE.ExtrudeGeometry.prototype = Object.create( THREE.Geometry.prototype );
THREE.ExtrudeGeometry.prototype.addShapeList = function(shapes, options) {
THREE.ExtrudeGeometry.prototype.addShapeList = function ( shapes, options ) {
var sl = shapes.length;
for ( var s = 0; s < sl; s ++ ) {
......@@ -67,7 +65,7 @@ THREE.ExtrudeGeometry.prototype.addShapeList = function(shapes, options) {
}
};
THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
var amount = options.amount !== undefined ? options.amount : 100;
......@@ -81,8 +79,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
var steps = options.steps !== undefined ? options.steps : 1;
var bendPath = options.bendPath;
var extrudePath = options.extrudePath;
var extrudePts, extrudeByPath = false;
......@@ -110,9 +106,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
// Reuse TNB from TubeGeomtry for now.
// TODO1 - have a .isClosed in spline?
splineTube = options.frames !== undefined ?
options.frames :
new THREE.TubeGeometry.FrenetFrames(extrudePath, steps, false);
splineTube = options.frames !== undefined ? options.frames : new THREE.TubeGeometry.FrenetFrames(extrudePath, steps, false);
// console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);
......@@ -140,15 +134,9 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
var shapesOffset = this.vertices.length;
if ( bendPath ) {
shape.addWrapPath( bendPath );
}
var shapePoints = shape.extractPoints();
var vertices = shapePoints.shape;
var vertices = shapePoints.shape;
var holes = shapePoints.holes;
var reverse = !THREE.Shape.Utils.isClockWise( vertices ) ;
......@@ -177,18 +165,8 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
var faces = THREE.Shape.Utils.triangulateShape ( vertices, holes );
//var faces = THREE.Shape.Utils.triangulate2( vertices, holes );
// Would it be better to move points after triangulation?
// shapePoints = shape.extractAllPointsWithBend( curveSegments, bendPath );
// vertices = shapePoints.shape;
// holes = shapePoints.holes;
//console.log(faces);
////
/// Handle Vertices
////
/* Vertices */
var contour = vertices; // vertices has all points but contour has only points of circumference
......@@ -215,9 +193,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
cont, clen = contour.length;
//------
// Find directions for point movement
//
var RAD_TO_DEGREES = 180 / Math.PI;
......@@ -530,11 +506,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
}
////
/// Handle Faces
////
/* Faces */
// Top and bottom faces
......@@ -666,8 +638,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
// normal, color, material
scope.faces.push( new THREE.Face3( a, b, c, null, null, material ) );
var uvs = isBottom ? uvgen.generateBottomUV( scope, shape, options, a, b, c )
: uvgen.generateTopUV( scope, shape, options, a, b, c );
var uvs = isBottom ? uvgen.generateBottomUV( scope, shape, options, a, b, c ) : uvgen.generateTopUV( scope, shape, options, a, b, c );
scope.faceVertexUvs[ 0 ].push( uvs );
......@@ -690,8 +661,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) {
};
THREE.ExtrudeGeometry.WorldUVGenerator = {
generateTopUV: function( geometry, extrudedShape, extrudeOptions, indexA, indexB, indexC ) {
......@@ -721,6 +690,7 @@ THREE.ExtrudeGeometry.WorldUVGenerator = {
generateSideWallUV: function( geometry, extrudedShape, wallContour, extrudeOptions,
indexA, indexB, indexC, indexD, stepIndex, stepsLength,
contourIndex1, contourIndex2 ) {
var ax = geometry.vertices[ indexA ].x,
ay = geometry.vertices[ indexA ].y,
az = geometry.vertices[ indexA ].z,
......
......@@ -18,15 +18,12 @@
* bevelEnabled: <bool>, // turn on bevel
* bevelThickness: <float>, // how deep into text bevel goes
* bevelSize: <float>, // how far from text outline is bevel
*
* bend: <bool> // bend according to hardcoded curve (generates bendPath)
* bendPath: <curve> // wraps text according to bend Path
* }
*
*/
/* Usage Examples
// TextGeometry wrapper
var text3d = new TextGeometry( text, options );
......@@ -35,7 +32,7 @@
var textShapes = THREE.FontUtils.generateShapes( text, options );
var text3d = new ExtrudeGeometry( textShapes, options );
*/
......@@ -53,19 +50,6 @@ THREE.TextGeometry = function ( text, parameters ) {
if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
if ( parameters.bend ) {
var b = textShapes[ textShapes.length - 1 ].getBoundingBox();
var max = b.maxX;
parameters.bendPath = new THREE.QuadraticBezierCurve(
new THREE.Vector2( 0, 0 ),
new THREE.Vector2( max / 2, 120 ),
new THREE.Vector2( max, 0 )
);
}
THREE.ExtrudeGeometry.call( this, textShapes, parameters );
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册