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.
66 lines
1.5 KiB
66 lines
1.5 KiB
/**
|
|
* Text = 3D Text
|
|
*
|
|
* parameters = {
|
|
* font: <THREE.Font>, // font
|
|
*
|
|
* size: <float>, // size of the text
|
|
* depth: <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 (including bevelOffset) is bevel
|
|
* bevelOffset: <float> // how far from text outline does bevel start
|
|
* }
|
|
*/
|
|
|
|
import {
|
|
ExtrudeGeometry
|
|
} from 'three';
|
|
|
|
class TextGeometry extends ExtrudeGeometry {
|
|
|
|
constructor( text, parameters = {} ) {
|
|
|
|
const font = parameters.font;
|
|
|
|
if ( font === undefined ) {
|
|
|
|
super(); // generate default extrude geometry
|
|
|
|
} else {
|
|
|
|
const shapes = font.generateShapes( text, parameters.size );
|
|
|
|
// translate parameters to ExtrudeGeometry API
|
|
|
|
if ( parameters.depth === undefined && parameters.height !== undefined ) {
|
|
|
|
console.warn( 'THREE.TextGeometry: .height is now depreciated. Please use .depth instead' ); // @deprecated, r163
|
|
|
|
}
|
|
|
|
parameters.depth = parameters.depth !== undefined ?
|
|
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;
|
|
|
|
super( shapes, parameters );
|
|
|
|
}
|
|
|
|
this.type = 'TextGeometry';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
export { TextGeometry };
|