rapid-render
    Preparing search index...

    Class WebglBufferArray

    A specialized dynamic buffer intended for WebGL operations.

    Hierarchy (View Summary)

    Index

    Constructors

    • Initializes a new WebGL dynamic buffer.

      Parameters

      • gl: WebGL2RenderingContext

        The active WebGL rendering context state.

      • arrayType: ArrayType

        Type of the underlying data elements to bind.

      • type: number = gl.ARRAY_BUFFER

        Determines the type of WebGLBuffer (defaults to gl.ARRAY_BUFFER).

      • usage: number = gl.DYNAMIC_DRAW

        Determines the data usage pattern (defaults to gl.DYNAMIC_DRAW).

      Returns WebglBufferArray

    Properties

    buffer: WebGLBuffer

    The actual WebGLBuffer object maintained by this instance.

    bytePerElem: number

    The number of bytes per element based on the ArrayType.

    dirty: boolean = true

    Signifies whether the buffer has been updated and requires resyncing to the GPU.

    float32?: Float32Array<ArrayBufferLike>

    Float32Array view of the underlying memory buffer.

    gl: WebGL2RenderingContext

    The related WebGL rendering context.

    maxElemNum: number

    The maximum number of elements the buffer can currently hold without resizing.

    type: number

    The WebGL buffer type, e.g., gl.ARRAY_BUFFER.

    typedArray:
        | Float32Array<ArrayBufferLike>
        | Uint32Array<ArrayBufferLike>
        | Uint16Array<ArrayBufferLike>

    The main typed array view corresponding to the specified ArrayType.

    uint16?: Uint16Array<ArrayBufferLike>

    Uint16Array view of the underlying memory buffer.

    uint32?: Uint32Array<ArrayBufferLike>

    Uint32Array view of the underlying memory buffer.

    usage: number

    Usage hint for WebGL, e.g., gl.DYNAMIC_DRAW.

    usedElemNum: number

    The number of elements currently used in the buffer.

    Accessors

    • get length(): number

      The number of elements currently stored in the buffer.

      Returns number

    Methods

    • Binds this buffer object tracking it as the current bound buffer to the GPU.

      Returns void

    • Uploads the local buffer data to the GPU memory synchronously.

      Returns void

    • Gets the value of the element at the specified index.

      Parameters

      • index: number

        The index of the element to retrieve.

      Returns number

      The requested element.

    • Returns a constrained view of the primary typed array up to the specified range. If end is omitted, returns the whole reallocated buffer slice.

      Parameters

      • begin: number = 0

        The starting index (inclusive). Defaults to 0.

      • Optionalend: number

        The ending index (exclusive). Optional.

      Returns
          | Float32Array<ArrayBufferLike>
          | Uint32Array<ArrayBufferLike>
          | Uint16Array<ArrayBufferLike>

      A subarray corresponding to the specified range.

    • Returns the typed array constructor for the corresponding ArrayType.

      Parameters

      Returns TypedArrayConstructor

      The typed array constructor.

      Dispatches an error if the specified type is unsupported.

    • Flags the buffer as dirty, marking it for future data synchronization.

      Returns void

    • Removes and returns the last element in the buffer.

      Returns number

      The removed element or undefined if the buffer is empty.

    • Appends an element to the buffer, using the primary typed array view.

      Parameters

      • value: number

        The item to add.

      Returns void

    • Appends a new 32-bit floating point element to the buffer.

      Parameters

      • value: number

        The item to add.

      Returns void

    • Appends a new 32-bit unsigned integer element to the buffer.

      Parameters

      • value: number

        The item to add.

      Returns void

    • Checks if the buffer has enough space for additional elements and resizes the buffer if necessary.

      Parameters

      • size: number = 0

        The number of new elements that need to be accommodated.

      Returns boolean

      true if the buffer was resized, false otherwise.

    • Reallocates the underlying array buffer to a new size and copies existing data.

      Parameters

      • size: number = ...

        The new maximum number of elements.

      Returns void

    • Returns the last element pushed to the buffer without removing it.

      Returns number

      The last element.