/* spellchecker: disable */ import { mat4 } from 'gl-matrix'; import { assert } from '../auxiliaries'; import { GLfloat2, GLsizei2 } from '../tuples'; import { Camera } from '../camera'; import { ChangeLookup } from '../changelookup'; import { Context } from '../context'; import { Framebuffer } from '../framebuffer'; import { Initializable } from '../initializable'; import { Program } from '../program'; import { Shader } from '../shader'; import { Texture2D } from '../texture2d'; import { GlyphVertices } from './glyphvertices'; import { Color } from '../color'; import { FontFace } from './fontface'; import { Label } from './label'; import { LabelGeometry } from './labelgeometry'; import { Position2DLabel } from './position2dlabel'; import { Position3DLabel } from './position3dlabel'; import { Projected3DLabel } from './projected3dlabel'; /* spellchecker: enable */ /** * This class allows rendering of multiple dynamic as well as static labels. While preparing for frame, all label * geometry is packed into single buffers for the GPU and drawing is done with as few draw calls as possible. The * preparation tries to reduce state changes when labels of same color and same font are provided consecutively. * It might be beneficial to not render labels of large static texts and some often changing dynamic texts using the * same label render pass object. Often changing texts should be out into separate passed for better performance. */ export class LabelRenderPass extends Initializable { /** * Default AA step scale: more crisp text rendering (the value is optimized for multi-frame sampling). */ protected static readonly DEFAULT_AA_STEP_SCALE: GLfloat = 0.6666; /** * Alterable auxiliary object for tracking changes on render pass inputs and lazy updates. */ protected readonly _altered = Object.assign(new ChangeLookup(), { any: false, camera: false, geometry: false, labels: false, aaStepScale: false, aaSampling: false, }); /** * Context, used to get context information and WebGL API access. */ protected _context: Context; /** @see {@link target} */ protected _target: Framebuffer; /** @see {@link camera} */ protected _camera: Camera; /** @see {@link ndcOffset} */ protected _ndcOffset: GLfloat2 = [0.0, 0.0]; /** @see {@link depthMask} */ protected _depthMask = false; /** @see {@link depthFunc} */ protected _depthFunc: GLenum; /** @see {@link aaStepScale} */ protected _aaStepScale: GLfloat; /** @see {@link aaSampling} */ protected _aaSampling: LabelRenderPass.Sampling = LabelRenderPass.Sampling.Smooth1; protected _program: Program; protected _uViewProjection: WebGLUniformLocation | undefined; protected _uNdcOffset: WebGLUniformLocation | undefined; protected _uColor: WebGLUniformLocation | undefined; protected _uAAStepScale: WebGLUniformLocation | undefined; protected _uTransform: WebGLUniformLocation | undefined; protected _uDynamic: WebGLUniformLocation | undefined; protected _uAASampling: WebGLUniformLocation | undefined; protected _labels = new Array