{"record":{"id":"641d76ee440c3d50","repo":"BabylonJS/Babylon.js","slug":"cannot-transform-value-a","errorCode":null,"errorMessage":"Cannot transform value ${a}","messagePattern":"Cannot transform value (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.ts","lineNumber":214,"sourceCode":"    switch (className) {\n        case FlowGraphTypes.Vector2:\n            return (b as FlowGraphMatrix2D).transformVector(a as Vector2);\n        case FlowGraphTypes.Vector3:\n            return (b as FlowGraphMatrix3D).transformVector(a as Vector3);\n        case FlowGraphTypes.Vector4:\n            a = a as Vector4;\n            // transform the vector 4 with the matrix here. Vector4.TransformCoordinates transforms a 3D coordinate, not Vector4.\n            // Babylon's Matrix stores its elements column-major (m[0..3] is the first column), and the incoming\n            // float4x4 values are column-major as well, so M * a reads down the columns: value[i] = sum_j M[i][j] * a[j]\n            // with M[i][j] = m[j * 4 + i].\n            return new Vector4(\n                a.x * b.m[0] + a.y * b.m[4] + a.z * b.m[8] + a.w * b.m[12],\n                a.x * b.m[1] + a.y * b.m[5] + a.z * b.m[9] + a.w * b.m[13],\n                a.x * b.m[2] + a.y * b.m[6] + a.z * b.m[10] + a.w * b.m[14],\n                a.x * b.m[3] + a.y * b.m[7] + a.z * b.m[11] + a.w * b.m[15]\n            );\n        default:\n            throw new Error(`Cannot transform value ${a}`);\n    }\n}\n\n/**\n * Configuration for the transform block.\n */\nexport interface IFlowGraphTransformBlockConfiguration extends IFlowGraphBlockConfiguration {\n    /**\n     * The vector type\n     */\n    vectorType: FlowGraphTypes;\n}\n\n/**\n * Transform a vector3 by a matrix.\n */\nexport class FlowGraphTransformBlock extends FlowGraphBinaryOperationBlock<FlowGraphVector, FlowGraphMatrix, FlowGraphVector> {\n    constructor(config?: IFlowGraphTransformBlockConfiguration) {","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.pure.ts#L196-L232","documentation":"FlowGraphVectorMathBlocks' TransformVector applies a matrix to a vector but only supports 2D, 3D, and 4D Vector2/Vector3/Vector4 inputs. When the input `a` is none of those recognized types (or the matrix operand combination falls through the switch's default), it throws this message. It is a polymorphic-dispatch guard: the block cannot figure out how to multiply the given value by the given matrix.","triggerScenarios":"Calling the transform vector-math block with `a` being a scalar, quaternion, Matrix, null/undefined, or any non-Vector2/3/4 value, so the switch in TransformVector reaches its `default` branch.","commonSituations":"Wiring a wrong-typed data output (e.g. a quaternion or scalar from another block) into the transform block's input; JSON-authored graphs where a variable lost its type; refactors that changed the vector type of an upstream block.","solutions":["Ensure the input to the transform block is a BABYLON.Vector2, Vector3, or Vector4 matching the matrix dimensions","Insert a conversion block (e.g. Vector3 -> Vector4) or a correct-typed upstream block before the transform block","Add a type check on the incoming data input at graph-build time and fail fast with a clearer message"],"exampleFix":"// before\nconst result = TransformVector(myQuaternion, myMatrix); // throws\n// after\nconst vec = new Vector4(q.x, q.y, q.z, q.w);\nconst result = TransformVector(vec, myMatrix);","handlingStrategy":"validation","validationCode":"function isTransformable(v) { return v instanceof BABYLON.Vector2 || v instanceof BABYLON.Vector3 || v instanceof BABYLON.Vector4; }\nif (!isTransformable(input)) throw new TypeError('TransformVector requires Vector2/3/4, got ' + input);","typeGuard":"const isTransformable = (v: unknown): v is BABYLON.Vector2 | BABYLON.Vector3 | BABYLON.Vector4 =>\n  v instanceof BABYLON.Vector2 || v instanceof BABYLON.Vector3 || v instanceof BABYLON.Vector4;","tryCatchPattern":"try { result = TransformVector(a, m); } catch (e) { if (e.message.startsWith('Cannot transform value')) { /* substitute identity/fallback */ } else throw e; }","preventionTips":["Type-check data inputs at graph build time","Use typed data inputs (RichTypeVector3 etc.) so wrong types fail early","Validate serialized graph JSON against expected block input types"],"tags":["flow-graph","type-error","math"],"backgroundTag":"unsupported-input-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}