BabylonJS/Babylon.js · error

Unknown kind ${kind}

Error message

Unknown kind ${kind}

What it means

GetAccessorType maps a Babylon VertexBuffer kind string (e.g. 'position', 'normal', 'uv') to a glTF accessor type (VEC3, VEC2, etc.). If the kind is not one of the known kinds, the mapping falls through the switch and throws, because the exporter cannot know the component count of an unknown attribute.

Source

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

        case VertexBuffer.PositionKind:
        case VertexBuffer.NormalKind:
            return AccessorType.VEC3;
        case VertexBuffer.TangentKind:
        case VertexBuffer.MatricesIndicesKind:
        case VertexBuffer.MatricesIndicesExtraKind:
        case VertexBuffer.MatricesWeightsKind:
        case VertexBuffer.MatricesWeightsExtraKind:
            return AccessorType.VEC4;
        case VertexBuffer.UVKind:
        case VertexBuffer.UV2Kind:
        case VertexBuffer.UV3Kind:
        case VertexBuffer.UV4Kind:
        case VertexBuffer.UV5Kind:
        case VertexBuffer.UV6Kind:
            return AccessorType.VEC2;
    }

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

export function GetAttributeType(kind: string): string {
    switch (kind) {
        case VertexBuffer.PositionKind:
            return "POSITION";
        case VertexBuffer.NormalKind:
            return "NORMAL";
        case VertexBuffer.TangentKind:
            return "TANGENT";
        case VertexBuffer.ColorKind:
            return "COLOR_0";
        case VertexBuffer.UVKind:
            return "TEXCOORD_0";
        case VertexBuffer.UV2Kind:
            return "TEXCOORD_1";
        case VertexBuffer.UV3Kind:
            return "TEXCOORD_2";

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Register/export only known VertexBuffer kinds, or remove custom-kind buffers before export
  2. Extend/patch GetAccessorType (and GetAttributeType) to map your custom kind to an accessor type (glTF requires a known _CUSTOM attribute naming)
  3. Rename the attribute kind to a standard one (position, normal, tangent, uv..uv6, color, matrices indices/weights) if it represents the same data
  4. Catch the error and skip unknown attributes during export

Example fix

// before
mesh.setVerticesBuffer(new VertexBuffer(engine, data, "myattr", true)); // GetAccessorType throws
// after
mesh.setVerticesBuffer(new VertexBuffer(engine, data, VertexBuffer.UVKind, true)); // known kind maps to VEC2
Defensive patterns

Strategy: type-guard

Validate before calling

const KNOWN_KINDS = ["position","normal","tangent","uv","uv2","uv3","uv4","uv5","uv6","color","matricesIndices","matricesWeights","matricesIndicesExtra","matricesWeightsExtra"];
const isKnownKind = (kind: string): boolean => KNOWN_KINDS.includes(kind);
// remove or rename unknown buffers before export

Type guard

function isExportableVertexKind(kind: string): boolean {
    return kind === VertexBuffer.PositionKind || kind === VertexBuffer.NormalKind || kind === VertexBuffer.TangentKind || /^uv[1-6]?$/.test(kind) || kind === VertexBuffer.ColorKind || kind.startsWith("matrices");
}

Try / catch

try {
    await GLTF2Export.GLTFAsync(scene, "scene");
} catch (e) {
    if (e instanceof Error && e.message.startsWith("Unknown kind")) {
        // strip custom attributes and retry, or register a mapping
    } else { throw e; }
}

Prevention

When it happens

Trigger: Exporting a mesh with a custom vertex buffer registered under a nonstandard kind string (e.g. mesh.setVerticesBuffer(new VertexBuffer(..., "myCustomAttr"))) that is not handled by the switch, passed to _exportVertexBuffer during GLTFExporter export.

Common situations: Custom shaders with user-defined attributes whose buffers were added directly to the mesh; typos in kind names (e.g. 'uvs' instead of 'uv'); plugin-generated attributes from newer Babylon versions not yet mapped in this serializer.

Related errors


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