VertexBuffer

Specialized buffer used to store vertex data

Hierarchy

  • VertexBuffer

Index

Constructors

constructor

Find examples in Playground
  • new VertexBuffer(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean): VertexBuffer
  • Constructor

    Parameters

    • engine: any

      the engine

    • data: DataArray | Buffer

      the data to use for this vertex buffer

    • kind: string

      the vertex buffer kind

    • updatable: boolean

      whether the data is updatable

    • Optional postponeInternalCreation: boolean

      whether to postpone creating the internal WebGL buffer (optional)

    • Optional stride: number

      the stride (optional)

    • Optional instanced: boolean

      whether the buffer is instanced (optional)

    • Optional offset: number

      the offset of the data (optional)

    • Optional size: number

      the number of components (optional)

    • Optional type: number

      the type of the component (optional)

    • Optional normalized: boolean

      whether the data contains normalized data (optional)

    • Optional useBytes: boolean

      set to true if stride and offset are in bytes (optional)

    Returns VertexBuffer

Properties

byteOffset

Find examples in Playground
byteOffset: number

Gets the byte offset.

byteStride

Find examples in Playground
byteStride: number

Gets the byte stride.

instanceDivisor

Find examples in Playground
instanceDivisor: number

Gets or sets the instance divisor when in instanced mode

normalized

Find examples in Playground
normalized: boolean

Gets whether integer data values should be normalized into a certain range when being casted to a float.

type

Find examples in Playground
type: number

Gets the data type of each component in the array.

Static BYTE

Find examples in Playground
BYTE: number

The byte type.

Static ColorKind

Find examples in Playground
ColorKind: string

Colors

Static FLOAT

Find examples in Playground
FLOAT: number

The float type.

Static INT

Find examples in Playground
INT: number

The integer type.

Static MatricesIndicesExtraKind

Find examples in Playground
MatricesIndicesExtraKind: string

Additional matrix indices (for bones)

Static MatricesIndicesKind

Find examples in Playground
MatricesIndicesKind: string

Matrix indices (for bones)

Static MatricesWeightsExtraKind

Find examples in Playground
MatricesWeightsExtraKind: string

Additional matrix weights (for bones)

Static MatricesWeightsKind

Find examples in Playground
MatricesWeightsKind: string

Matrix weights (for bones)

Static NormalKind

Find examples in Playground
NormalKind: string

Normals

Static PositionKind

Find examples in Playground
PositionKind: string

Positions

Static SHORT

Find examples in Playground
SHORT: number

The short type.

Static TangentKind

Find examples in Playground
TangentKind: string

Tangents

Static UNSIGNED_BYTE

Find examples in Playground
UNSIGNED_BYTE: number

The unsigned byte type.

Static UNSIGNED_INT

Find examples in Playground
UNSIGNED_INT: number

The unsigned integer type.

Static UNSIGNED_SHORT

Find examples in Playground
UNSIGNED_SHORT: number

The unsigned short type.

Static UV2Kind

Find examples in Playground
UV2Kind: string

Texture coordinates 2

Static UV3Kind

Find examples in Playground
UV3Kind: string

Texture coordinates 3

Static UV4Kind

Find examples in Playground
UV4Kind: string

Texture coordinates 4

Static UV5Kind

Find examples in Playground
UV5Kind: string

Texture coordinates 5

Static UV6Kind

Find examples in Playground
UV6Kind: string

Texture coordinates 6

Static UVKind

Find examples in Playground
UVKind: string

Texture coordinates

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

    • Optional data: DataArray

      defines the data to store

    Returns void

dispose

Find examples in Playground
  • dispose(): void
  • Disposes the VertexBuffer and the underlying WebGLBuffer.

    Returns void

forEach

Find examples in Playground
  • forEach(count: number, callback: function): void
  • Enumerates each value of this vertex buffer as numbers.

    Parameters

    • count: number

      the number of values to enumerate

    • callback: function

      the callback function called for each value

        • (value: number, index: number): void
        • Parameters

          • value: number
          • index: number

          Returns void

    Returns void

getBuffer

Find examples in Playground
  • Gets underlying native buffer

    Returns Nullable<WebGLBuffer>

    underlying native buffer

getData

Find examples in Playground

getInstanceDivisor

Find examples in Playground
  • getInstanceDivisor(): number
  • Returns the instancing divisor, zero for non-instanced (integer).

    Returns number

    a number

getIsInstanced

Find examples in Playground
  • getIsInstanced(): boolean
  • Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced

    Returns boolean

    true if this buffer is instanced

getKind

Find examples in Playground
  • getKind(): string
  • Returns the kind of the VertexBuffer (string)

    Returns string

    a string

getOffset

Find examples in Playground
  • getOffset(): number
  • Returns the offset as a multiple of the type byte length. DEPRECATED. Use byteOffset instead.

    Returns number

    the offset in bytes

getSize

Find examples in Playground
  • getSize(): number
  • Returns the number of components per vertex attribute (integer)

    Returns number

    the size in float

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. Use byteStride instead.

    Returns number

    the stride in float32 units

isUpdatable

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

    Returns boolean

    true if the buffer is updatable

update

Find examples in Playground
  • Updates the underlying buffer according to the passed numeric array or Float32Array. This function will create a new buffer if the current one is not updatable

    Parameters

    Returns void

updateDirectly

Find examples in Playground
  • updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void
  • Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array. Returns the directly updated WebGLBuffer.

    Parameters

    • data: DataArray

      the new data

    • offset: number

      the new offset

    • Optional useBytes: boolean

      set to true if the offset is in bytes

    Returns void

Static DeduceStride

Find examples in Playground
  • DeduceStride(kind: string): number
  • Deduces the stride given a kind.

    Parameters

    • kind: string

      The kind string to deduce

    Returns number

    The deduced stride

Static ForEach

Find examples in Playground
  • ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: function): void
  • Enumerates each value of the given parameters as numbers.

    Parameters

    • data: DataArray

      the data to enumerate

    • byteOffset: number

      the byte offset of the data

    • byteStride: number

      the byte stride of the data

    • componentCount: number

      the number of components per element

    • componentType: number

      the type of the component

    • count: number

      the total number of components

    • normalized: boolean

      whether the data is normalized

    • callback: function

      the callback function called for each value

        • (value: number, index: number): void
        • Parameters

          • value: number
          • index: number

          Returns void

    Returns void

Static GetTypeByteLength

Find examples in Playground
  • GetTypeByteLength(type: number): number
  • Gets the byte length of the given type.

    Parameters

    • type: number

      the type

    Returns number

    the number of bytes

Generated using TypeDoc