Options
All
  • Public
  • Public/Protected
  • All
Menu

Class VertexBuffer

Specialized buffer used to store vertex data

Hierarchy

  • VertexBuffer

Index

Constructors

constructor

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

    Parameters

    • engine: any

      the engine

    • data: DataArray | Buffer | DataBuffer

      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)

    • Optional divisor: number

      defines the instance divisor to use (1 by default)

    • Optional takeBufferOwnership: boolean

      defines if the buffer should be released when the vertex buffer is disposed

    Returns VertexBuffer

Properties

Readonly byteOffsetSearch playground for byteOffset

byteOffset: number

Gets the byte offset.

Readonly byteStrideSearch playground for byteStride

byteStride: number

Gets the byte stride.

Readonly hashCodeSearch playground for hashCode

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

Readonly normalizedSearch playground for normalized

normalized: boolean

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

Readonly typeSearch playground for type

type: number

Gets the data type of each component in the array.

Readonly uniqueIdSearch playground for uniqueId

uniqueId: number

Gets the unique id of this vertex buffer

Static Readonly BYTESearch playground for BYTE

BYTE: 5120 = 5120

The byte type.

Static Readonly ColorInstanceKindSearch playground for ColorInstanceKind

ColorInstanceKind: "instanceColor" = "instanceColor"

Instance Colors

Static Readonly ColorKindSearch playground for ColorKind

ColorKind: "color" = "color"

Colors

Static Readonly FLOATSearch playground for FLOAT

FLOAT: 5126 = 5126

The float type.

Static Readonly INTSearch playground for INT

INT: 5124 = 5124

The integer type.

Static Readonly MatricesIndicesExtraKindSearch playground for MatricesIndicesExtraKind

MatricesIndicesExtraKind: "matricesIndicesExtra" = "matricesIndicesExtra"

Additional matrix indices (for bones)

Static Readonly MatricesIndicesKindSearch playground for MatricesIndicesKind

MatricesIndicesKind: "matricesIndices" = "matricesIndices"

Matrix indices (for bones)

Static Readonly MatricesWeightsExtraKindSearch playground for MatricesWeightsExtraKind

MatricesWeightsExtraKind: "matricesWeightsExtra" = "matricesWeightsExtra"

Additional matrix weights (for bones)

Static Readonly MatricesWeightsKindSearch playground for MatricesWeightsKind

MatricesWeightsKind: "matricesWeights" = "matricesWeights"

Matrix weights (for bones)

Static Readonly NormalKindSearch playground for NormalKind

NormalKind: "normal" = "normal"

Normals

Static Readonly PositionKindSearch playground for PositionKind

PositionKind: "position" = "position"

Positions

Static Readonly SHORTSearch playground for SHORT

SHORT: 5122 = 5122

The short type.

Static Readonly TangentKindSearch playground for TangentKind

TangentKind: "tangent" = "tangent"

Tangents

Static Readonly UNSIGNED_BYTESearch playground for UNSIGNED_BYTE

UNSIGNED_BYTE: 5121 = 5121

The unsigned byte type.

Static Readonly UNSIGNED_INTSearch playground for UNSIGNED_INT

UNSIGNED_INT: 5125 = 5125

The unsigned integer type.

Static Readonly UNSIGNED_SHORTSearch playground for UNSIGNED_SHORT

UNSIGNED_SHORT: 5123 = 5123

The unsigned short type.

Static Readonly UV2KindSearch playground for UV2Kind

UV2Kind: "uv2" = "uv2"

Texture coordinates 2

Static Readonly UV3KindSearch playground for UV3Kind

UV3Kind: "uv3" = "uv3"

Texture coordinates 3

Static Readonly UV4KindSearch playground for UV4Kind

UV4Kind: "uv4" = "uv4"

Texture coordinates 4

Static Readonly UV5KindSearch playground for UV5Kind

UV5Kind: "uv5" = "uv5"

Texture coordinates 5

Static Readonly UV6KindSearch playground for UV6Kind

UV6Kind: "uv6" = "uv6"

Texture coordinates 6

Static Readonly UVKindSearch playground for UVKind

UVKind: "uv" = "uv"

Texture coordinates

Accessors

instanceDivisor

  • get instanceDivisor(): number
  • set instanceDivisor(value: number): any
  • Gets or sets the instance divisor when in instanced mode

    Returns number

  • Gets or sets the instance divisor when in instanced mode

    Parameters

    • value: number

    Returns any

Methods

createSearch playground for create

  • 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

disposeSearch playground for dispose

  • dispose(): void
  • Disposes the VertexBuffer and the underlying WebGLBuffer.

    Returns void

forEachSearch playground for forEach

  • forEach(count: number, callback: (value: number, index: number) => void): void
  • 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

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

          • value: number
          • index: number

          Returns void

    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

getFloatDataSearch playground for getFloatData

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

    • Optional forceCopy: boolean

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

    Returns Nullable<FloatArray>

    a float array containing vertex data

getInstanceDivisorSearch playground for getInstanceDivisor

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

    Returns number

    a number

getIsInstancedSearch playground for getIsInstanced

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

    Returns boolean

    true if this buffer is instanced

getKindSearch playground for getKind

  • getKind(): string
  • Returns the kind of the VertexBuffer (string)

    Returns string

    a string

getOffsetSearch playground for getOffset

  • getOffset(): number
  • Returns the offset as a multiple of the type byte length.

    deprecated

    Please use byteOffset instead.

    Returns number

    the offset in bytes

getSizeSearch playground for getSize

  • getSize(sizeInBytes?: boolean): number
  • Returns the number of components or the byte size per vertex attribute

    Parameters

    • Optional sizeInBytes: boolean

      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

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 VertexBuffer is updatable?

    Returns boolean

    true if the buffer is updatable

updateSearch playground for update

  • 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

updateDirectlySearch playground for updateDirectly

  • 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 DeduceStrideSearch playground for DeduceStride

  • DeduceStride(kind: string): number
  • Deduces the stride given a kind.

    Parameters

    • kind: string

      The kind string to deduce

    Returns number

    The deduced stride

Static ForEachSearch playground for ForEach

  • ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): 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 number of values to enumerate

    • normalized: boolean

      whether the data is normalized

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

      the callback function called for each value

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

          • value: number
          • index: number

          Returns void

    Returns void

Static GetTypeByteLengthSearch playground for GetTypeByteLength

  • GetTypeByteLength(type: number): number
  • Gets the byte length of the given type.

    Parameters

    • type: number

      the type

    Returns number

    the number of bytes

Legend

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