rhodonite
    Preparing search index...

    Class BufferView

    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.

    Index

    Constructors

    • Creates a new BufferView instance.

      Parameters

      • params: {
            buffer: Buffer;
            byteLength: number;
            byteOffsetInBuffer: number;
            defaultByteStride: number;
            raw: ArrayBuffer;
        }

        Configuration object for the BufferView

        • buffer: Buffer

          The parent Buffer that this BufferView references

        • byteLength: number

          Total byte length of this BufferView

        • byteOffsetInBuffer: number

          Byte offset within the parent buffer

        • defaultByteStride: number

          Default stride in bytes between elements

        • raw: ArrayBuffer

          The underlying ArrayBuffer containing the actual data

      Returns BufferView

    Accessors

    • get byteOffsetInBuffer(): number

      Gets the byte offset of this BufferView within its parent Buffer. This is the relative offset from the start of the Buffer.

      Returns number

      The byte offset within the parent Buffer

    • get byteOffsetInRawArrayBufferOfBuffer(): number

      Gets the absolute byte offset in the raw ArrayBuffer. This includes the Buffer's own offset within the raw ArrayBuffer.

      Returns number

      The absolute byte offset in the raw ArrayBuffer

    • get defaultByteStride(): number

      Gets the default byte stride for this BufferView. The stride determines the number of bytes between consecutive elements.

      Returns number

      The default byte stride in bytes

    • get isAoS(): boolean

      Checks if this BufferView uses Array of Structures (AoS) layout. AoS layout interleaves different component types within the same array.

      Returns boolean

      True if any accessor uses AoS layout, false otherwise

    • get isSoA(): boolean

      Checks if this BufferView uses Structure of Arrays (SoA) layout. SoA layout stores each component type in separate arrays.

      Returns boolean

      True if using SoA layout, false otherwise

    Methods

    • Creates a Uint8Array view of this BufferView's memory area. This provides direct access to the raw bytes within the BufferView's bounds.

      Returns Uint8Array

      A Uint8Array representing the BufferView's memory area

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

      Parameters

      • rnBufferView: BufferView

        The BufferView to compare with

      Returns boolean

      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.

      Parameters

      • params: {
            arrayLength?: number;
            byteStride?: number;
            componentType: ComponentTypeEnum;
            compositionType: CompositionTypeEnum;
            count: number;
            max?: number[];
            min?: number[];
            normalized?: boolean;
        }

        Configuration object for the Accessor

        • OptionalarrayLength?: number

          Optional array length for array attributes (defaults to 1)

        • OptionalbyteStride?: number

          Optional byte stride between elements (defaults to defaultByteStride)

        • componentType: ComponentTypeEnum

          The component data type (e.g., FLOAT, UNSIGNED_SHORT)

        • compositionType: CompositionTypeEnum

          The composition type (e.g., SCALAR, VEC2, VEC3, VEC4, MAT4)

        • count: number

          Number of elements in the accessor

        • Optionalmax?: number[]

          Optional maximum values for each component

        • Optionalmin?: number[]

          Optional minimum values for each component

        • Optionalnormalized?: boolean

          Whether integer values should be normalized to [0,1] or [-1,1] range

      Returns Result<Accessor, undefined>

      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.

      Parameters

      • params: {
            byteOffsetInBufferView: number;
            byteStride?: number;
            componentType: ComponentTypeEnum;
            compositionType: CompositionTypeEnum;
            count: number;
            max?: number[];
            min?: number[];
            normalized?: boolean;
        }

        Configuration object for the Accessor

        • byteOffsetInBufferView: number

          Specific byte offset within this BufferView

        • OptionalbyteStride?: number

          Optional byte stride between elements (defaults to defaultByteStride)

        • componentType: ComponentTypeEnum

          The component data type (e.g., FLOAT, UNSIGNED_SHORT)

        • compositionType: CompositionTypeEnum

          The composition type (e.g., SCALAR, VEC2, VEC3, VEC4, MAT4)

        • count: number

          Number of elements in the accessor

        • Optionalmax?: number[]

          Optional maximum values for each component

        • Optionalmin?: number[]

          Optional minimum values for each component

        • Optionalnormalized?: boolean

          Whether integer values should be normalized to [0,1] or [-1,1] range

      Returns Result<Accessor, undefined>

      A Result containing the created Accessor on success, or an error on failure