Spaces:
Running
Running
File size: 2,031 Bytes
6cd9596 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
/**
* @author zz85 / http://www.lab4games.net/zz85/blog
* @author alteredq / http://alteredqualia.com/
*
* Text = 3D Text
*
* parameters = {
* font: <THREE.Font>, // font
*
* size: <float>, // size of the text
* height: <float>, // thickness to extrude text
* curveSegments: <int>, // number of points on the curves
*
* bevelEnabled: <bool>, // turn on bevel
* bevelThickness: <float>, // how deep into text bevel goes
* bevelSize: <float> // how far from text outline is bevel
* }
*/
import { Geometry } from '../core/Geometry.js';
import { ExtrudeBufferGeometry } from './ExtrudeGeometry.js';
// TextGeometry
function TextGeometry( text, parameters ) {
Geometry.call( this );
this.type = 'TextGeometry';
this.parameters = {
text: text,
parameters: parameters
};
this.fromBufferGeometry( new TextBufferGeometry( text, parameters ) );
this.mergeVertices();
}
TextGeometry.prototype = Object.create( Geometry.prototype );
TextGeometry.prototype.constructor = TextGeometry;
// TextBufferGeometry
function TextBufferGeometry( text, parameters ) {
parameters = parameters || {};
var font = parameters.font;
if ( ! ( font && font.isFont ) ) {
console.error( 'THREE.TextGeometry: font parameter is not an instance of THREE.Font.' );
return new Geometry();
}
var shapes = font.generateShapes( text, parameters.size );
// translate parameters to ExtrudeGeometry API
parameters.depth = 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;
ExtrudeBufferGeometry.call( this, shapes, parameters );
this.type = 'TextBufferGeometry';
}
TextBufferGeometry.prototype = Object.create( ExtrudeBufferGeometry.prototype );
TextBufferGeometry.prototype.constructor = TextBufferGeometry;
export { TextGeometry, TextBufferGeometry };
|