Label

Extends: BaseBillboard

Source: Label.ts:65

Billboard text label.


Constructor

new Label(options?: Object): Label

Parameters

  • options (Object, optional) — Label options:
    • options.position (Vec3 | Array.<number>, optional) — Billboard spatial position.
    • options.rotation (number, optional) — Screen angle rotation.
    • options.color (Vec4 | string | Array.<number>, optional) — Billboard color.
    • options.alignedAxis (Vec3 | Array.<number>, optional) — Billboard aligned vector.
    • options.offset (Vec2 | Array.<number>, optional) — Billboard center screen offset.
    • options.visibility (boolean, optional) — Visibility.
    • options.text (string, optional) — Text string.
    • options.face (string, optional) — HTML5 font face.
    • options.size (number, optional) — Font size in pixels.
    • options.style (string, optional) — HTML5 font style. Example 'normal', 'italic'.
    • options.weight (string, optional) — HTML5 font weight. Example 'normal', 'bold'.
    • options.outline (number, optional) — Text outline width in pixels. 0 - no outline. Default 0.
    • options.outlineColor (Vec4 | string | Array.<number>, optional) — Outline color.
    • options.align (string, optional) — Text horizontal align: "left", "right" and "center".

Instance Methods

setText(text: string)

Sets label text.

Parameters

  • text (string) — Text string. Text length cannot exceed the labelHandler._maxLetters value.

setLetterSpacing(letterSpacing: number)

Sets text letter spacing.

Parameters

  • letterSpacing (number) — Letter spacing.

getLetterSpacing()

Returns label text letter spacing.

setRtl(isRTL: boolean)

Change text direction.

Parameters

  • isRTL (boolean) — Text string.

getText(): string

Gets current text string.

Returns

  • string

setAlign(align: string)

Sets label text align. Could be center, left or right. Left is default.

Parameters

  • align (string) — Text align.

getAlign(): string

Gets label text current alignment.

Returns

  • string

setFace(face: string)

Sets font face family.

Parameters

  • face (string) — Font face family.

getFace(): string

Gets current font face.

Returns

  • string

setSize(size: number)

Sets label font size in pixels.

Parameters

  • size (number) — Label size in pixels.

getSize(): number

Gets label size in pixels.

Returns

  • number

setOutline(outline: number)

Sets text outline border width in pixels. Where 0 - is no outline. The visible width is capped by the font atlas distance field range, which grows with the label font size.

Parameters

  • outline (number) — Text outline width in pixels.

getOutline(): number

Gets text current outline width in pixels.

Returns

  • number

setOpacity(a: number)

Overrides: BaseBillboard#setOpacity

Sets label opacity.

Parameters

  • a (number) — Label opacity.

setOutlineColor(r: number, g: number, b: number, a: number)

Sets text outline color.

Parameters

  • r (number) — Red.
  • g (number) — Green.
  • b (number) — Blue.
  • a (number) — Alpha.

setOutlineColor4v(rgba: Vec4)

Sets text outline color.

Parameters

  • rgba (Vec4) — Color vector.

setOutlineColorHTML(color: string)

Sets text outline color HTML string.

Parameters

  • color (string) — HTML string color.

getOutlineColor(): Vec4

Gets outline color vector.

Returns

setOutlineOpacity(opacity: number)

Sets outline opacity. Actually outline color alpha value.

Parameters

  • opacity (number) — Outline opacity.

getOutlineOpacity(): number

Gets outline opacity value.

Returns

  • number

update()

Updates label parameters.

assignFontAtlas(fontAtlas: FontAtlas)

Assigns font atlas and update.

Parameters

  • fontAtlas (FontAtlas) — Font atlas.

setPosition(x: number, y: number, z: number)

Inherited from BaseBillboard#setPosition

Overrides: BaseBillboard#setPosition

Sets billboard position.

Parameters

  • x (number) — X coordinate.
  • y (number) — Y coordinate.
  • z (number) — Z coordinate.

setPosition3v(position: Vec3)

Inherited from BaseBillboard#setPosition3v

Overrides: BaseBillboard#setPosition3v

Sets billboard position.

Parameters

  • position (Vec3) — Cartesian coordinates.

getPosition(): Vec3

Inherited from BaseBillboard#getPosition

Overrides: BaseBillboard#getPosition

Returns billboard position.

Returns

setOffset(x: number, y: number)

Inherited from BaseBillboard#setOffset

Overrides: BaseBillboard#setOffset

Sets screen space offset.

Parameters

  • x (number) — X offset.
  • y (number) — Y offset.

setOffset2v(offset: Vec2)

Inherited from BaseBillboard#setOffset2v

Overrides: BaseBillboard#setOffset2v

Sets screen space offset.

Parameters

  • offset (Vec2) — Offset size.

getOffset(): Vec2

Inherited from BaseBillboard#getOffset

Overrides: BaseBillboard#getOffset

Returns billboard screen space offset size.

Returns

setRotation(rotation: number)

Inherited from BaseBillboard#setRotation

Overrides: BaseBillboard#setRotation

Sets billboard screen space rotation in radians.

Parameters

  • rotation (number) — Screen space rotation in radians.

getRotation(): number

Inherited from BaseBillboard#getRotation

Overrides: BaseBillboard#getRotation

Gets screen space rotation.

Returns

  • number

setColor(r: number, g: number, b: number, a: number)

Inherited from BaseBillboard#setColor

Overrides: BaseBillboard#setColor

Sets RGBA color. Each channel from 0.0 to 1.0.

Parameters

  • r (number) — Red.
  • g (number) — Green.
  • b (number) — Blue.
  • a (number) — Alpha.

setColor4v(color: Vec4)

Inherited from BaseBillboard#setColor4v

Overrides: BaseBillboard#setColor4v

Sets RGBA color. Each channel from 0.0 to 1.0.

Parameters

  • color (Vec4) — RGBA vector.

setColorHTML(color: string)

Inherited from BaseBillboard#setColorHTML

Overrides: BaseBillboard#setColorHTML

Sets billboard color.

Parameters

  • color (string) — HTML style color.

getColor(): Vec4

Inherited from BaseBillboard#getColor

Overrides: BaseBillboard#getColor

Returns RGBA color.

Returns

setVisibility(visibility: boolean)

Inherited from BaseBillboard#setVisibility

Overrides: BaseBillboard#setVisibility

Sets billboard visibility.

Parameters

  • visibility (boolean) — Visibility flag.

getVisibility(): boolean

Inherited from BaseBillboard#getVisibility

Overrides: BaseBillboard#getVisibility

Returns billboard visibility.

Returns

  • boolean

setAlignedAxis(x: number, y: number, z: number)

Inherited from BaseBillboard#setAlignedAxis

Overrides: BaseBillboard#setAlignedAxis

Sets billboard cartesian aligned vector.

Parameters

  • x (number) — Aligned vector X coordinate.
  • y (number) — Aligned vector Y coordinate.
  • z (number) — Aligned vector Z coordinate.

setAlignedAxis3v(alignedAxis: Vec3)

Inherited from BaseBillboard#setAlignedAxis3v

Overrides: BaseBillboard#setAlignedAxis3v

Sets billboard aligned vector.

Parameters

  • alignedAxis (Vec3) — Align direction.

getAlignedAxis(): Vec3

Inherited from BaseBillboard#getAlignedAxis

Overrides: BaseBillboard#getAlignedAxis

Returns aligned vector.

Returns

remove()

Inherited from BaseBillboard#remove

Overrides: BaseBillboard#remove

Removes billboard from handler.

setPickingColor3v(color: Vec3)

Inherited from BaseBillboard#setPickingColor3v

Overrides: BaseBillboard#setPickingColor3v

Sets billboard picking color.

Parameters

  • color (Vec3) — Picking color.