docs.unity3d.com
    Show / Hide Table of Contents

    Class Accessor

    An accessor defines a method for retrieving data as typed arrays from within a buffer view. See accessor in the glTF 2.0 specification

    Inheritance
    Object
    Accessor
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: GLTFast.Schema
    Syntax
    [Serializable]
    public class Accessor

    Fields

    bufferView

    The index of the bufferView. If this is undefined, look in the sparse object for the index and value buffer views.

    Declaration
    public int bufferView
    Field Value
    Type Description
    Int32

    byteOffset

    The offset relative to the start of the bufferView in bytes. This must be a multiple of the size of the component datatype. 0

    Declaration
    public int byteOffset
    Field Value
    Type Description
    Int32

    componentType

    The datatype of components in the attribute. All valid values correspond to WebGL enums. The corresponding typed arrays are: Int8Array, Uint8Array, Int16Array, Uint16Array, Uint32Array, and Float32Array, respectively. 5125 (UNSIGNED_INT) is only allowed when the accessor contains indices i.e., the accessor is only referenced by primitive.indices.

    Declaration
    public GltfComponentType componentType
    Field Value
    Type Description
    GltfComponentType

    count

    The number of attributes referenced by this accessor, not to be confused with the number of bytes or number of components. 1

    Declaration
    public int count
    Field Value
    Type Description
    Int32

    max

    Maximum value of each component in this attribute. Both min and max arrays have the same length. The length is determined by the value of the type property; it can be 1, 2, 3, 4, 9, or 16.

    When componentType is 5126 (FLOAT) each array value must be stored as double-precision JSON number with numerical value which is equal to buffer-stored single-precision value to avoid extra runtime conversions.

    normalized property has no effect on array values: they always correspond to the actual values stored in the buffer. When accessor is sparse, this property must contain max values of accessor data with sparse substitution applied. 1 16

    Declaration
    public float[] max
    Field Value
    Type Description
    Single[]

    min

    Minimum value of each component in this attribute. Both min and max arrays have the same length. The length is determined by the value of the type property; it can be 1, 2, 3, 4, 9, or 16.

    When componentType is 5126 (FLOAT) each array value must be stored as double-precision JSON number with numerical value which is equal to buffer-stored single-precision value to avoid extra runtime conversions.

    normalized property has no effect on array values: they always correspond to the actual values stored in the buffer. When accessor is sparse, this property must contain min values of accessor data with sparse substitution applied. 1 16

    Declaration
    public float[] min
    Field Value
    Type Description
    Single[]

    normalized

    Specifies whether integer data values should be normalized (true) to [0, 1] (for unsigned types) or [-1, 1] (for signed types), or converted directly (false) when they are accessed. Must be false when accessor is used for animation data.

    Declaration
    public bool normalized
    Field Value
    Type Description
    Boolean

    sparse

    Sparse storage of attributes that deviate from their initialization value.

    Declaration
    public AccessorSparse sparse
    Field Value
    Type Description
    AccessorSparse

    Properties

    IsSparse

    True if the accessor is sparse

    Declaration
    public bool IsSparse { get; }
    Property Value
    Type Description
    Boolean

    Methods

    GetAccessorAttributeType(Int32)

    Get one-dimensional glTF attribute type by number of components per elements. Note that this does not support matrix types.

    Declaration
    public static GltfAccessorAttributeType GetAccessorAttributeType(int dimension)
    Parameters
    Type Name Description
    Int32 dimension

    Number of components per element

    Returns
    Type Description
    GltfAccessorAttributeType

    Corresponding one-dimensional glTF attribute type

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    GetAccessorAttributeTypeLength(GltfAccessorAttributeType)

    Get number of components of glTF attribute type.

    Declaration
    public static int GetAccessorAttributeTypeLength(GltfAccessorAttributeType type)
    Parameters
    Type Name Description
    GltfAccessorAttributeType type

    glTF attribute type

    Returns
    Type Description
    Int32

    Number of components

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    GetAttributeType()

    GltfAccessorAttributeType typed/cached getter from the GLTFast.Schema.Accessor.type string.

    Declaration
    public GltfAccessorAttributeType GetAttributeType()
    Returns
    Type Description
    GltfAccessorAttributeType

    The Accessor's attribute type, if it could be retrieved correctly. Undefined otherwise

    GetComponentType(VertexAttributeFormat)

    Converts Unity vertex attribute format to glTF component type.

    Declaration
    public static GltfComponentType GetComponentType(VertexAttributeFormat format)
    Parameters
    Type Name Description
    VertexAttributeFormat format

    vertex attribute format

    Returns
    Type Description
    GltfComponentType

    glTF component type

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    GetComponentTypeSize(GltfComponentType)

    Provides size of components by type

    Declaration
    public static int GetComponentTypeSize(GltfComponentType componentType)
    Parameters
    Type Name Description
    GltfComponentType componentType

    glTF component type

    Returns
    Type Description
    Int32

    Component size in bytes

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    SetAttributeType(GltfAccessorAttributeType)

    GltfAccessorAttributeType typed setter for the GLTFast.Schema.Accessor.type string.

    Declaration
    public void SetAttributeType(GltfAccessorAttributeType type)
    Parameters
    Type Name Description
    GltfAccessorAttributeType type

    Attribute type

    TryGetBounds()

    For 3D positional data, returns accessor's bounding box. Applies coordinate system transform (glTF to Unity)

    Declaration
    public Bounds? TryGetBounds()
    Returns
    Type Description
    Nullable<Bounds>

    Bounding box enclosing the minimum and maximum values

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023