Accessors store lists of numeric, vector, or matrix elements in a typed array.

All large data for Mesh, Skin, and Animation properties is stored in Accessors, organized into one or more Buffers. Each accessor provides data in typed arrays, with two abstractions:

Elements are the logical divisions of the data into useful types: "SCALAR", "VEC2", "VEC3", "VEC4", "MAT3", or "MAT4". The element type can be determined with the getType() method, and the number of elements in the accessor determine its getCount(). The number of components in an element — e.g. 9 for "MAT3" — are its getElementSize(). See Accessor.Type.

Components are the numeric values within an element — e.g. .x and .y for "VEC2". Various component types are available: BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, UNSIGNED_INT, and FLOAT. The component type can be determined with the getComponentType method, and the number of bytes in each component determine its getComponentSize. See Accessor.ComponentType.


const accessor = doc.createAccessor('myData')
    .setArray(new Float32Array([1,2,3,4,5,6,7,8,9,10,11,12]))

accessor.getCount();        // → 4
accessor.getElementSize();  // → 3
accessor.getByteLength();   // → 48
accessor.getElement(1, []); // → [4, 5, 6]

accessor.setElement(0, [10, 20, 30]);

Data access through the getElement and setElement methods reads or overwrites the content of the underlying typed array. These methods use element arrays intended to be compatible with the gl-matrix library, or with the toArray/fromArray methods of libraries like three.js and babylon.js.

Each Accessor must be assigned to a Buffer, which determines where the accessor's data is stored in the final file. Assigning Accessors to different Buffers allows the data to be written to different .bin files.

glTF-Transform does not expose many details of sparse, normalized, or interleaved accessors through its API. It reads files using those techniques, presents a simplified view of the data for editing, and attempts to write data back out with optimizations. For example, vertex attributes will typically be interleaved by default, regardless of the input file.




propertyType: ACCESSOR

Property type.

ComponentType: Record<string, AccessorComponentType> = ...

Data type of the values composing each element in the accessor.

Type: Record<string, AccessorType> = ...

Element type contained by the accessor (SCALAR, VEC2, ...).


  • dispatchEvent(event: BaseEvent): Accessor
  • Events.

  • dispose(): void
  • Removes both inbound references to and outbound references from this object. At the end of the process the object holds no references, and nothing holds references to it. A disposed object is not reusable.

  • equals(other: Accessor, skip?: Set<string>): boolean
  • Returns true if two properties are deeply equivalent, recursively comparing the attributes of the properties. Optionally, a 'skip' set may be included, specifying attributes whose values should not be considered in the comparison.

    Example: Two Primitives are equivalent if they have accessors and materials with equivalent content — but not necessarily the same specific accessors and materials.

  • getArray(): TypedArray
  • getByteLength(): number
  • getComponentSize(): number
  • getCount(): number
  • getDefaults(): Nullable<IAccessor>
  • getElement(index: number, target: number[]): number[]
  • getElementSize(): number
  • getExtension<Prop>(name: string): Prop
  • getExtras(): Record<string, unknown>
  • getMax(target: number[]): number[]
  • getMaxNormalized(target: number[]): number[]
  • getMin(target: number[]): number[]
  • getMinNormalized(target: number[]): number[]
  • getName(): string
  • getNormalized(): boolean
  • 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. This property is defined only for accessors that contain vertex attributes or animation output data.

  • getScalar(index: number): number
  • init(): void
  • isDisposed(): boolean
  • Returns true if the node has been permanently removed from the graph.

  • listExtensions(): ExtensionProperty<IProperty>[]
  • listParents(): Property<IProperty>[]
  • Returns a list of all properties that hold a reference to this property. For example, a material may hold references to various textures, but a texture does not hold references to the materials that use it.

    It is often necessary to filter the results for a particular type: some resources, like Accessors, may be referenced by different types of properties. Most properties include the Root as a parent, which is usually not of interest.


    const materials = texture
        .filter((p) => p instanceof Material)
  • setElement(index: number, value: number[]): Accessor
  • setExtension<Prop>(name: string, extensionProperty: Prop): Accessor
  • setExtras(extras: Record<string, unknown>): Accessor
  • setNormalized(normalized: boolean): Accessor
  • 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. This property is defined only for accessors that contain vertex attributes or animation output data.

  • setScalar(index: number, x: number): Accessor
Function symbol, f(📦) → 📦, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy TypeDoc documentation Copyright 2021 under MIT license