You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.7 KiB
62 lines
1.7 KiB
/**
|
|
* @author zz85 / http://www.lab4games.net/zz85/blog
|
|
* @author alteredq / http://alteredqualia.com/
|
|
*
|
|
* For creating 3D text geometry in three.js
|
|
*
|
|
* Text = 3D Text
|
|
*
|
|
* parameters = {
|
|
* size: <float>, // size of the text
|
|
* height: <float>, // thickness to extrude text
|
|
* curveSegments: <int>, // number of points on the curves
|
|
*
|
|
* font: <string>, // font name
|
|
* weight: <string>, // font weight (normal, bold)
|
|
* style: <string>, // font style (normal, italics)
|
|
*
|
|
* bevelEnabled: <bool>, // turn on bevel
|
|
* bevelThickness: <float>, // how deep into text bevel goes
|
|
* bevelSize: <float>, // how far from text outline is bevel
|
|
* }
|
|
*
|
|
*/
|
|
|
|
/* Usage Examples
|
|
|
|
// TextGeometry wrapper
|
|
|
|
var text3d = new TextGeometry( text, options );
|
|
|
|
// Complete manner
|
|
|
|
var textShapes = THREE.FontUtils.generateShapes( text, options );
|
|
var text3d = new ExtrudeGeometry( textShapes, options );
|
|
|
|
*/
|
|
|
|
|
|
THREE.TextGeometry = function ( text, parameters ) {
|
|
|
|
parameters = parameters || {};
|
|
|
|
var textShapes = THREE.FontUtils.generateShapes( text, parameters );
|
|
|
|
// translate parameters to ExtrudeGeometry API
|
|
|
|
parameters.amount = parameters.height !== undefined ? parameters.height : 50;
|
|
|
|
// defaults
|
|
|
|
if ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10;
|
|
if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
|
|
if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
|
|
|
|
THREE.ExtrudeGeometry.call( this, textShapes, parameters );
|
|
|
|
this.type = 'TextGeometry';
|
|
|
|
};
|
|
|
|
THREE.TextGeometry.prototype = Object.create( THREE.ExtrudeGeometry.prototype );
|
|
THREE.TextGeometry.prototype.constructor = THREE.TextGeometry;
|
|
|