BabylonJS/Babylon.js · error · Error
${context}/type: Invalid value ${accessor.type}
Error message
${context}/type: Invalid value ${accessor.type} What it means
Index accessors must be of type SCALAR per the glTF 2.0 spec. When _loadIndicesAccessorAsync receives an accessor whose type is VEC2, VEC3, VEC4, or MAT*, it throws this error before any data is loaded. Indices are inherently a flat list of scalars.
Source
Thrown at packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts:2187
});
}
return accessor._data;
}
/**
* @internal
*/
public _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array> {
return this._loadAccessorAsync(context, accessor, Float32Array) as Promise<Float32Array>;
}
/**
* @internal
*/
public _loadIndicesAccessorAsync(context: string, accessor: IAccessor): Promise<IndicesArray> {
if (accessor.type !== AccessorType.SCALAR) {
throw new Error(`${context}/type: Invalid value ${accessor.type}`);
}
if (
accessor.componentType !== AccessorComponentType.UNSIGNED_BYTE &&
accessor.componentType !== AccessorComponentType.UNSIGNED_SHORT &&
accessor.componentType !== AccessorComponentType.UNSIGNED_INT
) {
throw new Error(`${context}/componentType: Invalid value ${accessor.componentType}`);
}
if (accessor._data) {
return accessor._data as Promise<IndicesArray>;
}
if (accessor.sparse) {
const constructor = GLTFLoader._GetTypedArrayConstructor(`${context}/componentType`, accessor.componentType);
accessor._data = this._loadAccessorAsync(context, accessor, constructor);
} else {
View on GitHub (pinned to 0592b347b8)
Solutions
- Change the indices accessor type to "SCALAR" and regenerate its data.
- Point primitive.indices at the correct SCALAR accessor.
- Re-export the mesh with a compliant exporter.
- Run glTF-Validator to find all mis-typed accessors.
Example fix
// before
"accessors": [{ "type": "VEC3", "componentType": 5125, "count": 36 }]
// after (indices)
"accessors": [{ "type": "SCALAR", "componentType": 5125, "count": 36 }] Defensive patterns
Strategy: type-guard
Validate before calling
for (const prim of gltf.meshes?.flatMap(m => m.primitives) ?? []) {
const acc = gltf.accessors?.[prim.indices!];
if (acc && acc.type !== "SCALAR") {
throw new Error(`Indices accessor type must be SCALAR, got ${acc.type}`);
}
} Type guard
function isScalarAccessor(acc: { type: string }): acc is { type: "SCALAR" } {
return acc.type === "SCALAR";
} Try / catch
try { await loadAsset(); } catch (e) {
if (/\/type: Invalid value/.test((e as Error).message)) {
// reject or repair the asset before retrying
}
} Prevention
- Validate accessors with glTF-Validator in your asset pipeline.
- Keep attribute and index accessors clearly separated in exporters.
- Audit hand-edited glTF JSON for type fields.
When it happens
Trigger: A primitive's indices accessor referencing an accessor with type != "SCALAR"; usually a malformed asset or an exporter writing the wrong type field.
Common situations: Buggy exporters pointing indices at a vector accessor, hand-edited glTF JSON, converters that reused an attribute accessor as indices.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- ${context}/componentType: Invalid value ${accessor.component
- ${context}: Camera orthographic properties are missing
- ${context}: Invalid camera type (${camera.type})
- ${context}/target/path: Invalid value (${channel.target.path
- ${context}/target/path: Could not find interpolation propert
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/04ce3aebfce02e04.
Report an issue: GitHub.