• Public
  • Public/Protected
  • All

Class Buffer

Class used to store data that will be store in GPU memory


  • Buffer




  • new Buffer(engine: any, data: DataArray | DataBuffer, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number): Buffer
  • Constructor


    • engine: any

      the engine

    • data: DataArray | DataBuffer

      the data to use for this buffer

    • updatable: boolean

      whether the data is updatable

    • Optional stride: number

      the stride (optional)

    • Optional postponeInternalCreation: boolean

      whether to postpone creating the internal WebGL buffer (optional)

    • Optional instanced: boolean

      whether the buffer is instanced (optional)

    • Optional useBytes: boolean

      set to true if the stride in in bytes (optional)

    • Optional divisor: number

      sets an optional divisor for instances (1 by default)

    Returns Buffer


Readonly byteStrideSearch playground for byteStride

byteStride: number

Gets the byte stride.


createSearch playground for create

  • Store data into the buffer. Creates the buffer if not used already. If the buffer was already used, it will be updated only if it is updatable, otherwise it will do nothing.


    Returns void

createVertexBufferSearch playground for createVertexBuffer

  • createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer
  • Create a new VertexBuffer based on the current buffer


    • kind: string

      defines the vertex buffer kind (position, normal, etc.)

    • offset: number

      defines offset in the buffer (0 by default)

    • size: number

      defines the size in floats of attributes (position is 3 for instance)

    • Optional stride: number

      defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)

    • Optional instanced: boolean

      defines if the vertex buffer contains indexed data

    • Optional useBytes: boolean

      defines if the offset and stride are in bytes *

    • Optional divisor: number

      sets an optional divisor for instances (1 by default)

    Returns VertexBuffer

    the new vertex buffer

disposeSearch playground for dispose

  • dispose(): void
  • Release all resources

    Returns void

getBufferSearch playground for getBuffer

  • Gets underlying native buffer

    Returns Nullable<DataBuffer>

    underlying native buffer

getDataSearch playground for getData

  • Gets current buffer's data

    Returns Nullable<DataArray>

    a DataArray or null

getStrideSizeSearch playground for getStrideSize

  • getStrideSize(): number
  • Gets the stride in float32 units (i.e. byte stride / 4). May not be an integer if the byte stride is not divisible by 4.


    Please use byteStride instead.

    Returns number

    the stride in float32 units

isUpdatableSearch playground for isUpdatable

  • isUpdatable(): boolean
  • Gets a boolean indicating if the Buffer is updatable?

    Returns boolean

    true if the buffer is updatable

updateSearch playground for update

  • Update current buffer data


    Returns void

updateDirectlySearch playground for updateDirectly

  • updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void
  • Updates the data directly.


    • data: DataArray

      the new data

    • offset: number

      the new offset

    • Optional vertexCount: number

      the vertex count (optional)

    • Optional useBytes: boolean

      set to true if the offset is in bytes

    Returns void


  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method