Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Projected3DLabel

A Label that can be positioned in 3D space, but projected onto a 2D plane (a.k.a. screen). The unit for positioning is world space, the unit for size is pixel (px).

Hierarchy

Index

Constructors

constructor

  • Constructs a pre-configured projected 3D-label with given text. Depending on the label type, transformations are applied once when typesetting (static) or every frame during rendering (dynamic).

    Parameters

    • text: Text

      The text that is displayed by this label.

    • type: Type

      Either static or dynamic. If static is used, all transformations are baked and modifications to on any of the label's transformations are expected to occur less often.

    • Optional fontFace: FontFace

      The font face that should be used for that label, or undefined if set later.

    Returns Projected3DLabel

Properties

Protected _alignment

_alignment: Alignment = Label.Alignment.Left
see

alignment

Protected _altered

_altered: ChangeLookup & object = Object.assign(new ChangeLookup(), {any: false, color: false, resources: false, text: false, typesetting: false,static: false, dynamic: false,})
see

altered

Protected _backgroundColor

_backgroundColor: Color
see

{@link background}

Protected _camera

_camera: Camera | undefined
see

camera

Protected _color

_color: Color = new Color(Label.DEFAULT_COLOR)
see

color

Protected _direction

_direction: vec2
see

direction

Protected _dynamicTransform

_dynamicTransform: mat4

Protected _elide

_elide: Elide = Label.Elide.None
see

elide

Protected _ellipsis

_ellipsis: string = Label.DEFAULT_ELLIPSIS
see

ellipsis

Protected _extent

_extent: [number, number]
see

extent

Protected _fontFace

_fontFace: FontFace | undefined
see

fontFace

Protected _fontSize

_fontSize: number
see

fontSize

Protected _fontSizeUnit

_fontSizeUnit: Unit = Label.Unit.World

Protected _lineAnchor

_lineAnchor: LineAnchor = Label.LineAnchor.Baseline

Protected _lineWidth

_lineWidth: number = NaN
see

lineWidth

Protected _position

_position: vec3
see

position

Protected _staticTransform

_staticTransform: mat4
see

{@link transform}

Protected _text

_text: Text
see

text

Protected _type

_type: Type
see

type

Protected _wrap

_wrap: boolean = false
see

wrap

Static Private DEFAULT_FONTSIZE_PX

DEFAULT_FONTSIZE_PX: 20 = 20

Accessors

alignment

altered

  • get altered(): boolean

backgroundColor

  • get backgroundColor(): Color
  • set backgroundColor(color: Color): void

camera

  • get camera(): Camera | undefined
  • set camera(camera: Camera | undefined): void
  • The camera is used to retrieve (1) the view projection matrix, and (2) the width and height of targeted frame. (1) is used to project the 3D label as a 2D label, (2) is used to calculate the font size in px units. Setting the camera invalidates the transform.

    Returns Camera | undefined

  • The camera is used to retrieve (1) the view projection matrix, and (2) the width and height of targeted frame. (1) is used to project the 3D label as a 2D label, (2) is used to calculate the font size in px units. Setting the camera invalidates the transform.

    Parameters

    Returns void

color

  • get color(): Color
  • set color(color: Color): void

direction

  • get direction(): vec2 | GLfloat2
  • set direction(direction: vec2 | GLfloat2): void

dynamicTransform

  • get dynamicTransform(): mat4
  • set dynamicTransform(t: mat4): void
  • Stores the resulting dynamic transform. This is intended to be used when in dynamic mode. (e.g., for calculations to the final transform).

    Returns mat4

  • Stores the resulting dynamic transform. This is intended to be used when in dynamic mode. (e.g., for calculations to the final transform).

    Parameters

    • t: mat4

    Returns void

elide

  • get elide(): Elide
  • set elide(elide: Elide): void
  • If enabled, shrinks the label to line width. Depending on the elide mode, the ellipses is put left, middle, or right. The ellipsis string can be adjusted (@see ellipsis). If the labels text does not exceed the line width no elide will be applied.

    Returns Elide

  • If enabled, shrinks the label to line width. Depending on the elide mode, the ellipses is put left, middle, or right. The ellipsis string can be adjusted (@see ellipsis). If the labels text does not exceed the line width no elide will be applied.

    Parameters

    Returns void

ellipsis

  • get ellipsis(): string
  • set ellipsis(ellipsis: string): void

extent

  • get extent(): [number, number]
  • set extent(e: [number, number]): void
  • Returns the width and height of the typset label. Both are zero if not typeset yet.

    Returns [number, number]

  • The typesetter sets this extent after typesetting and applying the transform.

    Parameters

    • e: [number, number]

    Returns void

fontFace

  • get fontFace(): FontFace | undefined
  • set fontFace(fontFace: FontFace | undefined): void
  • Font face used for typesetting, transformation, and rendering. To avoid unnecessary state changes when rendering, prefer to add labels of the same font face consecutively (since this specifies draw sequence and state change occurs whenever font face changes between two subsequent labels).

    Returns FontFace | undefined

  • Font face used for typesetting, transformation, and rendering. To avoid unnecessary state changes when rendering, prefer to add labels of the same font face consecutively (since this specifies draw sequence and state change occurs whenever font face changes between two subsequent labels).

    Parameters

    Returns void

fontSize

  • get fontSize(): number
  • set fontSize(size: number): void

fontSizeUnit

  • get fontSizeUnit(): Unit
  • set fontSizeUnit(unit: Unit): void

length

  • get length(): number

lineAnchor

lineFeed

  • get lineFeed(): string

lineWidth

  • get lineWidth(): number
  • set lineWidth(lineWidth: number): void
  • Width of a single line in typesetting space (the unit used while Typesetting, i.e., the unit as the font face's glyph texture atlas). Since the font face needs to be defined in order to typeset, we assume here that the label has a defined fontFace.

    Returns number

  • Line width used to either maximum length for elide or maximum length for line breaks due to word wrap. The line width is expected in font size.

    Parameters

    • lineWidth: number

    Returns void

position

staticTransform

  • get staticTransform(): mat4
  • set staticTransform(transform: mat4): void
  • Transformation used to move, scale, rotate, skew, etc. the label into an arbitrary coordinate space (e.g., screen space, world space, ...). This can be set either explicitly or implicitly using various transformation utility functions. @todo review/refine this.

    Returns mat4

  • Transformation used to move, scale, rotate, skew, etc. the label into an arbitrary coordinate space (e.g., screen space, world space, ...). This can be set either explicitly or implicitly using various transformation utility functions. @todo review/refine this.

    Parameters

    • transform: mat4

    Returns void

text

  • get text(): Text
  • set text(text: Text): void

type

  • Read-only access to this labels type specified at construction time. Static labels are baking as much transformations as possible into the glyph vertices (used for GPU). This means, when the position or size changes, the label must be typeset again and vertices are fully re-computed. For dynamic labels, only most relevant transformations are applied and dynamic transformations such as rotation, translation, scale etc, are applied during rendering without requiring re-typesetting or re-computation of vertices. The type, however, does not relate to the text. Whenever the text changes, re-typesetting etc. have to be invoked.

    Returns Type

valid

  • get valid(): boolean
  • Returns whether or not this label is ready to be rendered (aka has a font face with valid texture as well as a text with a length > 0).

    Returns boolean

wrap

  • get wrap(): boolean
  • set wrap(flag: boolean): void
  • If enabled, breaks lines automatically at line width (while typesetting). Note that elide mode takes precedence.

    Returns boolean

  • If enabled, breaks lines automatically at line width (while typesetting). Note that elide mode takes precedence.

    Parameters

    • flag: boolean

    Returns void

Methods

advance

  • advance(index: number): number
  • Returns the advancement of the glyph at given index.

    Parameters

    • index: number

      The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.

    Returns number

    • advancement of the glyph at given index or NaN

charAt

  • charAt(index: number): string
  • Returns the character at the specified index.

    Parameters

    • index: number

      The zero-based index of the desired character.

    Returns string

    character at the specified index

charCodeAt

  • charCodeAt(index: number): number
  • Returns the Unicode value (codepoint) of the character at the specified location.

    Parameters

    • index: number

      The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.

    Returns number

    • codepoint of the char at given index or NaN

kerningAfter

  • kerningAfter(index: number): number
  • Gets the kerning value after (i.e., right in left-to-right writing systems) the given glyph index.

    Parameters

    • index: number

      index of the glyph in this label

    Returns number

    • kerning value after glyph at given index

kerningBefore

  • kerningBefore(index: number): number
  • Gets the kerning value before (i.e., left in left-to-right writing systems) the given glyph index.

    Parameters

    • index: number

      index of the glyph in this label

    Returns number

    • kerning value before glyph at given index

lineFeedAt

  • lineFeedAt(index: number): boolean
  • Returns, whether or not the character at a given index is equal to the default or the text's line feed character.

    Parameters

    • index: number

      The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.

    Returns boolean

    • true if char at given index equals the text's line feed character

reset

  • reset(): void

toString

  • toString(): string
  • Convenience getter to the label's text as string.

    Returns string

    the label's text as string

typeset

  • If altered, creates a position and direction-vector, then prepares the vertex storage and invokes typesetting. Depending on the label's type (static or dynamic) the transform is stored and applied either during typesetting (static) or passed as single transform to the vertex shader during rendering (dynamic).

    Parameters

    • Default value force: boolean = false

    Returns GlyphVertices | undefined

Protected vertices

Static devicePixelRatio

  • devicePixelRatio(): number