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

Implements

Index

Constructors

constructor

Properties

Protected _buffers

_buffers: Buffer[] = new Array<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: GLuint

Protected _origins

_origins: Buffer

Protected _tangentLocation

_tangentLocation: GLuint

Protected _tangents

_tangents: Buffer

Protected _texCoordLocation

_texCoordLocation: GLuint

Protected _texCoords

_texCoords: Buffer

Protected _upLocation

_upLocation: GLuint

Protected _ups

_ups: Buffer

Protected _vertexArray

_vertexArray: VertexArray

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

Protected _vertexLocation

_vertexLocation: GLuint

Protected _vertices

_vertices: Buffer

Handle to the glyph template this geometry is based on.

Static Protected VERTICES

VERTICES: Float32Array = new Float32Array([0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0])

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

  • get buffers(): Array<Buffer>

context

initialized

  • get initialized(): boolean

numberOfGlyphs

  • get numberOfGlyphs(): number

originLocation

  • get originLocation(): GLint

tangentLocation

  • get tangentLocation(): GLint

texCoordLocation

  • get texCoordLocation(): GLint
  • Attribute location to which this geometry's texture coordinates are bound to.

    Returns GLint

upLocation

  • get upLocation(): GLint

valid

  • get valid(): boolean

vertexArray

vertexLocation

  • get vertexLocation(): GLint

Methods

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.

    Returns void

Protected assertUninitialized

  • assertUninitialized(): undefined
  • 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.

    Returns undefined

bind

  • bind(): void

Protected bindBuffers

  • bindBuffers(): void

draw

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

    Parameters

    • Default value offset: GLint = 0
    • Default value count: GLint = 0

    Returns void

initialize

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

    Parameters

    • Default value vertexLocation: GLuint = 0

      Attribute binding point for vertices.

    • Default value texCoordLocation: GLuint = 1

      Attribute binding point for texture coordinates.

    • Default value originLocation: GLuint = 2

      Attribute binding point for glyph origin coordinates

    • Default value tangentLocation: GLuint = 3

      Attribute binding point for glyph tangent coordinates.

    • Default value upLocation: GLuint = 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 assertInitializedFalse

Static Protected assertUninitializedFalse

Static assert_initialized

Static assert_uninitialized

Static initialize

  • 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

  • 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