Module: SpriteText

A sprite based text component. Text that always faces towards the camera.
Author:
License:
  • under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Source:
See:

Methods

(static) SpriteText(text, positionopt, optionsopt)

A sprite based text component.
Parameters:
Name Type Attributes Default Description
text string | number The text to be displayed on the sprite. You can include a multiline text separated by "\r\n".
position THREE.Vector3 <optional>
new THREE.Vector3() Position of the text.
options object <optional>
{} the following options are available
Properties
Name Type Attributes Default Description
name string <optional>
Name of the SpriteText instance.
group THREE.Group <optional>
Parent group of the SpriteText with common options. See common options for the group of the SpriteText. Default is undefined.
textHeight number <optional>
0.04 The height of the text.
fov number <optional>
Camera frustum vertical field of view, from bottom to top of view, in degrees. PerspectiveCamera.fov Set the fov option as camera.fov if you want to see text size is independent from camera.fov. The text height will be calculated as textHeight = fov * textHeight / 50 Default is undefined.
sizeAttenuation boolean <optional>
false Whether the size of the sprite is attenuated by the camera depth. (Perspective camera only.) See SpriteMaterial.sizeAttenuation
rotation number <optional>
0 The rotation of the sprite in radians. See SpriteMaterial.rotation
fontFace string <optional>
'Arial' CSS font-family - specifies the font of the text.
fontFaces Array.<string> <optional>
array of fontFaces. Example ['Arial', 'Verdana', 'Times'].
fontColor string <optional>
'rgba(255, 255, 255, 1)' RGBA object or RGB object or HEX value. Examples 'rgba(0, 0, 255, 0.5)', '#00FF00'.
bold boolean <optional>
false CSS font-weight. Equivalent of 700.
italic boolean <optional>
false CSS font-style.
fontProperties string <optional>
Other font properties. The font property uses the same syntax as the CSS font property. Default is empty string. Example "900", "oblique lighter".
rect object <optional>
{} rectangle around the text.
Properties
Name Type Attributes Default Description
displayRect boolean <optional>
false true - the rectangle around the text is visible.
backgroundColor string <optional>
'rgba(0, 0, 0, 0)' - black transparent background color. RGBA object or RGB object or HEX value
	Examples 'rgba(0, 0, 255, 0.5)', '#00FF00'.
borderColor string <optional>
border color. RGBA object or RGB object or HEX value. Default is same as options.fontColor 'rgba(255, 255, 255, 1)' - white.
borderThickness number <optional>
0 is invisible border border thickness.
borderRadius number <optional>
0 is no radius border corners radius.
center THREE.Vector2 | object <optional>
If center.x and center.y is defined, then it the text's anchor point.
See Sprite.center
	A value of (0.5, 0.5) corresponds to the midpoint of the text.
	A value of (0, 0) corresponds to the left lower corner of the text.
	A value of (0, 1) corresponds to the left upper corner of the text.
	
Otherwise, the center is calculated so that the text is always inside the canvas.
Please define center.camera and center.canvas for it. See below for details.

If options.center is not defined, center is left upper corner: new THREE.Vector2( 0, 1 )
center.camera THREE.PerspectiveCamera <optional>
PerspectiveCamera
center.canvas HTMLElement <optional>
canvas element.
Source:
See: