{"record":{"id":"624fad342febc219","repo":"BabylonJS/Babylon.js","slug":"unsupported-attribute-type-type","errorCode":null,"errorMessage":"Unsupported attribute type: ${type}.","messagePattern":"Unsupported attribute type: (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Engines/Native/nativeHelpers.ts","lineNumber":371,"sourceCode":"}\r\n\r\nexport function getNativeAttribType(type: number): number {\r\n    switch (type) {\r\n        case VertexBuffer.BYTE:\r\n            return _native.Engine.ATTRIB_TYPE_INT8;\r\n        case VertexBuffer.UNSIGNED_BYTE:\r\n            return _native.Engine.ATTRIB_TYPE_UINT8;\r\n        case VertexBuffer.SHORT:\r\n            return _native.Engine.ATTRIB_TYPE_INT16;\r\n        case VertexBuffer.UNSIGNED_SHORT:\r\n            return _native.Engine.ATTRIB_TYPE_UINT16;\r\n        case VertexBuffer.FLOAT:\r\n            return _native.Engine.ATTRIB_TYPE_FLOAT;\r\n        // HALF_FLOAT (as well as INT and UNSIGNED_INT) has no equivalent in the native bindings, which only\r\n        // expose ATTRIB_TYPE_INT8/UINT8/INT16/UINT16/FLOAT. Those vertex attribute types are therefore\r\n        // WebGL/WebGPU only and intentionally fall through to the throw below on the Babylon Native engine.\r\n        default:\r\n            throw new Error(`Unsupported attribute type: ${type}.`);\r\n    }\r\n}\r\n","sourceCodeStart":353,"sourceCodeEnd":374,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Engines/Native/nativeHelpers.ts#L353-L374","documentation":"getNativeAttribType maps VertexBuffer component types (BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, FLOAT) to native ATTRIB_TYPE_* enums. HALF_FLOAT, INT and UNSIGNED_INT deliberately have no native equivalent (the bindings only expose int8/uint8/int16/uint16/float), so any other type throws. This means those attribute types are unsupported on the Babylon Native engine by design.","triggerScenarios":"Creating a VertexBuffer with HALF_FLOAT, INT (0x1404 gl.INT) or UNSIGNED_INT (0x1405 gl.UNSIGNED_INT) data on a NativeEngine, e.g. float16 attribute data or 32-bit integer indices/attributes.","commonSituations":"Loading glTF models using half-float attributes; porting a WebGL/WebGPU scene that used INT attributes to Babylon Native; asset pipelines emitting f16 vertex data.","solutions":["Convert vertex data to Float32Array (or 8/16-bit types) before creating the VertexBuffer.","Retarget the asset pipeline/glTF loader to avoid HALF_FLOAT accessors (normalize to float32).","If 32-bit data is unavoidable, keep that mesh on the WebGL/WebGPU engine rather than NativeEngine."],"exampleFix":"// before\nnew VertexBuffer(engine, halfFloatData, \"position\", false); // HALF_FLOAT\n// after\nnew VertexBuffer(engine, new Float32Array(convertHalfToFloat(halfFloatData)), \"position\", false);","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = new Set([BABYLON.VertexBuffer.BYTE, BABYLON.VertexBuffer.UNSIGNED_BYTE, BABYLON.VertexBuffer.SHORT, BABYLON.VertexBuffer.UNSIGNED_SHORT, BABYLON.VertexBuffer.FLOAT]);\nif (!SUPPORTED.has(vertexData.type)) {\n  vertexData = convertToFloat32(vertexData); // e.g. decode HALF_FLOAT to Float32Array\n}","typeGuard":"function isNativeSupportedAttribType(type: number): boolean {\n  const V = BABYLON.VertexBuffer;\n  return [V.BYTE, V.UNSIGNED_BYTE, V.SHORT, V.UNSIGNED_SHORT, V.FLOAT].includes(type);\n}","tryCatchPattern":"try {\n  mesh.setVerticesBuffer(kind, buffer);\n} catch (e) {\n  if (String(e.message).startsWith('Unsupported attribute type')) {\n    console.warn(`Converting ${kind} to FLOAT32 for NativeEngine`);\n    mesh.setVerticesBuffer(kind, toFloat32Buffer(buffer));\n  } else throw e;\n}","preventionTips":["Avoid HALF_FLOAT/INT/UNSIGNED_INT vertex attributes when targeting Babylon Native.","Configure glTF loading to decode f16 accessors to float32.","Test asset pipelines against NativeEngine before shipping."],"tags":["babylonjs","vertex-buffer","native-engine","unsupported-type"],"backgroundTag":"unsupported-vertex-attribute-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}