/** * A base WebGL Batcher object that manages shader programs, vertex attribute * definitions, and vertex buffer batching for efficient GPU draw calls. * @category Rendering */ export class Batcher { /** * @param {WebGLRenderer} renderer - the current WebGL renderer session * @param {object} settings - additional settings to initialize this batcher * @param {object[]} settings.attributes - an array of attributes definition * @param {string} settings.attributes.name - name of the attribute in the vertex shader * @param {number} settings.attributes.size - number of components per vertex attribute. Must be 1, 2, 3, or 4. * @param {GLenum} settings.attributes.type - data type of each component in the array * @param {boolean} settings.attributes.normalized - whether integer data values should be normalized into a certain range when being cast to a float * @param {number} settings.attributes.offset - offset in bytes of the first component in the vertex attribute array * @param {object} settings.shader - shader definition * @param {string} settings.shader.vertex - a string containing the GLSL source code to set * @param {string} settings.shader.fragment - a string containing the GLSL source code to set * @param {number} [settings.maxVertices=4096] - the maximum number of vertices this batcher can hold * @param {boolean} [settings.indexed=false] - whether this batcher uses an index buffer for indexed drawing (drawElements) * @param {string} [settings.projectionUniform="uProjectionMatrix"] - the name of the projection matrix uniform in the shader */ constructor(renderer: WebGLRenderer, settings: { attributes: { name: string; size: number; type: GLenum; normalized: boolean; offset: number; }; shader: { vertex: string; fragment: string; }; maxVertices?: number | undefined; indexed?: boolean | undefined; projectionUniform?: string | undefined; }); /** * Initialize the batcher * @ignore */ init(renderer: any, settings: any): void; renderer: any; gl: any; viewMatrix: any; /** * the default shader created by this batcher * @type {GLShader} */ defaultShader: GLShader | undefined; /** * the shader currently used by this batcher * @type {GLShader} */ currentShader: GLShader | undefined; /** * primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES) * @type {number} * @default gl.TRIANGLES */ mode: number | undefined; /** * an array of vertex attribute properties * @see Batcher.addAttribute * @type {Array.} */ attributes: Object[] | undefined; /** * the stride of a single vertex in bytes * (will automatically be calculated as attributes definitions are added) * @see Batcher.addAttribute * @type {number} */ stride: number | undefined; /** * the size of a single vertex in floats * (will automatically be calculated as attributes definitions are added) * @see Batcher.addAttribute * @type {number} */ vertexSize: number | undefined; /** * the vertex data buffer used by this batcher * @type {VertexArrayBuffer} */ vertexData: VertexArrayBuffer | undefined; /** * the name of the projection matrix uniform in the shader * @type {string} */ projectionUniform: string | undefined; /** * whether this batcher uses indexed drawing * @type {boolean} */ useIndexBuffer: boolean | undefined; /** * the GL vertex buffer object (own buffer for indexed batchers, null for shared) * @type {WebGLBuffer|null} * @ignore */ glVertexBuffer: WebGLBuffer | null | undefined; /** * the dynamic index buffer (only for indexed batchers) * @type {IndexBuffer|null} * @ignore */ indexBuffer: IndexBuffer | null | undefined; /** * Reset batcher internal state * @ignore */ reset(): void; /** * called by the WebGL renderer when a batcher becomes the current one */ bind(): void; /** * Select the shader to use for compositing * @see GLShader * @param {GLShader} shader - a reference to a GLShader instance */ useShader(shader: GLShader): void; currentSamplerUnit: number | undefined; /** * add vertex attribute property definition to the batcher * @param {string} name - name of the attribute in the vertex shader * @param {number} size - number of components per vertex attribute. Must be 1, 2, 3, or 4. * @param {GLenum} type - data type of each component in the array * @param {boolean} normalized - whether integer data values should be normalized into a certain range when being cast to a float * @param {number} offset - offset in bytes of the first component in the vertex attribute array */ addAttribute(name: string, size: number, type: GLenum, normalized: boolean, offset: number): void; /** * set/change the current projection matrix * @param {Matrix3d} matrix - the new projection matrix */ setProjection(matrix: Matrix3d): void; /** * Add index values to the index buffer (only for indexed batchers). * Indices are rebased relative to the current vertex count. * @param {number[]} indices - array of index values to add */ addIndices(indices: number[]): void; /** * Flush batched vertex data to the GPU * @param {number} [mode=gl.TRIANGLES] - the GL drawing mode */ flush(mode?: number): void; } export default Batcher; import GLShader from "../glshader.js"; import VertexArrayBuffer from "../buffer/vertex.js"; import IndexBuffer from "../buffer/index.js"; import type { Matrix3d } from "../../../math/matrix3d.ts"; import type WebGLRenderer from "./../webgl_renderer.js"; //# sourceMappingURL=batcher.d.ts.map