Buffer

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

Hierarchy

  • Buffer

Index

Constructors

constructor

Find examples in Playground
  • new Buffer(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number): Buffer
  • Constructor

    Parameters

    • engine: any

      the engine

    • data: DataArray

      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

Properties

byteStride

Find examples in Playground
byteStride: number

Gets the byte stride.

Methods

create

Find examples in Playground
  • Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property

    Parameters

    Returns void

createVertexBuffer

Find examples in Playground
  • 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

    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)

    • 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

dispose

Find examples in Playground
  • dispose(): void
  • Release all resources

    Returns void

getBuffer

Find examples in Playground

getData

Find examples in Playground

getStrideSize

Find examples in Playground
  • 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.

    deprecated

    Please use byteStride instead.

    Returns number

    the stride in float32 units

isUpdatable

Find examples in Playground
  • isUpdatable(): boolean
  • Gets a boolean indicating if the Buffer is updatable?

    Returns boolean

    true if the buffer is updatable

update

Find examples in Playground
  • Update current buffer data

    Parameters

    Returns void

updateDirectly

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

    Parameters

    • 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

Generated using TypeDoc