API

Class VertexBuffer

Specialized buffer used to store vertex data

Index
byteOffset: number

Gets the byte offset.

byteStride: number

Gets the byte stride.

effectiveBuffer: Nullable<DataBuffer>

Gets the effective buffer, that is the buffer that is actually sent to the GPU. It could be different from VertexBuffer.getBuffer() if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.

effectiveByteOffset: number

Gets the effective byte offset, that is the byte offset of the buffer that is actually sent to the GPU. It could be different from VertexBuffer.byteOffset if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.

effectiveByteStride: number

Gets the effective byte stride, that is the byte stride of the buffer that is actually sent to the GPU. It could be different from VertexBuffer.byteStride if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.

Gets the engine associated with the buffer

hashCode: number

Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer All buffers with the same format will have the same hash code

normalized: boolean

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

type: number

Gets the data type of each component in the array.

uniqueId: number

Gets the unique id of this vertex buffer

BYTE: number = Constants.BYTE

The byte type.

ColorInstanceKind: string = Constants.ColorInstanceKind

Instance Colors

ColorKind: string = Constants.ColorKind

Colors

FLOAT: number = Constants.FLOAT

The float type.

HALF_FLOAT: number = Constants.HALF_FLOAT

The half float type. Note: supported as a vertex attribute type only on the WebGL and WebGPU engines, not on Babylon Native.

INT: number = Constants.INT

The integer type. Note: supported as a vertex attribute type only on the WebGL and WebGPU engines, not on Babylon Native.

MatricesIndicesExtraKind: string = Constants.MatricesIndicesExtraKind

Additional matrix indices (for bones)

MatricesIndicesKind: string = Constants.MatricesIndicesKind

Matrix indices (for bones)

MatricesWeightsExtraKind: string = Constants.MatricesWeightsExtraKind

Additional matrix weights (for bones)

MatricesWeightsKind: string = Constants.MatricesWeightsKind

Matrix weights (for bones)

NormalKind: string = Constants.NormalKind

Normals

PositionKind: string = Constants.PositionKind

Positions

SHORT: number = Constants.SHORT

The short type.

TangentKind: string = Constants.TangentKind

Tangents

UNSIGNED_BYTE: number = Constants.UNSIGNED_BYTE

The unsigned byte type.

UNSIGNED_INT: number = Constants.UNSIGNED_INT

The unsigned integer type. Note: supported as a vertex attribute type only on the WebGL and WebGPU engines, not on Babylon Native.

UNSIGNED_SHORT: number = Constants.UNSIGNED_SHORT

The unsigned short type.

UV2Kind: string = Constants.UV2Kind

Texture coordinates 2

UV3Kind: string = Constants.UV3Kind

Texture coordinates 3

UV4Kind: string = Constants.UV4Kind

Texture coordinates 4

UV5Kind: string = Constants.UV5Kind

Texture coordinates 5

UV6Kind: string = Constants.UV6Kind

Texture coordinates 6

UVKind: string = Constants.UVKind

Texture coordinates

  • Enumerates each value of this vertex buffer as numbers.

    Parameters

    • count: number

      the number of values to enumerate

    • callback: (value: number, index: number) => void

      the callback function called for each value

    Returns void

  • Gets this vertex buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.

    Parameters

    • totalVertices: number

      number of vertices in the buffer to take into account

    • OptionalforceCopy: boolean

      defines a boolean indicating that the returned array must be cloned upon returning it

    Returns Nullable<FloatArray>

    a float array containing vertex data

  • Returns the number of components or the byte size per vertex attribute

    Parameters

    • sizeInBytes: boolean = false

      If true, returns the size in bytes or else the size in number of components of the vertex attribute (default: false)

    Returns number

    the number of components

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

    • useBytes: boolean = false

      set to true if the offset is in bytes

    Returns void