Creates a new BufferView instance.
Configuration object for the BufferView
The parent Buffer that this BufferView references
Total byte length of this BufferView
Byte offset within the parent buffer
Default stride in bytes between elements
The underlying ArrayBuffer containing the actual data
Gets the total byte length of this BufferView.
The byte length of this BufferView
Gets the byte offset of this BufferView within its parent Buffer. This is the relative offset from the start of the Buffer.
The byte offset within the parent Buffer
Gets the absolute byte offset in the raw ArrayBuffer. This includes the Buffer's own offset within the raw ArrayBuffer.
The absolute byte offset in the raw ArrayBuffer
Gets the default byte stride for this BufferView. The stride determines the number of bytes between consecutive elements.
The default byte stride in bytes
Checks if this BufferView uses Array of Structures (AoS) layout. AoS layout interleaves different component types within the same array.
True if any accessor uses AoS layout, false otherwise
Checks if this BufferView uses Structure of Arrays (SoA) layout. SoA layout stores each component type in separate arrays.
True if using SoA layout, false otherwise
Compares this BufferView with another BufferView for equality. Two BufferViews are considered the same if they have identical byte length, byte offset, default byte stride, and reference the same underlying ArrayBuffer.
The BufferView to compare with
True if the BufferViews are identical, false otherwise
Creates and allocates a new Accessor within this BufferView. The Accessor will be positioned at the current end of allocated space.
Configuration object for the Accessor
Optional
arrayOptional array length for array attributes (defaults to 1)
Optional
byteOptional byte stride between elements (defaults to defaultByteStride)
The component data type (e.g., FLOAT, UNSIGNED_SHORT)
The composition type (e.g., SCALAR, VEC2, VEC3, VEC4, MAT4)
Number of elements in the accessor
Optional
max?: number[]Optional maximum values for each component
Optional
min?: number[]Optional minimum values for each component
Optional
normalized?: booleanWhether integer values should be normalized to [0,1] or [-1,1] range
A Result containing the created Accessor on success, or an error on failure
Creates and allocates a new Accessor at a specific byte offset within this BufferView. Unlike takeAccessor, this method allows specifying the exact position within the BufferView.
Configuration object for the Accessor
Specific byte offset within this BufferView
Optional
byteOptional byte stride between elements (defaults to defaultByteStride)
The component data type (e.g., FLOAT, UNSIGNED_SHORT)
The composition type (e.g., SCALAR, VEC2, VEC3, VEC4, MAT4)
Number of elements in the accessor
Optional
max?: number[]Optional maximum values for each component
Optional
min?: number[]Optional minimum values for each component
Optional
normalized?: booleanWhether integer values should be normalized to [0,1] or [-1,1] range
A Result containing the created Accessor on success, or an error on failure
BufferView represents a view into a Buffer with specific byte offset and length. It manages memory allocation for Accessors and provides methods to create Accessors that read data from the underlying buffer in various formats.
BufferView acts as an intermediate layer between Buffer and Accessor, allowing multiple Accessors to share the same buffer memory while maintaining proper byte alignment and bounds checking.