{"record":{"id":"04ce3aebfce02e04","repo":"BabylonJS/Babylon.js","slug":"context-type-invalid-value-accessor-type","errorCode":null,"errorMessage":"${context}/type: Invalid value ${accessor.type}","messagePattern":"(.+?)/type: Invalid value (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts","lineNumber":2187,"sourceCode":"            });\r\n        }\r\n\r\n        return accessor._data;\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     */\r\n    public _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array> {\r\n        return this._loadAccessorAsync(context, accessor, Float32Array) as Promise<Float32Array>;\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     */\r\n    public _loadIndicesAccessorAsync(context: string, accessor: IAccessor): Promise<IndicesArray> {\r\n        if (accessor.type !== AccessorType.SCALAR) {\r\n            throw new Error(`${context}/type: Invalid value ${accessor.type}`);\r\n        }\r\n\r\n        if (\r\n            accessor.componentType !== AccessorComponentType.UNSIGNED_BYTE &&\r\n            accessor.componentType !== AccessorComponentType.UNSIGNED_SHORT &&\r\n            accessor.componentType !== AccessorComponentType.UNSIGNED_INT\r\n        ) {\r\n            throw new Error(`${context}/componentType: Invalid value ${accessor.componentType}`);\r\n        }\r\n\r\n        if (accessor._data) {\r\n            return accessor._data as Promise<IndicesArray>;\r\n        }\r\n\r\n        if (accessor.sparse) {\r\n            const constructor = GLTFLoader._GetTypedArrayConstructor(`${context}/componentType`, accessor.componentType);\r\n            accessor._data = this._loadAccessorAsync(context, accessor, constructor);\r\n        } else {\r","sourceCodeStart":2169,"sourceCodeEnd":2205,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts#L2169-L2205","documentation":"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.","triggerScenarios":"A primitive's indices accessor referencing an accessor with type != \"SCALAR\"; usually a malformed asset or an exporter writing the wrong type field.","commonSituations":"Buggy exporters pointing indices at a vector accessor, hand-edited glTF JSON, converters that reused an attribute accessor as indices.","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."],"exampleFix":"// before\n\"accessors\": [{ \"type\": \"VEC3\", \"componentType\": 5125, \"count\": 36 }]\n// after (indices)\n\"accessors\": [{ \"type\": \"SCALAR\", \"componentType\": 5125, \"count\": 36 }]","handlingStrategy":"type-guard","validationCode":"for (const prim of gltf.meshes?.flatMap(m => m.primitives) ?? []) {\n  const acc = gltf.accessors?.[prim.indices!];\n  if (acc && acc.type !== \"SCALAR\") {\n    throw new Error(`Indices accessor type must be SCALAR, got ${acc.type}`);\n  }\n}","typeGuard":"function isScalarAccessor(acc: { type: string }): acc is { type: \"SCALAR\" } {\n  return acc.type === \"SCALAR\";\n}","tryCatchPattern":"try { await loadAsset(); } catch (e) {\n  if (/\\/type: Invalid value/.test((e as Error).message)) {\n    // reject or repair the asset before retrying\n  }\n}","preventionTips":["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."],"tags":["gltf","accessor","indices","schema-validation","asset-loading"],"backgroundTag":"invalid-enum-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}