Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LabelGeometry

Gathers vertices and other data needed for drawing all labels using the glyphquad-shaders.

Example usage:

const labelGeometry = new LabelGeometry(this._context);
labelGeometry = new LabelGeometry(this._context);
...
labelGeometry.initialize();

program.initialize([vert, frag], false);
program.attribute('a_vertex', labelGeometry.vertexLocation);
program.attribute('a_texCoord', labelGeometry.texCoordLocation);
program.attribute('a_origin', labelGeometry.originLocation);
program.attribute('a_tangent', labelGeometry.tangentLocation);
program.attribute('a_up', labelGeometry.upLocation);

program.link();
...
labelGeometry.update(origins, tangents, ups, texCoords);
...
labelGeometry.bind();
labelGeometry.draw();
labelGeometry.unbind();

Hierarchy

Index

Constructors

constructor

Properties

Protected _buffers

_buffers: Buffer[] = ...

Various buffers required for this geometry (e.g., vertex buffer).

Protected _numberOfGlyphs

_numberOfGlyphs: number = 0

Number of glyphs encoded within the geometry.

Protected _originLocation

_originLocation: number

Protected _origins

_origins: Buffer

Protected _tangentLocation

_tangentLocation: number

Protected _tangents

_tangents: Buffer

Protected _texCoordLocation

_texCoordLocation: number

Protected _texCoords

_texCoords: Buffer

Protected _upLocation

_upLocation: number

Protected _ups

_ups: Buffer

Protected _vertexArray

_vertexArray: VertexArray

Vertex array used for binding the rectangle's buffer(s).

Protected _vertexLocation

_vertexLocation: number

Protected _vertices

_vertices: Buffer

Handle to the glyph template this geometry is based on.

Protected assertInitialized

assertInitialized: () => void = ...

Asserts the objects initialization status to be true. Note that the implementation is cached and forwarded to either an empty function when initialized and to an acutal assert(false) otherwise.

Type declaration

    • (): void
    • Returns void

Protected assertUninitialized

assertUninitialized: () => void = ...

Asserts the objects initialization status to be false. Note that the implementation is cached and forwarded to either an empty function when uninitialized and to an acutal assert(false) otherwise.

Type declaration

    • (): void
    • Returns void

Static Protected Readonly VERTICES

VERTICES: Float32Array = ...

These 2D vertices are equal for all quads, used for instanced rendering. Their actual position will be changed in the vertex shader, based on origins, tangents and up-vector attributes. 2-------4 | \ | | \ | 1-------3

Accessors

buffers

context

initialized

  • get initialized(): boolean
  • Property getter for readonly access to the initialization status of an initializable instance.

    Returns boolean

numGlyphs

  • get numGlyphs(): number

originLocation

  • get originLocation(): number

tangentLocation

  • get tangentLocation(): number

texCoordLocation

  • get texCoordLocation(): number

upLocation

  • get upLocation(): number

valid

  • get valid(): boolean

vertexArray

vertexLocation

  • get vertexLocation(): number

Methods

bind

  • bind(): void

Protected bindBuffers

  • bindBuffers(): void

draw

  • draw(offset?: number, count?: number): void
  • Specifies/invokes the draw of specific labels (ranges are supposed to be tracked/managed from outside).

    Parameters

    • offset: number = 0
    • count: number = 0

    Returns void

initialize

  • initialize(vertexLocation?: number, texCoordLocation?: number, originLocation?: number, tangentLocation?: number, upLocation?: number): boolean
  • Creates the vertex buffer object (VBO) and creates and initializes the buffer's data store.

    Parameters

    • vertexLocation: number = 0

      Attribute binding point for vertices.

    • texCoordLocation: number = 1

      Attribute binding point for texture coordinates.

    • originLocation: number = 2

      Attribute binding point for glyph origin coordinates

    • tangentLocation: number = 3

      Attribute binding point for glyph tangent coordinates.

    • upLocation: number = 4

      Attribute binding point for glyph up-vector coordinates.

    Returns boolean

unbind

  • unbind(): void

Protected unbindBuffers

  • unbindBuffers(): void

uninitialize

  • uninitialize(): void

update

  • update(origins: Float32Array, tangents: Float32Array, up: Float32Array, texCoords: Float32Array): void
  • Use this method to set (or update) the glyph coordinates, e.g. after typesetting or after the calculations of a placement algorithm. The actual interpretation of those buffers depends on the shader, usually they are 3-component vectors in world space (provided as flat array.)

    Parameters

    • origins: Float32Array

      Coordinates of the lower left corner of every glyph.

    • tangents: Float32Array

      Tangent vector for every glyph (direction along base line).

    • up: Float32Array

      Up vector for every glyph (orthogonal to its tangent vector).

    • texCoords: Float32Array

      The texture coordinates for every glyph, format: ll.x, ll.y, ur.x, ur.y.

    Returns void

Static Protected Readonly assertInitializedFalse

Static Protected Readonly assertUninitializedFalse

Static assert_initialized

  • assert_initialized(): MethodDecorator

Static assert_uninitialized

  • assert_uninitialized(): MethodDecorator

Static discard

  • discard(): MethodDecorator
  • Method decorator for discarding of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be discarded, invokes its uninitialization, and falsifies the initialization status. In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to a static, always-failing assert and an empty/undefined function respectively.

    Returns MethodDecorator

Static initialize

  • initialize(): MethodDecorator
  • Method decorator for initialization of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be initialized, invokes its initialization with arbitrary number of parameters, and sets the initialization status to the initialization success (either false or true). In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to either a static, always-failing assert or an empty/undefined function.

    Returns MethodDecorator

Static uninitialize

  • uninitialize(): MethodDecorator
  • Method decorator for uninitialization of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be uninitialized, invokes its uninitialization, and falsifies the initialization status. In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to a static, always-failing assert and an empty/undefined function respectively.

    Returns MethodDecorator