Data type of the values composing each element in the accessor.
Element type contained by the accessor (SCALAR, VEC2, ...).
Returns size of a given component type, in bytes.
Returns size of a given element type, in components.
Returns the raw typed array underlying this accessor.
Assigns the raw typed array underlying this accessor.
Returns the Buffer into which this accessor will be organized.
Assigns the Buffer into which this accessor will be organized.
Returns the total bytelength of this accessor, exclusive of padding.
Makes a copy of this property, with the same resources (by reference) as the original.
Size of each component (a value in the raw array), in bytes. For example, the
componentSize
of data backed by a float32
array is 4 bytes.
Component type (float32, uint16, etc.). This value is determined automatically, and can only be modified by replacing the underlying array.
Copies all data from another property to this one. Child properties are copied by reference, unless a 'resolve' function is given to override that.
Number of elements in the accessor. An array of length 30, containing 10 VEC3
elements,
will have a count of 10.
Dispatches an event on the GraphNode, and on the associated
Graph. Event types on the graph are prefixed, "node:[type]"
.
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.
Returns the vector or matrix element value at the given index. For normalized integer accessors, values are decoded and returned in floating-point form.
Example:
import { add } from 'gl-matrix/add';
const element = [];
const offset = [1, 1, 1];
for (let i = 0; i < accessor.getCount(); i++) {
accessor.getElement(i, element);
add(element, element, offset);
accessor.setElement(i, element);
}
Assigns the vector or matrix element value at the given index. For normalized integer accessors, "value" should be given in floating-point form β it will be integer-encoded before writing to the underlying array.
Example:
import { add } from 'gl-matrix/add';
const element = [];
const offset = [1, 1, 1];
for (let i = 0; i < accessor.getCount(); i++) {
accessor.getElement(i, element);
add(element, element, offset);
accessor.setElement(i, element);
}
Number of components in each element of the accessor. For example, the element size of a
VEC2
accessor is 2. This value is determined automatically based on array length and
accessor type, specified with setType().
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.
Returns an ExtensionProperty attached to this Property, if any.
Attaches the given ExtensionProperty to this Property. For a given extension, only one ExtensionProperty may be attached to any one Property at a time.
Lists all ExtensionProperty instances attached to this Property.
Returns a reference to the Extras object, containing application-specific data for this Property. Extras should be an Object, not a primitive value, for best portability.
Updates the Extras object, containing application-specific data for this Property. Extras should be an Object, not a primitive value, for best portability.
Returns true if the node has been permanently removed from the graph.
Maximum value of each component in this attribute. Values returned by this method do not reflect normalization: use {@link .getMinNormalized} in that case.
Maximum value of each component in this attribute. Unlike in a final glTF file, values returned by this method will reflect the minimum accounting for {@link .normalized} state.
Minimum value of each component in this attribute. Values returned by this method do not reflect normalization: use {@link .getMinNormalized} in that case.
Minimum value of each component in this attribute. Unlike in a final glTF file, values returned by this method will reflect the minimum accounting for {@link .normalized} state.
Returns the name of this property. While names are not required to be unique, this is encouraged, and non-unique names will be overwritten in some tools. For custom data about a property, prefer to use Extras.
Sets the name of this property. While names are not required to be unique, this is encouraged, and non-unique names will be overwritten in some tools. For custom data about a property, prefer to use Extras.
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.
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.
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.
Usage:
const materials = texture
.listParents()
.filter((p) => p instanceof Material)
Returns the scalar element value at the given index. For normalized integer accessors, values are decoded and returned in floating-point form.
Assigns the scalar element value at the given index. For normalized integer accessors, "value" should be given in floating-point form β it will be integer-encoded before writing to the underlying array.
Specifies whether the accessor should be stored sparsely. When written to a glTF file, sparse accessors store only values that differ from base values. When loaded in glTF Transform (or most runtimes) a sparse accessor can be treated like any other accessor. Currently, glTF Transform always uses zeroes for the base values when writing files.
Specifies whether the accessor should be stored sparsely. When written to a glTF file, sparse accessors store only values that differ from base values. When loaded in glTF Transform (or most runtimes) a sparse accessor can be treated like any other accessor. Currently, glTF Transform always uses zeroes for the base values when writing files.
Type of element stored in the accessor. VEC2
, VEC3
, etc.
Sets type of element stored in the accessor. VEC2
, VEC3
, etc. Array length must be a
multiple of the component size (VEC2
= 2, VEC3
= 3, ...) for the selected type.
Made by Don McCurdy. Documentation built with greendoc and published under Creative Commons Attribution 3.0.
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
, andFLOAT
. The component type can be determined with the getComponentType method, and the number of bytes in each component determine its getComponentSize. See Accessor.ComponentType.Usage:
const accessor = doc.createAccessor('myData') .setArray(new Float32Array([1,2,3,4,5,6,7,8,9,10,11,12])) .setType(Accessor.Type.VEC3) .setBuffer(doc.getRoot().listBuffers()[0]); 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.
References: