{"record":{"id":"5ed7aa5e0993687f","repo":"BabylonJS/Babylon.js","slug":"draco-cannot-decode-invalid-geometry-type-type","errorCode":null,"errorMessage":"Draco: Cannot decode invalid geometry type ${type}","messagePattern":"Draco: Cannot decode invalid geometry type (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Meshes/Compression/dracoCompressionWorker.ts","lineNumber":236,"sourceCode":"                } finally {\r\n                    decoderModule._free(ptr);\r\n                }\r\n\r\n                geometry = mesh;\r\n                break;\r\n            }\r\n            case decoderModule.POINT_CLOUD: {\r\n                const pointCloud = new decoderModule.PointCloud();\r\n                status = decoder.DecodeBufferToPointCloud(buffer, pointCloud);\r\n                if (!status.ok() || !pointCloud.ptr) {\r\n                    throw new Error(status.error_msg());\r\n                }\r\n\r\n                geometry = pointCloud;\r\n                break;\r\n            }\r\n            default: {\r\n                throw new Error(`Draco: Cannot decode invalid geometry type ${type}`);\r\n            }\r\n        }\r\n\r\n        const numPoints = geometry.num_points();\r\n\r\n        const processAttribute = (decoder: Decoder, geometry: Mesh | PointCloud, kind: string, attribute: any /** Attribute */) => {\r\n            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","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Meshes/Compression/dracoCompressionWorker.ts#L218-L254","documentation":"DecodeMesh switches on decoder.GetEncodedGeometryType(buffer) and only handles TRIANGULAR_MESH and POINT_CLOUD. Any other (or unknown) geometry type falls into the default branch and throws this Error, because Babylon has no decoding path for it.","triggerScenarios":"Decoding a Draco buffer whose encoded geometry type is neither TRIANGULAR_MESH nor POINT_CLOUD (e.g. invalid/corrupted data causing GetEncodedGeometryType to return an unexpected value, or a future/unknown Draco geometry type).","commonSituations":"Corrupted headers making the type byte garbage; decoding arbitrary binary data that merely resembles Draco; using a decoder that returns -1/INVALID for failed type detection.","solutions":["Validate the input is genuine Draco data before decoding (magic bytes / known source).","Re-export the asset ensuring it is encoded as a mesh or point cloud.","Check for buffer truncation that corrupts the geometry type field.","If the type is valid but unsupported by Babylon, decode it with the raw Draco module directly instead."],"exampleFix":"// before\nconst geo = await DecodeMesh(buffer); // buffer is not Draco -> type = -1\n\n// after\nfunction isLikelyDraco(buf: ArrayBuffer) { return buf.byteLength > 5; } // plus real validation\nif (isLikelyDraco(buffer)) {\n  const geo = await DecodeMesh(buffer);\n}","handlingStrategy":"try-catch","validationCode":"// decode and inspect geometry type before relying on Babylon's worker\ntype === decoderModule.TRIANGULAR_MESH || type === decoderModule.POINT_CLOUD\n  ? proceed : reject('unsupported Draco geometry type: ' + type);","typeGuard":"const isSupportedGeometryType = (type: number): type is 0 | 1 =>\n  type === 0 /* TRIANGULAR_MESH */ || type === 1 /* POINT_CLOUD */;","tryCatchPattern":"try {\n  geometry = await DecodeMesh(buffer);\n} catch (e) {\n  if (String(e?.message).includes('invalid geometry type')) {\n    throw new Error('Asset is not a decodable Draco mesh/point cloud; check source data');\n  }\n  throw e;\n}","preventionTips":["Only feed the decoder buffers from trusted Draco sources.","Check for truncation/corruption before decoding (headers include the type).","Fail fast in CI by decoding every compressed asset once at build time.","Pin decoder module versions to avoid unknown new geometry types."],"tags":["draco","decoding","geometry","validation"],"backgroundTag":"unsupported-geometry-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}