{"record":{"id":"97c0292a4d659e76","repo":"BabylonJS/Babylon.js","slug":"unknown-kind-kind","errorCode":null,"errorMessage":"Unknown kind ${kind}","messagePattern":"Unknown kind (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/serializers/src/glTF/2.0/glTFUtilities.ts","lineNumber":110,"sourceCode":"        case VertexBuffer.PositionKind:\r\n        case VertexBuffer.NormalKind:\r\n            return AccessorType.VEC3;\r\n        case VertexBuffer.TangentKind:\r\n        case VertexBuffer.MatricesIndicesKind:\r\n        case VertexBuffer.MatricesIndicesExtraKind:\r\n        case VertexBuffer.MatricesWeightsKind:\r\n        case VertexBuffer.MatricesWeightsExtraKind:\r\n            return AccessorType.VEC4;\r\n        case VertexBuffer.UVKind:\r\n        case VertexBuffer.UV2Kind:\r\n        case VertexBuffer.UV3Kind:\r\n        case VertexBuffer.UV4Kind:\r\n        case VertexBuffer.UV5Kind:\r\n        case VertexBuffer.UV6Kind:\r\n            return AccessorType.VEC2;\r\n    }\r\n\r\n    throw new Error(`Unknown kind ${kind}`);\r\n}\r\n\r\nexport function GetAttributeType(kind: string): string {\r\n    switch (kind) {\r\n        case VertexBuffer.PositionKind:\r\n            return \"POSITION\";\r\n        case VertexBuffer.NormalKind:\r\n            return \"NORMAL\";\r\n        case VertexBuffer.TangentKind:\r\n            return \"TANGENT\";\r\n        case VertexBuffer.ColorKind:\r\n            return \"COLOR_0\";\r\n        case VertexBuffer.UVKind:\r\n            return \"TEXCOORD_0\";\r\n        case VertexBuffer.UV2Kind:\r\n            return \"TEXCOORD_1\";\r\n        case VertexBuffer.UV3Kind:\r\n            return \"TEXCOORD_2\";\r","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/serializers/src/glTF/2.0/glTFUtilities.ts#L92-L128","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Register/export only known VertexBuffer kinds, or remove custom-kind buffers before export","Extend/patch GetAccessorType (and GetAttributeType) to map your custom kind to an accessor type (glTF requires a known _CUSTOM attribute naming)","Rename the attribute kind to a standard one (position, normal, tangent, uv..uv6, color, matrices indices/weights) if it represents the same data","Catch the error and skip unknown attributes during export"],"exampleFix":"// before\nmesh.setVerticesBuffer(new VertexBuffer(engine, data, \"myattr\", true)); // GetAccessorType throws\n// after\nmesh.setVerticesBuffer(new VertexBuffer(engine, data, VertexBuffer.UVKind, true)); // known kind maps to VEC2","handlingStrategy":"type-guard","validationCode":"const KNOWN_KINDS = [\"position\",\"normal\",\"tangent\",\"uv\",\"uv2\",\"uv3\",\"uv4\",\"uv5\",\"uv6\",\"color\",\"matricesIndices\",\"matricesWeights\",\"matricesIndicesExtra\",\"matricesWeightsExtra\"];\nconst isKnownKind = (kind: string): boolean => KNOWN_KINDS.includes(kind);\n// remove or rename unknown buffers before export","typeGuard":"function isExportableVertexKind(kind: string): boolean {\n    return kind === VertexBuffer.PositionKind || kind === VertexBuffer.NormalKind || kind === VertexBuffer.TangentKind || /^uv[1-6]?$/.test(kind) || kind === VertexBuffer.ColorKind || kind.startsWith(\"matrices\");\n}","tryCatchPattern":"try {\n    await GLTF2Export.GLTFAsync(scene, \"scene\");\n} catch (e) {\n    if (e instanceof Error && e.message.startsWith(\"Unknown kind\")) {\n        // strip custom attributes and retry, or register a mapping\n    } else { throw e; }\n}","preventionTips":["Use VertexBuffer.* constants (not raw strings) for all kinds to avoid typos","Keep custom shader attributes in user-defined mesh metadata rather than vertex buffer kinds when exporting","Before export, iterate mesh.getVerticesData keys and assert each is a known kind","When adding new VertexBuffer kinds in the engine, update the serializer's mappings"],"tags":["gltf","export","vertex-buffer","attribute-mapping","serialization"],"backgroundTag":"unknown-vertex-attribute-kind","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}