TextBitmap Class

Extends THREE.Mesh
Module: Sprite

Text bitmap atlas with support for signed distance field data.

Input data should be composed of a BMFont file (can be a .fnt, .json. etc) file and a character atlas texture from an image.

Font atlas can be generate using the tool http://www.angelcode.com/products/bmfont/

Based on the three-bmfont-text library.

Methods

setText

(
  • text
)

Set the text to be displayed.

Parameters:

  • text String

updateGeometry

()

Update the text bitmap geometry.

Should be called every time after changes to configuration are made.

Attributes

align

String

Horizontal text alignment can be

  • TextBitmap.LEFT
  • TextBitmap.RIGHT
  • TextBitmap.CENTER

BITMAP

Number static

Simple bitmap font atlas.

BITMAP_SHADER

String static

Shader object used to render the bitmap directly without any processing.

Contains only the fragment shader code, the vertex is the same for every render mode.

CENTER

String static

Align text to the center.

color

THREE.Color

Color of the text, only applied for SDF and MSDF modes.

config

Object

BMFont text configuration object.

Passed to the BMFont text geometry generator. It is a object with the format.

{ font: (Object) Font data should be parsed from (.json, .fnt, etc) file, text: (String), width: (Number) Width of the text area, align: (String) Side to align the text, lineHeight: (Number) Line height/font size, letterSpacing: (Number) Spacing between characters, mode: (String) a mode for word-wrapper; can be 'pre' (maintain spacing), or 'nowrap' (collapse whitespace but only break on newline characters), otherwise assumes normal word-wrap behaviour (collapse whitespace, break at width or newlines) tabSize: (Number) the number of spaces to use in a single tab (default 4) start: (Number) the starting index into the text to layout (default 0) end: (Number) the ending index (exclusive) into the text to layout (default text.length) }

font

Object

BMFont text font data, contains the data about all characters available, and their position in the atlas.

Font data should be parsed from (.json, .fnt, etc) file.

Passed to the BMFont text geometry generator.

LEFT

String static

Align text to the left side.

letterSpacing

Number

Spacing between each letter.

lineHeight

Number

Space between each text line.

mode

Number

Text bitmap rendering mode, can be:

  • TextBitmap.BITMAP
  • TextBitmap.SDF
  • TextBitmap.MSDF

MSDF

Number static

Multi channel signed distance field font atlas.

RIGHT

String static

Align text to the right side.

SDF

Number static

Single channel signed distance field font atlas.

SDF_SHADER

String static

Shader object used to render single channel MSDF data.

Contains only the fragment shader code, the vertex is the same for every render mode.

Details about Multiā€Channel Signed Distance Fields for vetorial shapes rendering.

SDF_SHADER

String static

Shader object used to render single channel SDF data.

Contains only the fragment shader code, the vertex is the same for every render mode.

Details about signed distance fields for vetorial shapes rendering.

smoothing

Number

Smoothing of the text borders.

text

String

Text displayed on the object.

threshold

THREE.Color

SDF distance alpha threshold.

VERTEX_SHADER

String static

Vertex shader used to draw the text, is responsible for applying the billboard effect by removing the rotation from the transformation matrix.

width

Number

Width of the text box.