BabylonJS/Babylon.js · error · Error

${context}: Attributes are missing

Error message

${context}: Attributes are missing

What it means

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.

Source

Thrown at packages/dev/loaders/src/glTF/2.0/glTFLoader.pure.ts:1240

        this._parent.onMeshLoadedObservable.notifyObservers(babylonAbstractMesh);
        assign(babylonAbstractMesh);

        this.logClose();

        return promise.then(() => {
            return babylonAbstractMesh;
        });
    }

    private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Promise<Geometry> {
        const extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh);
        if (extensionPromise) {
            return extensionPromise;
        }

        const attributes = primitive.attributes;
        if (!attributes) {
            throw new Error(`${context}: Attributes are missing`);
        }

        const promises = new Array<Promise<unknown>>();

        const babylonGeometry = new Geometry(babylonMesh.name, this._babylonScene);

        if (primitive.indices == undefined) {
            babylonMesh.isUnIndexed = true;
        } else {
            const accessor = ArrayItem.Get(`${context}/indices`, this._gltf.accessors, primitive.indices);
            promises.push(
                this._loadIndicesAccessorAsync(`/accessors/${accessor.index}`, accessor).then((data) => {
                    babylonGeometry.setIndices(data);
                })
            );
        }

        const loadAttribute = (name: string, kind: string, callback?: (accessor: IAccessor) => void) => {

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Fix the asset so every primitive has an attributes object including POSITION
  2. Re-export the model and validate with glTF-Validator before shipping
  3. Remove primitives that have no geometry from the mesh

Example fix

// before (in .gltf)
// { "primitives": [ { "mode": 4 } ] }
// after
// { "primitives": [ { "mode": 4, "attributes": { "POSITION": 0 } } ] }
Defensive patterns

Strategy: validation

Validate before calling

// Check every primitive has attributes before loading
const bad = (gltf.meshes ?? []).flatMap(m => m.primitives ?? [])
  .filter(p => !p.attributes);
if (bad.length) throw new Error(`Primitives missing attributes: ${bad.length}`);

Type guard

function primitiveHasAttributes(primitive) {
  return primitive != null && typeof primitive.attributes === "object" && primitive.attributes !== null;
}

Try / catch

try {
  await loader.loadAsync(url);
} catch (e) {
  if (e.message.includes(": Attributes are missing")) {
    console.error("Primitive has no attributes (needs at least POSITION) — re-export the asset");
  } else throw e;
}

Prevention

When it happens

Trigger: Loading a glTF whose primitive lacks the attributes property entirely, e.g. { "mode": 4 } with no attributes or accessors.

Common situations: Corrupt or truncated exports; hand-written glTF missing attributes; asset-processing pipelines that strip vertex streams but keep the primitive.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/07cdb50e823396b7. Report an issue: GitHub.