Class VertexBuffer
Hierarchy
- VertexBuffer
Index
Constructors
Properties
- byte
Offset - byte
Stride - effective
Buffer - effective
Byte Offset - effective
Byte Stride - engine
- hash
Code - normalized
- type
- unique
Id - BYTE
- Color
Instance Kind - Color
Kind - FLOAT
- INT
- Matrices
Indices Extra Kind - Matrices
Indices Kind - Matrices
Weights Extra Kind - Matrices
Weights Kind - Normal
Kind - Position
Kind - SHORT
- Tangent
Kind - UNSIGNED_
BYTE - UNSIGNED_
INT - UNSIGNED_
SHORT - UV2
Kind - UV3
Kind - UV4
Kind - UV5
Kind - UV6
Kind - UVKind
Accessors
Methods
Constructors
constructor
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
Constructor
Parameters
engine: ThinEngine
the engine
data: Buffer | DataArray | DataBuffer
the data to use for this vertex buffer
kind: string
the vertex buffer kind
Optional options: IVertexBufferOptions
defines the rest of the options used to create the buffer
Returns VertexBuffer
Properties
Readonly byte OffsetSearch playground for byteOffset
Gets the byte offset.
Readonly byte StrideSearch playground for byteStride
Gets the byte stride.
effective BufferSearch playground for effectiveBuffer
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 forceVertexBufferStrideMultiple4Bytes engine flag.
effective Byte OffsetSearch playground for effectiveByteOffset
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 forceVertexBufferStrideMultiple4Bytes engine flag.
effective Byte StrideSearch playground for effectiveByteStride
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 forceVertexBufferStrideMultiple4Bytes engine flag.
Readonly engineSearch playground for engine
Gets the engine associated with the buffer
Readonly hash CodeSearch playground for hashCode
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
Gets whether integer data values should be normalized into a certain range when being casted to a float.
Readonly typeSearch playground for type
Gets the data type of each component in the array.
Readonly unique IdSearch playground for uniqueId
Gets the unique id of this vertex buffer
Static Readonly BYTESearch playground for BYTE
The byte type.
Static Readonly Color Instance KindSearch playground for ColorInstanceKind
Instance Colors
Static Readonly Color KindSearch playground for ColorKind
Colors
Static Readonly FLOATSearch playground for FLOAT
The float type.
Static Readonly INTSearch playground for INT
The integer type.
Static Readonly Matrices Indices Extra KindSearch playground for MatricesIndicesExtraKind
Additional matrix indices (for bones)
Static Readonly Matrices Indices KindSearch playground for MatricesIndicesKind
Matrix indices (for bones)
Static Readonly Matrices Weights Extra KindSearch playground for MatricesWeightsExtraKind
Additional matrix weights (for bones)
Static Readonly Matrices Weights KindSearch playground for MatricesWeightsKind
Matrix weights (for bones)
Static Readonly Normal KindSearch playground for NormalKind
Normals
Static Readonly Position KindSearch playground for PositionKind
Positions
Static Readonly SHORTSearch playground for SHORT
The short type.
Static Readonly Tangent KindSearch playground for TangentKind
Tangents
Static Readonly UNSIGNED_ BYTESearch playground for UNSIGNED_BYTE
The unsigned byte type.
Static Readonly UNSIGNED_ INTSearch playground for UNSIGNED_INT
The unsigned integer type.
Static Readonly UNSIGNED_ SHORTSearch playground for UNSIGNED_SHORT
The unsigned short type.
Static Readonly UV2 KindSearch playground for UV2Kind
Texture coordinates 2
Static Readonly UV3 KindSearch playground for UV3Kind
Texture coordinates 3
Static Readonly UV4 KindSearch playground for UV4Kind
Texture coordinates 4
Static Readonly UV5 KindSearch playground for UV5Kind
Texture coordinates 5
Static Readonly UV6 KindSearch playground for UV6Kind
Texture coordinates 6
Static Readonly UVKindSearch playground for UVKind
Texture coordinates
Accessors
instance Divisor
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
is Disposed
Gets a boolean indicating if the Buffer is disposed
Returns boolean
total Vertices
Gets the number of vertices in the buffer
Returns number
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
Disposes the VertexBuffer and the underlying WebGLBuffer.
Returns void
for EachSearch playground for forEach
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
Parameters
value: number
index: number
Returns void
Returns void
get BufferSearch playground for getBuffer
Gets underlying native buffer
Returns Nullable<DataBuffer>
underlying native buffer
get DataSearch playground for getData
get Float DataSearch 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
Optional 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
get Instance DivisorSearch playground for getInstanceDivisor
Returns the instancing divisor, zero for non-instanced (integer).
Returns number
a number
get Is InstancedSearch playground for getIsInstanced
Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
Returns boolean
true if this buffer is instanced
get KindSearch playground for getKind
Returns the kind of the VertexBuffer (string)
Returns string
a string
get OffsetSearch playground for getOffset
Returns the offset as a multiple of the type byte length.
Returns number
the offset in bytes
get SizeSearch playground for getSize
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
get Stride SizeSearch playground for getStrideSize
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
is UpdatableSearch playground for isUpdatable
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
data: DataArray
defines the data to store
Returns void
update DirectlySearch playground for updateDirectly
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 Deduce StrideSearch playground for DeduceStride
Deduces the stride given a kind.
Parameters
kind: string
The kind string to deduce
Returns number
The deduced stride
Static For EachSearch playground for ForEach
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
Parameters
value: number
index: number
Returns void
Returns void
Static Get Data TypeSearch playground for GetDataType
Gets the vertex buffer type of the given data array.
Parameters
data: DataArray
the data array
Returns number
the vertex buffer type
Static Get Float DataSearch playground for GetFloatData
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
Static Get Type Byte LengthSearch playground for GetTypeByteLength
Gets the byte length of the given type.
Parameters
type: number
the type
Returns number
the number of bytes
Specialized buffer used to store vertex data