API

Class Buffer

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

Index
  • Constructor

    Parameters

    • engine: AbstractEngine

      the engine

    • data: DataArray | DataBuffer

      the data to use for this buffer

    • updatable: boolean

      whether the data is updatable

    • stride: number = 0

      the stride (optional)

    • postponeInternalCreation: boolean = false

      whether to postpone creating the internal WebGL buffer (optional)

    • instanced: boolean = false

      whether the buffer is instanced (optional)

    • useBytes: boolean = false

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

    • Optionaldivisor: number

      sets an optional divisor for instances (1 by default)

    • Optionallabel: string

      defines the label of the buffer (for debug purpose)

    Returns Buffer

byteStride: number

Gets the byte stride.

  • Create a new VertexBuffer based on the current buffer

    Parameters

    • 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)

    • Optionalstride: number

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

    • Optionalinstanced: boolean

      defines if the vertex buffer contains indexed data

    • useBytes: boolean = false

      defines if the offset and stride are in bytes *

    • Optionaldivisor: number

      sets an optional divisor for instances (1 by default)

    Returns VertexBuffer

    the new vertex buffer

  • 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.

    Returns number

    the stride in float32 units

    Please use byteStride instead.

  • Updates the data directly.

    Parameters

    • data: DataArray

      the new data

    • offset: number

      the new offset

    • OptionalvertexCount: number

      the vertex count (optional)

    • useBytes: boolean = false

      set to true if the offset is in bytes

    Returns void