2 * @author zz85 / http://www.lab4games.net/zz85/blog
3 * @author alteredq / http://alteredqualia.com/
8 * font: <THREE.Font>, // font
10 * size: <float>, // size of the text
11 * height: <float>, // thickness to extrude text
12 * curveSegments: <int>, // number of points on the curves
14 * bevelEnabled: <bool>, // turn on bevel
15 * bevelThickness: <float>, // how deep into text bevel goes
16 * bevelSize: <float> // how far from text outline is bevel
20 import { Geometry } from '../core/Geometry';
21 import { ExtrudeBufferGeometry } from './ExtrudeGeometry';
25 function TextGeometry( text, parameters ) {
27 Geometry.call( this );
29 this.type = 'TextGeometry';
33 parameters: parameters
36 this.fromBufferGeometry( new TextBufferGeometry( text, parameters ) );
41 TextGeometry.prototype = Object.create( Geometry.prototype );
42 TextGeometry.prototype.constructor = TextGeometry;
46 function TextBufferGeometry( text, parameters ) {
48 parameters = parameters || {};
50 var font = parameters.font;
52 if ( ! ( font && font.isFont ) ) {
54 console.error( 'THREE.TextGeometry: font parameter is not an instance of THREE.Font.' );
55 return new Geometry();
59 var shapes = font.generateShapes( text, parameters.size, parameters.curveSegments );
61 // translate parameters to ExtrudeGeometry API
63 parameters.amount = parameters.height !== undefined ? parameters.height : 50;
67 if ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10;
68 if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
69 if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
71 ExtrudeBufferGeometry.call( this, shapes, parameters );
73 this.type = 'TextBufferGeometry';
77 TextBufferGeometry.prototype = Object.create( ExtrudeBufferGeometry.prototype );
78 TextBufferGeometry.prototype.constructor = TextBufferGeometry;
81 export { TextGeometry, TextBufferGeometry };