{"record":{"id":"48de8d8f27488cf6","repo":"mrdoob/three.js","slug":"three-mathutils-invalid-component-type","errorCode":null,"errorMessage":"THREE.MathUtils: Invalid component type.","messagePattern":"THREE\\.MathUtils: Invalid component type\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/math/MathUtils.js","lineNumber":422,"sourceCode":"\t\tcase Uint8Array:\n\n\t\t\treturn value / 255.0;\n\n\t\tcase Int32Array:\n\n\t\t\treturn Math.max( value / 2147483647.0, - 1.0 );\n\n\t\tcase Int16Array:\n\n\t\t\treturn Math.max( value / 32767.0, - 1.0 );\n\n\t\tcase Int8Array:\n\n\t\t\treturn Math.max( value / 127.0, - 1.0 );\n\n\t\tdefault:\n\n\t\t\tthrow new Error( 'THREE.MathUtils: Invalid component type.' );\n\n\t}\n\n}\n\n/**\n * Normalizes the given value according to the given typed array.\n *\n * @param {number} value - The float value in the range `[0,1]` to normalize.\n * @param {TypedArray} array - The typed array that defines the data type of the value.\n * @return {number} The normalize value.\n */\nfunction normalize( value, array ) {\n\n\tswitch ( array.constructor ) {\n\n\t\tcase Float32Array:\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/math/MathUtils.js#L404-L440","documentation":"Thrown by MathUtils.denormalize(value, array) when array.constructor is not one of the supported TypedArray constructors (Float32Array, Uint32Array, Uint16Array, Uint8Array, Int32Array, Int16Array, Int8Array). denormalize converts a raw integer stored in a typed array back to a float in [0,1] or [-1,1]; only the listed types have a defined scale factor.","triggerScenarios":"Calling THREE.MathUtils.denormalize(value, array) with a plain Array, a BigInt64Array/BigUint64Array, a DataView, or a sub-classed TypedArray whose constructor differs. Also passing an array whose buffer was transferred/sliced such that constructor identity is unexpected (rare).","commonSituations":"Morph-target or attribute compression code that passes the raw JS array instead of the TypedArray. Custom typed-array subclasses. Using 64-bit integer arrays which denormalize does not support.","solutions":["Pass a standard TypedArray instance (Float32Array, Uint8Array, Int16Array, etc.), not a plain Array.","If you have a plain array, convert first: new Float32Array(plainArray).","Avoid BigInt64Array/BigUint64Array for attributes that go through denormalize; use a supported 8/16/32-bit type.","If you sub-classed a TypedArray, pass the underlying base TypedArray instance instead."],"exampleFix":"// before: passing a plain array\nconst v = THREE.MathUtils.denormalize(128, [0,128,255]); // throws\n\n// after: use a supported TypedArray\nconst v = THREE.MathUtils.denormalize(128, new Uint8Array([0,128,255]));","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = [Float32Array, Uint32Array, Uint16Array, Uint8Array, Int32Array, Int16Array, Int8Array];\n\nfunction isDenormalizable(array) {\n  return SUPPORTED.some(T => array instanceof T || array.constructor === T);\n}\n\nif (!isDenormalizable(array)) array = new Float32Array(array);","typeGuard":"function isSupportedTypedArray(array) {\n  const T = array && array.constructor;\n  return [Float32Array, Uint32Array, Uint16Array, Uint8Array, Int32Array, Int16Array, Int8Array].includes(T);\n}","tryCatchPattern":null,"preventionTips":["Convert plain arrays to a standard TypedArray before calling denormalize.","Avoid BigInt64Array/BigUint64Array for denormalized attributes.","Pass the base TypedArray, not a subclass instance."],"tags":["threejs","typed-array","mathutils","denormalize","attribute"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}