{"record":{"id":"05b0d41d3b64dc78","repo":"BabylonJS/Babylon.js","slug":"context-unsupported-mode-primitive-mode","errorCode":null,"errorMessage":"${context}: Unsupported mode ${primitive.mode}","messagePattern":"(.+?): Unsupported mode (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.ts","lineNumber":69,"sourceCode":"        this._loader = loader;\r\n        this.enabled = DracoDecoder.DefaultAvailable && this._loader.isExtensionUsed(NAME);\r\n    }\r\n\r\n    /** @internal */\r\n    public dispose(): void {\r\n        delete this.dracoDecoder;\r\n        (this._loader as any) = null;\r\n    }\r\n\r\n    /**\r\n     * @internal\r\n     */\r\n    // eslint-disable-next-line no-restricted-syntax\r\n    public _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {\r\n        return GLTFLoader.LoadExtensionAsync<IKHRDracoMeshCompression, Geometry>(context, primitive, this.name, async (extensionContext, extension) => {\r\n            if (primitive.mode != undefined) {\r\n                if (primitive.mode !== MeshPrimitiveMode.TRIANGLES && primitive.mode !== MeshPrimitiveMode.TRIANGLE_STRIP) {\r\n                    throw new Error(`${context}: Unsupported mode ${primitive.mode}`);\r\n                }\r\n            }\r\n\r\n            const attributes: { [kind: string]: number } = {};\r\n            const normalized: { [kind: string]: boolean } = {};\r\n            const loadAttribute = (name: string, kind: string) => {\r\n                const uniqueId = extension.attributes[name];\r\n                if (uniqueId == undefined) {\r\n                    return;\r\n                }\r\n\r\n                babylonMesh._delayInfo = babylonMesh._delayInfo || [];\r\n                if (babylonMesh._delayInfo.indexOf(kind) === -1) {\r\n                    babylonMesh._delayInfo.push(kind);\r\n                }\r\n\r\n                attributes[kind] = uniqueId;\r\n\r","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.ts#L51-L87","documentation":"KHR_draco_mesh_compression only supports triangle-based primitive modes (TRIANGLES=4 and TRIANGLE_STRIP=5). _loadVertexDataAsync throws this when the primitive's mode is any other value (points, lines, etc.), because the Draco decoder produces triangle geometry only.","triggerScenarios":"Loading a glTF primitive with mode 0 (POINTS), 1 (LINES), 2 (LINE_LOOP), 3 (LINE_STRIP), or 6 (TRIANGLE_FAN) that also uses KHR_draco_mesh_compression.","commonSituations":"Exporters that Draco-compress all primitives regardless of mode; hand-toggled extensions on line/point primitives; assets combining wireframe/line geometry with Draco compression.","solutions":["Convert the primitive to TRIANGLES (or TRIANGLE_STRIP) in the asset, or remove Draco compression from non-triangle primitives","Re-export with the DCC tool configured to not compress non-triangle primitives","Split line/point geometry into separate non-Draco primitives/meshes","Use glTF-Validator to flag mode/extension incompatibilities before loading"],"exampleFix":"// before\n\"primitives\": [{ \"mode\": 1, \"extensions\": { \"KHR_draco_mesh_compression\": {...} } }]\n// after\n\"primitives\": [{ \"mode\": 4, \"extensions\": { \"KHR_draco_mesh_compression\": {...} } }]","handlingStrategy":"validation","validationCode":"for (const mesh of asset.meshes ?? []) {\n  for (const prim of mesh.primitives) {\n    if (prim.extensions?.KHR_draco_mesh_compression && ![4, 5].includes(prim.mode ?? 4)) {\n      throw new Error(`Draco primitive with unsupported mode ${prim.mode}`);\n    }\n  }\n}","typeGuard":"function isTriangleMode(mode: number | undefined): boolean {\n  return mode === undefined || mode === 4 || mode === 5;\n}","tryCatchPattern":"try {\n  await BABYLON.SceneLoader.LoadAsync('./', 'model.glb', engine);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Unsupported mode')) {\n    console.error('Draco primitive uses non-triangle mode; fix asset or drop Draco');\n  } else throw e;\n}","preventionTips":["Only apply Draco compression to TRIANGLES/TRIANGLE_STRIP primitives","Configure exporters not to compress line/point geometry","Run glTF-Validator in CI to catch mode/extension conflicts"],"tags":["gltf","extension","draco","primitive-mode"],"backgroundTag":"unsupported-primitive-mode","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}