{"record":{"id":"410fa80e745f5962","repo":"mrdoob/three.js","slug":"three-webglattributes-unsupported-buffer-data-for","errorCode":null,"errorMessage":"THREE.WebGLAttributes: Unsupported buffer data format: ","messagePattern":"THREE\\.WebGLAttributes: Unsupported buffer data format: ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderers/webgl/WebGLAttributes.js","lineNumber":66,"sourceCode":"\t\t} else if ( array instanceof Int32Array ) {\n\n\t\t\ttype = gl.INT;\n\n\t\t} else if ( array instanceof Int8Array ) {\n\n\t\t\ttype = gl.BYTE;\n\n\t\t} else if ( array instanceof Uint8Array ) {\n\n\t\t\ttype = gl.UNSIGNED_BYTE;\n\n\t\t} else if ( array instanceof Uint8ClampedArray ) {\n\n\t\t\ttype = gl.UNSIGNED_BYTE;\n\n\t\t} else {\n\n\t\t\tthrow new Error( 'THREE.WebGLAttributes: Unsupported buffer data format: ' + array );\n\n\t\t}\n\n\t\treturn {\n\t\t\tbuffer: buffer,\n\t\t\ttype: type,\n\t\t\tbytesPerElement: array.BYTES_PER_ELEMENT,\n\t\t\tversion: attribute.version,\n\t\t\tsize: size\n\t\t};\n\n\t}\n\n\tfunction updateBuffer( buffer, attribute, bufferType ) {\n\n\t\tconst array = attribute.array;\n\t\tconst updateRanges = attribute.updateRanges;\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/renderers/webgl/WebGLAttributes.js#L48-L84","documentation":"Thrown by the legacy WebGLAttributes (WebGLRenderer path) when a BufferAttribute's `.array` is not a recognized typed-array type. Identical in spirit to the WebGL-fallback variant: only Float32Array, (Float16-marked) Uint16Array, Uint16Array, Int16Array, Uint32Array, Int32Array, Int8Array, Uint8Array, and Uint8ClampedArray are accepted because each maps to a concrete WebGL buffer type.","triggerScenarios":"Using WebGLRenderer (not WebGPURenderer) and creating a BufferAttribute with a plain Array, Float64Array, BigInt64Array, DataView, or other non-typed-array as the `.array`.","commonSituations":"Assigning parsed JSON arrays directly to geometry attributes without converting to a typed array. Custom geometry builders returning native arrays. Mixing Float64 data on the CPU and forgetting to downcast. Examples copied from non-three sources.","solutions":["Convert to a typed array: `new BufferAttribute(new Float32Array(coords), 3)`.","Pick the typed array matching your GPU integer/float needs (Uint32Array for indices, Int8Array for byte attributes, etc.).","Downcast Float64 computation results to Float32Array before upload.","Run a one-line assertion `Number.isFinite(attr.array.BYTES_PER_ELEMENT)` to catch plain arrays early."],"exampleFix":"// before\nconst geom = new BufferGeometry();\ngeom.setAttribute('position', new BufferAttribute(rawPositionsArray, 3)); // throws\n\n// after\ngeom.setAttribute('position', new BufferAttribute(new Float32Array(rawPositionsArray), 3));","handlingStrategy":"type-guard","validationCode":"function makeAttribute(data, itemSize, T = Float32Array) {\n  const array = data instanceof ArrayBuffer ? new T(data) : (Array.isArray(data) ? new T(data) : data);\n  if (!ArrayBuffer.isView(array)) throw new TypeError('attribute array must be a typed array');\n  return new THREE.BufferAttribute(array, itemSize);\n}","typeGuard":"function isSupportedTypedArray(array) {\n  return ArrayBuffer.isView(array) && typeof array.BYTES_PER_ELEMENT === 'number' && !(array instanceof Float64Array) && !(array instanceof BigUint64Array) && !(array instanceof BigInt64Array);\n}","tryCatchPattern":null,"preventionTips":["Convert parsed JSON / plain arrays into typed arrays before assigning to BufferAttribute.","Use Float32Array for vertex data, Uint32Array/Uint16Array for indices.","Assert BYTES_PER_ELEMENT is defined on attribute arrays during development."],"tags":["webgl","buffer-attribute","typed-array","geometry","data-format","webglrenderer"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}