{"record":{"id":"07cdb50e823396b7","repo":"BabylonJS/Babylon.js","slug":"context-attributes-are-missing","errorCode":null,"errorMessage":"${context}: Attributes are missing","messagePattern":"(.+?): Attributes are missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts","lineNumber":1240,"sourceCode":"        this._parent.onMeshLoadedObservable.notifyObservers(babylonAbstractMesh);\r\n        assign(babylonAbstractMesh);\r\n\r\n        this.logClose();\r\n\r\n        return promise.then(() => {\r\n            return babylonAbstractMesh;\r\n        });\r\n    }\r\n\r\n    private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Promise<Geometry> {\r\n        const extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh);\r\n        if (extensionPromise) {\r\n            return extensionPromise;\r\n        }\r\n\r\n        const attributes = primitive.attributes;\r\n        if (!attributes) {\r\n            throw new Error(`${context}: Attributes are missing`);\r\n        }\r\n\r\n        const promises = new Array<Promise<unknown>>();\r\n\r\n        const babylonGeometry = new Geometry(babylonMesh.name, this._babylonScene);\r\n\r\n        if (primitive.indices == undefined) {\r\n            babylonMesh.isUnIndexed = true;\r\n        } else {\r\n            const accessor = ArrayItem.Get(`${context}/indices`, this._gltf.accessors, primitive.indices);\r\n            promises.push(\r\n                this._loadIndicesAccessorAsync(`/accessors/${accessor.index}`, accessor).then((data) => {\r\n                    babylonGeometry.setIndices(data);\r\n                })\r\n            );\r\n        }\r\n\r\n        const loadAttribute = (name: string, kind: string, callback?: (accessor: IAccessor) => void) => {\r","sourceCodeStart":1222,"sourceCodeEnd":1258,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts#L1222-L1258","documentation":"Each glTF mesh primitive must declare an 'attributes' object (at minimum a POSITION attribute per the spec). When _loadPrimitiveAsync finds primitive.attributes missing, it throws because no vertex data can be constructed.","triggerScenarios":"Loading a glTF whose primitive lacks the attributes property entirely, e.g. { \"mode\": 4 } with no attributes or accessors.","commonSituations":"Corrupt or truncated exports; hand-written glTF missing attributes; asset-processing pipelines that strip vertex streams but keep the primitive.","solutions":["Fix the asset so every primitive has an attributes object including POSITION","Re-export the model and validate with glTF-Validator before shipping","Remove primitives that have no geometry from the mesh"],"exampleFix":"// before (in .gltf)\n// { \"primitives\": [ { \"mode\": 4 } ] }\n// after\n// { \"primitives\": [ { \"mode\": 4, \"attributes\": { \"POSITION\": 0 } } ] }","handlingStrategy":"validation","validationCode":"// Check every primitive has attributes before loading\nconst bad = (gltf.meshes ?? []).flatMap(m => m.primitives ?? [])\n  .filter(p => !p.attributes);\nif (bad.length) throw new Error(`Primitives missing attributes: ${bad.length}`);","typeGuard":"function primitiveHasAttributes(primitive) {\n  return primitive != null && typeof primitive.attributes === \"object\" && primitive.attributes !== null;\n}","tryCatchPattern":"try {\n  await loader.loadAsync(url);\n} catch (e) {\n  if (e.message.includes(\": Attributes are missing\")) {\n    console.error(\"Primitive has no attributes (needs at least POSITION) — re-export the asset\");\n  } else throw e;\n}","preventionTips":["Ensure exports always include POSITION vertex data","Run glTF-Validator on assets in CI to catch spec violations early"],"tags":["gltf","malformed-asset","geometry"],"backgroundTag":"gltf-invalid-asset-structure","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}