Options
All
  • Public
  • Public/Protected
  • All
Menu

Specialized buffer used to store vertex data

Hierarchy

  • VertexBuffer

Index

Constructors

  • new VertexBuffer(engine: ThinEngine, data: Buffer | DataArray | 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: ThinEngine

      the engine

    • data: Buffer | DataArray | 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

byteOffset: number

Gets the byte offset.

byteStride: number

Gets the byte stride.

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: 5120 = 5120

The byte type.

ColorInstanceKind: "instanceColor" = "instanceColor"

Instance Colors

ColorKind: "color" = "color"

Colors

FLOAT: 5126 = 5126

The float type.

INT: 5124 = 5124

The integer type.

MatricesIndicesExtraKind: "matricesIndicesExtra" = "matricesIndicesExtra"

Additional matrix indices (for bones)

MatricesIndicesKind: "matricesIndices" = "matricesIndices"

Matrix indices (for bones)

MatricesWeightsExtraKind: "matricesWeightsExtra" = "matricesWeightsExtra"

Additional matrix weights (for bones)

MatricesWeightsKind: "matricesWeights" = "matricesWeights"

Matrix weights (for bones)

NormalKind: "normal" = "normal"

Normals

PositionKind: "position" = "position"

Positions

SHORT: 5122 = 5122

The short type.

TangentKind: "tangent" = "tangent"

Tangents

UNSIGNED_BYTE: 5121 = 5121

The unsigned byte type.

UNSIGNED_INT: 5125 = 5125

The unsigned integer type.

UNSIGNED_SHORT: 5123 = 5123

The unsigned short type.

UV2Kind: "uv2" = "uv2"

Texture coordinates 2

UV3Kind: "uv3" = "uv3"

Texture coordinates 3

UV4Kind: "uv4" = "uv4"

Texture coordinates 4

UV5Kind: "uv5" = "uv5"

Texture coordinates 5

UV6Kind: "uv6" = "uv6"

Texture coordinates 6

UVKind: "uv" = "uv"

Texture coordinates

Accessors

  • get instanceDivisor(): number
  • set instanceDivisor(value: number): void
  • 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 void

  • get isDisposed(): boolean
  • Gets a boolean indicating if the Buffer is disposed

    Returns boolean

Methods

  • 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(): void
  • Disposes the VertexBuffer and the underlying WebGLBuffer.

    Returns void

  • 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

  • Gets underlying native buffer

    Returns Nullable<DataBuffer>

    underlying native buffer

  • Gets current buffer's data

    Returns Nullable<DataArray>

    a DataArray or null

  • 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

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

    Returns number

    a number

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

    Returns boolean

    true if this buffer is instanced

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

    Returns string

    a string

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

    deprecated

    Please use byteOffset instead.

    Returns number

    the offset in bytes

  • 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

  • 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(): boolean
  • Gets a boolean indicating if the VertexBuffer is updatable?

    Returns boolean

    true if the buffer is updatable

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

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

    Parameters

    • kind: string

      The kind string to deduce

    Returns number

    The deduced stride

  • 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

  • Gets the vertex buffer type of the given data array.

    Parameters

    Returns number

    the vertex buffer type

  • GetFloatData(data: DataArray, size: number, type: number, byteOffset: number, byteStride: number, normalized: boolean, totalVertices: number, forceCopy?: boolean): FloatArray
  • Gets the given data array as a float array. Float data is constructed if the data array cannot be returned directly.

    Parameters

    • data: DataArray

      the input data array

    • size: number

      the number of components

    • type: number

      the component type

    • byteOffset: number

      the byte offset of the data

    • byteStride: number

      the byte stride of the data

    • normalized: boolean

      whether the data is normalized

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

    a float array containing vertex data

  • 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
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Method
  • Static property
  • Static method

Settings

Theme