{"record":{"id":"ce8ef6e152fdea2c","repo":"BabylonJS/Babylon.js","slug":"context-componenttype-invalid-value-accessor","errorCode":null,"errorMessage":"${context}/componentType: Invalid value ${accessor.componentType}","messagePattern":"(.+?)/componentType: Invalid value (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts","lineNumber":2195,"sourceCode":"     */\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\n            const bufferView = ArrayItem.Get(`${context}/bufferView`, this._gltf.bufferViews, accessor.bufferView);\r\n            accessor._data = this.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView).then((data) => {\r\n                return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, accessor.count);\r\n            });\r\n        }\r\n\r\n        return accessor._data as Promise<IndicesArray>;\r\n    }\r","sourceCodeStart":2177,"sourceCodeEnd":2213,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts#L2177-L2213","documentation":"Index accessors must use an unsigned integer component type: UNSIGNED_BYTE (5121), UNSIGNED_SHORT (5123), or UNSIGNED_INT (5125). Signed, float, or double component types are rejected with this error because index buffers cannot contain negative or fractional values.","triggerScenarios":"A primitive's indices accessor uses componentType such as FLOAT (5126) or a signed int, whether from a buggy exporter, hand-editing, or a converter that reused a vertex-data accessor for indices.","commonSituations":"Converters mapping index data as float arrays, hand-built glTF where componentType constants are misremembered (e.g. 5126 instead of 5125), assets optimized incorrectly.","solutions":["Set the indices accessor componentType to 5121, 5123, or 5125 and convert the data accordingly.","Point primitive.indices at a properly typed unsigned-int accessor.","Re-export the mesh with a compliant exporter.","Validate with glTF-Validator to catch componentType mismatches."],"exampleFix":"// before\n\"accessors\": [{ \"type\": \"SCALAR\", \"componentType\": 5126, \"count\": 36 }]\n// after\n\"accessors\": [{ \"type\": \"SCALAR\", \"componentType\": 5125, \"count\": 36 }]","handlingStrategy":"type-guard","validationCode":"const IDX_COMPONENTS = [5121, 5123, 5125];\nfor (const prim of gltf.meshes?.flatMap(m => m.primitives) ?? []) {\n  const acc = gltf.accessors?.[prim.indices!];\n  if (acc && !IDX_COMPONENTS.includes(acc.componentType)) {\n    throw new Error(`Indices componentType must be unsigned int, got ${acc.componentType}`);\n  }\n}","typeGuard":"function isUnsignedIndexComponent(c: number): c is 5121 | 5123 | 5125 {\n  return c === 5121 || c === 5123 || c === 5125;\n}","tryCatchPattern":"try { await loadAsset(); } catch (e) {\n  if (/componentType: Invalid value/.test((e as Error).message)) {\n    // convert index data to UNSIGNED_INT (5125) and retry\n  }\n}","preventionTips":["Remember: 5121/5123/5125 only — never FLOAT (5126) for indices.","Run glTF-Validator on converted assets.","Double-check componentType constants in hand-written exporters."],"tags":["gltf","accessor","indices","component-type","asset-loading"],"backgroundTag":"invalid-enum-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}