Creates a new Accessor instance.
Configuration object for the accessor
Length of array for each element
The BufferView that contains the data
Byte offset within the buffer view
Byte stride between elements (0 for tightly packed)
Component data type (byte, short, int, float, etc.)
Type of data composition (scalar, vec2, vec3, vec4, mat3, mat4)
Number of elements
Optional
max?: number[]Optional maximum values for each component
Optional
min?: number[]Optional minimum values for each component
Whether integer values should be normalized to [0,1] or [-1,1]
Raw ArrayBuffer containing the data
Gets the actual byte stride, accounting for zero stride.
The actual byte stride
Gets the underlying ArrayBuffer of the buffer view.
The ArrayBuffer containing the data
Gets the BufferView that contains this accessor's data.
The BufferView object
Gets the total byte length of all data in this accessor.
The byte length
Gets the byte offset within the buffer.
The byte offset in the buffer
Gets the byte offset within the buffer view.
The byte offset in the buffer view
Gets the byte offset in the raw ArrayBuffer of the buffer.
The byte offset in the raw ArrayBuffer
Gets the byte stride between elements. For tightly packed data, this equals elementSizeInBytes. For interleaved data, this may be larger.
The byte stride
Gets the size in bytes of each component.
The component size in bytes
Gets the component type of this accessor.
The component type enum
Gets the composition type of this accessor.
The composition type enum
Gets the DataView of the buffer view.
The DataView for accessing the buffer data
Gets the total number of elements in this accessor. Each element may be a scalar, vec2, vec3, vec4, matrix, etc.
The element count
Gets the size in bytes of each element (numberOfComponents * componentSizeInBytes).
The element size in bytes
Checks if this accessor uses Array of Structures (AoS) layout. AoS means data is interleaved (e.g., XYZXYZXYZ for positions).
True if using AoS layout
Gets whether the min/max values are dirty and need recalculation.
True if min/max values are dirty
Checks if this accessor uses Structure of Arrays (SoA) layout. SoA means data is tightly packed (e.g., XXXYYYZZZ for positions).
True if using SoA layout
Gets the maximum values for each component. Calculates min/max if dirty.
Array of maximum values
Gets the minimum values for each component. Calculates min/max if dirty.
Array of minimum values
Gets whether the data should be normalized.
True if data should be normalized
Gets the number of components per element (e.g., 3 for Vec3, 4 for Vec4).
The number of components
Gets the number of elements that have been taken from this accessor.
The count of taken elements
Gets the version number of this accessor. Increments when data is modified.
The version number
Adds an element from another accessor with the same composition type, scaled by a coefficient.
The target element index
The source accessor to add from
The coefficient to multiply the source values by
Optional
secondIdx: numberOptional source index (defaults to i)
Copies the entire buffer from another accessor.
The source accessor to copy the buffer from
Copies data from a TypedArray into this accessor. The data is copied element by element with proper type conversion.
The TypedArray to copy data from
Gets the DataView getter method name for the given component type.
The component type to get the getter for
The DataView getter method name, or undefined if unknown
Gets the DataView setter method name for the given component type.
The component type to get the setter for
The DataView setter method name, or undefined if unknown
Gets a 3x3 matrix object at the specified index.
The element index
Access options including indices accessor and endianness
A Matrix33 object containing the matrix components
Gets a 3x3 matrix as an array at the specified index.
The element index
Access options including indices accessor and endianness
A 9-element array containing the matrix components in row-major order
Gets a 3x3 matrix at the specified index and stores it in the provided output object. This method avoids creating new objects and is more memory-efficient.
The element index
The output MutableMatrix33 object to store the result
Access options including indices accessor and endianness
Optional
endian?: booleanOptional
indicesThe output Matrix33 object (same as the out parameter)
Gets a 4x4 matrix object at the specified index.
The element index
Access options including indices accessor and endianness
A MutableMatrix44 object containing the matrix components
Gets a 4x4 matrix as an array at the specified index.
The element index
Access options including indices accessor and endianness
A 16-element array containing the matrix components in row-major order
Gets a 4x4 matrix at the specified index and stores it in the provided output object. This method avoids creating new objects and is more memory-efficient.
The element index
The output MutableMatrix44 object to store the result
Access options including indices accessor and endianness
The output MutableMatrix44 object (same as the out parameter)
Gets a scalar value at the specified index.
The element index
Access options including indices accessor and endianness
The scalar value
Gets a scalar value at the specified index with a composition offset.
The element index
Byte offset within the element
Access options including indices accessor and endianness
The scalar value
Gets the underlying TypedArray for this accessor. Note: If the buffer view uses interleaved data (AoS), direct access may not work as expected.
The TypedArray containing the data
Gets the appropriate TypedArray constructor for the given component type.
The component type to get the constructor for
The TypedArray constructor class, or undefined if unknown
Gets a 2D vector object at the specified index.
The element index
Access options including indices accessor and endianness
A Vector2 object containing the vector components
Gets a 2D vector as an array at the specified index.
The element index
Access options including indices accessor and endianness
A 2-element array containing the vector components
Gets a 2D vector at the specified index and stores it in the provided output object. This method avoids creating new objects and is more memory-efficient.
The element index
The output MutableVector2 object to store the result
Access options including indices accessor and endianness
The output Vector2 object (same as the out parameter)
Gets a 3D vector object at the specified index.
The element index
Access options including indices accessor and endianness
A Vector3 object containing the vector components
Gets a 3D vector as an array at the specified index.
The element index
Access options including indices accessor and endianness
A 3-element array containing the vector components
Gets a 3D vector at the specified index and stores it in the provided output object. This method avoids creating new objects and is more memory-efficient.
The element index
The output MutableVector3 object to store the result
Access options including indices accessor and endianness
The output Vector3 object (same as the out parameter)
Gets a 4D vector object at the specified index.
The element index
Access options including indices accessor and endianness
A Vector4 object containing the vector components
Gets a 4D vector as an array at the specified index.
The element index
Access options including indices accessor and endianness
A 4-element array containing the vector components
Gets a 4D vector at the specified index and stores it in the provided output object. This method avoids creating new objects and is more memory-efficient.
The element index
The output MutableVector4 object to store the result
Access options including indices accessor and endianness
The output Vector4 object (same as the out parameter)
Checks if this accessor is the same as another accessor. Compares byte length, offset, and underlying buffer.
The accessor to compare with
True if the accessors are the same
Sets an element from another accessor, handling different composition types. Automatically converts between different vector/scalar types as needed.
The target element index
The source accessor to copy from
Optional
secondIdx: numberOptional source index (defaults to i)
Sets an element from another accessor with the same composition type.
The target element index
The source accessor to copy from
Optional
secondIdx: numberOptional source index (defaults to i)
Sets a 3x3 matrix at the specified index.
The element index
Matrix component at position [0,0]
Matrix component at position [0,1]
Matrix component at position [0,2]
Matrix component at position [1,0]
Matrix component at position [1,1]
Matrix component at position [1,2]
Matrix component at position [2,0]
Matrix component at position [2,1]
Matrix component at position [2,2]
Access options including indices accessor and endianness
Sets a 4x4 matrix at the specified index.
The element index
Matrix component at position [0,0]
Matrix component at position [0,1]
Matrix component at position [0,2]
Matrix component at position [0,3]
Matrix component at position [1,0]
Matrix component at position [1,1]
Matrix component at position [1,2]
Matrix component at position [1,3]
Matrix component at position [2,0]
Matrix component at position [2,1]
Matrix component at position [2,2]
Matrix component at position [2,3]
Matrix component at position [3,0]
Matrix component at position [3,1]
Matrix component at position [3,2]
Matrix component at position [3,3]
Access options including indices accessor and endianness
Sets a 4x4 matrix at the specified index using a Matrix44 object.
The element index
The Matrix44 object containing the values to set
Access options including indices accessor and endianness
Sets a scalar value at the specified index.
The element index
The scalar value to set
Access options including indices accessor and endianness
Sets a scalar value at the specified index with a composition offset.
The element index
Byte offset within the element
The scalar value to set
Access options including indices accessor and endianness
Sets the data from a TypedArray into this accessor. If the provided array uses the same buffer, no copying is needed. Otherwise, data is copied element by element with proper type conversion.
The TypedArray to copy data from
Sets a 2D vector at the specified index.
The element index
The X component value
The Y component value
Access options including indices accessor and endianness
Sets a 2D vector at the specified index using a Vector2 object.
The element index
The Vector2 object containing the values to set
Access options including indices accessor and endianness
Sets a 3D vector at the specified index.
The element index
The X component value
The Y component value
The Z component value
Access options including indices accessor and endianness
Sets a 3D vector at the specified index using a Vector3 object.
The element index
The Vector3 object containing the values to set
Access options including indices accessor and endianness
Sets a 4D vector at the specified index.
The element index
The X component value
The Y component value
The Z component value
The W component value
Access options including indices accessor and endianness
Sets a 4D vector at the specified index using a Vector4 object.
The element index
The Vector4 object containing the values to set
Access options including indices accessor and endianness
Takes one element from the accessor and returns a TypedArray view of it. This method allocates a new view for the next available element.
A TypedArray view of the taken element
Accessor class provides a high-level interface for reading and writing data from/to a BufferView. It handles different data types (scalar, vector, matrix) and provides type-safe access to buffer data. This class is commonly used in 3D graphics applications for managing vertex attributes, indices, and other buffer data.