import { Buffer } from '../buffer'; import { Context } from '../context'; import { Geometry } from '../geometry'; /** * 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(); * ``` */ export declare class LabelGeometry extends Geometry { /** * 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 */ protected static readonly VERTICES: Float32Array; /** * Handle to the glyph template this geometry is based on. */ protected _vertices: Buffer; protected _texCoords: Buffer; protected _origins: Buffer; protected _tangents: Buffer; protected _ups: Buffer; /** * Number of glyphs encoded within the geometry. */ protected _numberOfGlyphs: number; protected _vertexLocation: GLuint; protected _texCoordLocation: GLuint; protected _originLocation: GLuint; protected _tangentLocation: GLuint; protected _upLocation: GLuint; /** * Object constructor, requires a context and an identifier. * @param context - Valid context to create the object for. * @param identifier - Meaningful name for identification of this instance. */ constructor(context: Context, identifier?: string); /** * Binds all vertex buffer objects (VBOs) to pre-set attribute binding points. * @param indices - Unused, since pre-set locations are used. */ protected bindBuffers(): void; /** * Unbinds all vertex buffer objects (VBOs) and disables their attribute binding points. * @param indices - Unused, since pre-set locations are used. */ protected unbindBuffers(): void; /** * Creates the vertex buffer object (VBO) and creates and initializes the buffer's data store. * @param vertexLocation - Attribute binding point for vertices. * @param texCoordLocation - Attribute binding point for texture coordinates. * @param originLocation - Attribute binding point for glyph origin coordinates * @param tangentLocation - Attribute binding point for glyph tangent coordinates. * @param upLocation - Attribute binding point for glyph up-vector coordinates. */ initialize(vertexLocation?: GLuint, texCoordLocation?: GLuint, originLocation?: GLuint, tangentLocation?: GLuint, upLocation?: GLuint): boolean; /** * 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.) * @param origins - Coordinates of the lower left corner of every glyph. * @param tangents - Tangent vector for every glyph (direction along base line). * @param up - Up vector for every glyph (orthogonal to its tangent vector). * @param texCoords - The texture coordinates for every glyph, format: ll.x, ll.y, ur.x, ur.y. */ update(origins: Float32Array, tangents: Float32Array, up: Float32Array, texCoords: Float32Array): void; /** * Specifies/invokes the draw of specific labels (ranges are supposed to be tracked/managed from outside). */ draw(offset?: GLint, count?: GLint): void; get numGlyphs(): number; get valid(): boolean; /** * Attribute location to which this geometry's vertices are bound to. */ get vertexLocation(): GLint; /** * Attribute location to which this geometry's texture coordinates are bound to. */ get texCoordLocation(): GLint; /** * Attribute location to which this geometry's origins are bound to. */ get originLocation(): GLint; /** * Attribute location to which this geometry's tangents are bound to. */ get tangentLocation(): GLint; /** * Attribute location to which this geometry's up vectors are bound to. */ get upLocation(): GLint; }