BabylonJS/Babylon.js · error

Unknown kind: ${kind}

Error message

Unknown kind: ${kind}

What it means

GetAttributeType maps a Babylon VertexBuffer kind to its glTF attribute name (POSITION, NORMAL, TEXCOORD_0, WEIGHTS_0, ...). Unknown kinds have no glTF attribute equivalent, so the function throws instead of emitting an invalid attribute name that glTF validators would reject.

Source

Thrown at packages/dev/serializers/src/glTF/2.0/glTFUtilities.ts:145

        case VertexBuffer.UV3Kind:
            return "TEXCOORD_2";
        case VertexBuffer.UV4Kind:
            return "TEXCOORD_3";
        case VertexBuffer.UV5Kind:
            return "TEXCOORD_4";
        case VertexBuffer.UV6Kind:
            return "TEXCOORD_5";
        case VertexBuffer.MatricesIndicesKind:
            return "JOINTS_0";
        case VertexBuffer.MatricesIndicesExtraKind:
            return "JOINTS_1";
        case VertexBuffer.MatricesWeightsKind:
            return "WEIGHTS_0";
        case VertexBuffer.MatricesWeightsExtraKind:
            return "WEIGHTS_1";
    }

    throw new Error(`Unknown kind: ${kind}`);
}

export function GetPrimitiveMode(fillMode: number): MeshPrimitiveMode {
    switch (fillMode) {
        case Material.TriangleFillMode:
            return MeshPrimitiveMode.TRIANGLES;
        case Material.TriangleStripDrawMode:
            return MeshPrimitiveMode.TRIANGLE_STRIP;
        case Material.TriangleFanDrawMode:
            return MeshPrimitiveMode.TRIANGLE_FAN;
        case Material.PointListDrawMode:
        case Material.PointFillMode:
            return MeshPrimitiveMode.POINTS;
        case Material.LineLoopDrawMode:
            return MeshPrimitiveMode.LINE_LOOP;
        case Material.LineListDrawMode:
            return MeshPrimitiveMode.LINES;
        case Material.LineStripDrawMode:

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Use only standard VertexBuffer kinds for attributes that must be exported, or strip custom buffers before export
  2. Patch GetAttributeType to translate custom kinds to glTF custom attribute names (e.g. '_MYATTR') and extend GetAccessorType accordingly
  3. Rename a typo'd kind to the correct VertexBuffer constant (e.g. VertexBuffer.UVKind) when creating the buffer
  4. Catch the error and skip non-exportable attributes

Example fix

// before
mesh.setVerticesBuffer(new VertexBuffer(engine, data, "position2", true));
// after
mesh.setVerticesBuffer(new VertexBuffer(engine, data, VertexBuffer.PositionKind, true)); // maps to "POSITION"
Defensive patterns

Strategy: type-guard

Validate before calling

const EXPORTABLE_KINDS = new Set(Object.values(VertexBuffer).filter((v) => typeof v === "string"));
const canMapToAttribute = (kind: string): boolean => EXPORTABLE_KINDS.has(kind);

Type guard

const isStandardKind = (kind: string): boolean =>
    [VertexBuffer.PositionKind, VertexBuffer.NormalKind, VertexBuffer.UVKind, VertexBuffer.MatricesWeightsKind].includes(kind);

Try / catch

try {
    await GLTF2Export.GLTFAsync(scene, "scene");
} catch (e) {
    if (e instanceof Error && e.message.startsWith("Unknown kind:")) {
        // remove/rename the offending vertex buffer and retry the export
    } else { throw e; }
}

Prevention

When it happens

Trigger: _exportVertexBuffer encounters a mesh vertex buffer whose kind is not in the switch (custom attribute kinds like 'myattr', misspelled kinds, or kinds introduced by newer engine code not yet mapped) during GLTFExporter export.

Common situations: Custom shader attributes added via mesh.setVerticesBuffer with arbitrary kind strings; typos in kind names; serializer lagging behind new VertexBuffer kinds added in the engine.

Related errors


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