123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /**
- * @author zz85 / http://www.lab4games.net/zz85/blog
- *
- * TextPath - not sure if there's much use for this class.
- only thing it has it .toShapes() which can be removed by refactoring.
- *
- **/
- THREE.TextPath = function ( text, parameters ) {
- THREE.Path.call( this );
- this.parameters = parameters || {};
- this.set( text );
- };
- THREE.TextPath.prototype.set = function ( text, parameters ) {
- parameters = parameters || this.parameters;
- this.text = text;
- var size = parameters.size !== undefined ? parameters.size : 100;
- var curveSegments = parameters.curveSegments !== undefined ? parameters.curveSegments: 4;
- var font = parameters.font !== undefined ? parameters.font : "helvetiker";
- var weight = parameters.weight !== undefined ? parameters.weight : "normal";
- var style = parameters.style !== undefined ? parameters.style : "normal";
- THREE.FontUtils.size = size;
- THREE.FontUtils.divisions = curveSegments;
- THREE.FontUtils.face = font;
- THREE.FontUtils.weight = weight;
- THREE.FontUtils.style = style;
- };
- THREE.TextPath.prototype.toShapes = function () {
- // Get a Font data json object
- var data = THREE.FontUtils.drawText( this.text );
- var paths = data.paths;
- var shapes = [];
- for ( var p = 0, pl = paths.length; p < pl; p ++ ) {
- Array.prototype.push.apply( shapes, paths[ p ].toShapes() );
- }
- return shapes;
- };
|