Class PrimitiveCompositor

A WebGL Compositor object. This class handles all of the WebGL state
Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU

Hierarchy (view full)

Constructors

  • Parameters

    • renderer: WebGLRenderer

      the current WebGL renderer session

    • settings: {
          attribute: {
              name: string;
              normalized: boolean;
              offset: number;
              size: number;
              type: number;
          }[];
          shader: {
              fragment: string;
              vertex: string;
          };
      }

      additional settings to initialize this compositors

      • attribute: {
            name: string;
            normalized: boolean;
            offset: number;
            size: number;
            type: number;
        }[]

        an array of attributes definition

      • shader: {
            fragment: string;
            vertex: string;
        }

        an array of attributes definition

        • fragment: string
        • vertex: string

    Returns PrimitiveCompositor

Properties

attributes: undefined | Object[]

an array of vertex attribute properties

WebGLCompositor.addAttribute

color: any
currentShader: undefined | GLShader

the shader currently used by this compositor

defaultShader: undefined | GLShader

the default shader created by this compositor

gl: any
mode: undefined | number

primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)

gl.TRIANGLES
renderer: any
vertexByteSize: undefined | number

the size of a single vertex in bytes (will automatically be calculated as attributes definitions are added)

WebGLCompositor.addAttribute

vertexData: undefined | VertexArrayBuffer

the vertex data buffer used by this compositor

vertexSize: undefined | number

the size of a single vertex in floats (will automatically be calculated as attributes definitions are added)

WebGLCompositor.addAttribute

viewMatrix: any

Methods

  • add vertex attribute property definition to the compositor

    Parameters

    • name: string

      name of the attribute in the vertex shader

    • size: number

      number of components per vertex attribute. Must be 1, 2, 3, or 4.

    • type: number

      data type of each component in the array

    • normalized: boolean

      whether integer data values should be normalized into a certain range when being cast to a float

    • offset: number

      offset in bytes of the first component in the vertex attribute array

    Returns void

  • Draw an array of vertices

    Parameters

    • mode: number

      primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)

    • verts: Point[]

      an array of vertices

    • OptionalvertexCount: number = verts.length

      amount of points defined in the points array

    Returns void