{"record":{"id":"eb29db601b9bf7ed","repo":"BabylonJS/Babylon.js","slug":"draco-cannot-decode-invalid-data-type-datatype","errorCode":null,"errorMessage":"Draco: Cannot decode invalid data type ${dataType}","messagePattern":"Draco: Cannot decode invalid data type (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Meshes/Compression/dracoCompressionWorker.ts","lineNumber":261,"sourceCode":"            const dataType = attribute.data_type();\r\n            const numComponents = attribute.num_components();\r\n            const normalized = attribute.normalized();\r\n            const byteStride = attribute.byte_stride();\r\n            const byteOffset = attribute.byte_offset();\r\n\r\n            const dataTypeInfo: Record<number, { typedArrayConstructor: TypedArrayConstructor; heap: TypedArray }> = {\r\n                [decoderModule.DT_FLOAT32]: { typedArrayConstructor: Float32Array, heap: decoderModule.HEAPF32 },\r\n                [decoderModule.DT_INT8]: { typedArrayConstructor: Int8Array, heap: decoderModule.HEAP8 },\r\n                [decoderModule.DT_INT16]: { typedArrayConstructor: Int16Array, heap: decoderModule.HEAP16 },\r\n                [decoderModule.DT_INT32]: { typedArrayConstructor: Int32Array, heap: decoderModule.HEAP32 },\r\n                [decoderModule.DT_UINT8]: { typedArrayConstructor: Uint8Array, heap: decoderModule.HEAPU8 },\r\n                [decoderModule.DT_UINT16]: { typedArrayConstructor: Uint16Array, heap: decoderModule.HEAPU16 },\r\n                [decoderModule.DT_UINT32]: { typedArrayConstructor: Uint32Array, heap: decoderModule.HEAPU32 },\r\n            };\r\n\r\n            const info = dataTypeInfo[dataType];\r\n            if (!info) {\r\n                throw new Error(`Draco: Cannot decode invalid data type ${dataType}`);\r\n            }\r\n\r\n            const numValues = numPoints * numComponents;\r\n            const byteLength = numValues * info.typedArrayConstructor.BYTES_PER_ELEMENT;\r\n\r\n            const ptr = decoderModule._malloc(byteLength);\r\n            try {\r\n                decoder.GetAttributeDataArrayForAllPoints(geometry, attribute, dataType, byteLength, ptr);\r\n                const data = new info.typedArrayConstructor(info.heap.buffer, ptr, numValues);\r\n                onAttributeData(kind, data.slice(), numComponents, byteOffset, byteStride, normalized);\r\n            } finally {\r\n                decoderModule._free(ptr);\r\n            }\r\n        };\r\n\r\n        if (attributeIDs) {\r\n            for (const kind in attributeIDs) {\r\n                const id = attributeIDs[kind];\r","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Meshes/Compression/dracoCompressionWorker.ts#L243-L279","documentation":"When copying an attribute out of Draco's WASM heap, processAttribute looks up the attribute's data type in a table covering DT_INT8, DT_UINT8/16/32, DT_INT16, DT_INT32, DT_FLOAT32 and DT_FLOAT64. If the Draco attribute reports a data type not in this table (or dataType is undefined), it throws this Error since no typed array constructor or heap view exists for it.","triggerScenarios":"An attribute in the decoded Draco geometry uses a data type outside the supported set — e.g. data encoded with a newer Draco version introducing new DT_* types, or attributes whose data type cannot be resolved (dataType undefined).","commonSituations":"Assets produced by newer/older Draco encoders than the bundled decoder; hand-authored Draco files with exotic attribute types; custom attributes (generics) using types Babylon's worker does not map.","solutions":["Re-encode the asset restricting attributes to standard types (FLOAT32 positions, UINT8/16/32 indices, etc.).","Upgrade/downgrade the draco_decoder module so its DT_* enum matches the encoder's types.","Extend the dataTypeInfo table locally if you control the worker and need the extra type.","Skip unsupported attributes instead of failing the whole decode if they are optional."],"exampleFix":"// before\nconst info = dataTypeInfo[dataType]; // e.g. DT_BOOL (newer Draco) -> undefined -> throws\n\n// after\nconst info = dataTypeInfo[dataType];\nif (!info) {\n  console.warn('Skipping attribute with unsupported type ' + dataType);\n  return; // skip instead of throwing\n}","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = new Set([1, 3, 5, 2, 4, 6]); // DT_INT8..DT_FLOAT64 as used by the worker\nif (!SUPPORTED.has(dataType)) {\n  throw new Error('attribute uses unsupported Draco data type: ' + dataType);\n}","typeGuard":"const isSupportedDracoDataType = (t: number | undefined): t is number =>\n  typeof t === 'number' && t >= 1 && t <= 6; // DT_INT8(1)..DT_FLOAT64(6)","tryCatchPattern":"try {\n  geometry = await DecodeMesh(buffer);\n} catch (e) {\n  if (String(e?.message).includes('invalid data type')) {\n    console.warn('Falling back: attribute data type unsupported by decoder');\n    return decodeWithRawDracoModule(buffer); // or request re-encoded asset\n  }\n  throw e;\n}","preventionTips":["Re-encode assets using only standard Draco data types (FLOAT32 attributes).","Match draco_decoder version with the encoder version to keep DT_* enums aligned.","Test-decode all pipeline assets with the exact decoder build shipped to users.","Handle custom/generic attributes explicitly rather than assuming default typing."],"tags":["draco","decoding","attributes","type-mapping"],"backgroundTag":"unsupported-data-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}