Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Buffer

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

Hierarchy

  • Buffer

Index

Constructors

constructor

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

    Parameters

    • 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

Properties

Readonly byteStrideSearch playground for byteStride

byteStride: number

Gets the byte stride.

Methods

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.

    Parameters

    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

    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

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.

    deprecated

    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

    Parameters

    Returns void

updateDirectlySearch playground for updateDirectly

  • 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

Legend

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