{"record":{"id":"d4ab8175257ff9f5","repo":"BabylonJS/Babylon.js","slug":"context-error-message","errorCode":null,"errorMessage":"${context}: ${error.message}","messagePattern":"\\$\\{context\\}: \\$\\{error\\.message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.ts","lineNumber":119,"sourceCode":"            loadAttribute(\"TEXCOORD_2\", VertexBuffer.UV3Kind);\r\n            loadAttribute(\"TEXCOORD_3\", VertexBuffer.UV4Kind);\r\n            loadAttribute(\"TEXCOORD_4\", VertexBuffer.UV5Kind);\r\n            loadAttribute(\"TEXCOORD_5\", VertexBuffer.UV6Kind);\r\n            loadAttribute(\"JOINTS_0\", VertexBuffer.MatricesIndicesKind);\r\n            loadAttribute(\"WEIGHTS_0\", VertexBuffer.MatricesWeightsKind);\r\n            loadAttribute(\"COLOR_0\", VertexBuffer.ColorKind);\r\n\r\n            const bufferView = ArrayItem.Get(extensionContext, this._loader.gltf.bufferViews, extension.bufferView) as IBufferViewDraco;\r\n            if (!bufferView._dracoBabylonGeometry) {\r\n                bufferView._dracoBabylonGeometry = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView).then(async (data) => {\r\n                    const dracoDecoder = this.dracoDecoder || DracoDecoder.Default;\r\n                    const positionAccessor = ArrayItem.TryGet(this._loader.gltf.accessors, primitive.attributes[\"POSITION\"]);\r\n                    const babylonBoundingInfo =\r\n                        !this._loader.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton && positionAccessor ? LoadBoundingInfoFromPositionAccessor(positionAccessor) : null;\r\n                    return await dracoDecoder\r\n                        ._decodeMeshToGeometryForGltfAsync(babylonMesh.name, this._loader.babylonScene, data, attributes, normalized, babylonBoundingInfo)\r\n                        .catch((error) => {\r\n                            throw new Error(`${context}: ${error.message}`);\r\n                        });\r\n                });\r\n            }\r\n\r\n            return await bufferView._dracoBabylonGeometry;\r\n        });\r\n    }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Registers the KHR_draco_mesh_compression glTF loader extension.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function RegisterKHR_draco_mesh_compression(): void {\r\n    if (_Registered) {\r\n        return;\r","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.pure.ts#L101-L137","documentation":"This wraps any error raised during Draco mesh decoding into `${context}: ${error.message}` while building the geometry via _decodeMeshToGeometryForGltfAsync. The original draco decoder failure (corrupt compressed data, missing attributes, decoder errors) is re-thrown with the glTF JSON path context prepended so the failing primitive can be identified.","triggerScenarios":"A primitive with KHR_draco_mesh_compression whose compressed bufferView data is corrupt, truncated, or encoded with attributes that don't match the declared attributes/normalized map, causing the Draco decoder promise to reject.","commonSituations":"Truncated GLB uploads; assets compressed with an incompatible Draco encoder version; bufferView data modified/re-compressed incorrectly by post-processing tools; mismatch between extension.attributes ids and data inside the Draco buffer.","solutions":["Re-export/re-compress the asset with a current Draco encoder and verify it loads in a reference viewer","Ensure the GLB/buffer data is complete (re-upload; check byteLength)","Confirm extension.attributes attribute ids match the encoded Draco data","Check the underlying error.message in this wrapper for the true decoder cause and address it"],"exampleFix":"// before\nbufferView._dracoBabylonGeometry = decode(corruptBuffer) // rejects\n// after: re-export with gltf-transform + draco3d encoder, verify offline, then load","handlingStrategy":"try-catch","validationCode":"const bv = gltf.bufferViews[ext.bufferView];\nif (!bv || bv.byteLength === 0) throw new Error('Draco bufferView missing or empty');","typeGuard":null,"tryCatchPattern":"try {\n  await BABYLON.SceneLoader.LoadAsync('./', 'model.glb', engine);\n} catch (e) {\n  if (e instanceof Error && /\\/meshes\\/\\d+\\/primitives\\/\\d+/.test(e.message)) {\n    console.error(`Draco decode failed for primitive: ${e.message}`);\n    // fall back to loading a non-Draco variant of the asset\n  } else throw e;\n}","preventionTips":["Ship assets with known-good Draco encoding verified in a reference viewer","Verify GLB completeness (byteLength/hash) after transfer","Keep the Draco encoder version consistent across the pipeline","Match extension.attributes ids exactly to the encoded mesh attributes"],"tags":["gltf","extension","draco","decoder","corrupt-asset"],"backgroundTag":"draco-decode-failure","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}