Nodes/ComfyMath/Vec3BinaryOperation
ComfyUI Node

Vec3BinaryOperation

Add, subtract, or cross two 3D vectors

By evanspearman·Created 3 years ago·Updated about a year ago· 192
Vec3BinaryOperation
  • a
  • b
  • VEC3
op

Whenever a graph is carrying a position, an offset, or an RGB triple as one VEC3 instead of three loose floats, this is the node that combines two of them. Vec3BinaryOperation takes two three-component vectors and returns a third - add one displacement to another, find the vector between two points, or take their cross product.

It's part of ComfyMath, evanspearman's math/logic node pack, and it's the 3D sibling of CM_Vec2BinaryOperation - same three-way op choice, one more component per vector.

How it works

Feed it a and b, both VEC3 (default [0, 0, 0]), and pick an op: Add, Sub, or Cross. Add and Sub are plain component-wise arithmetic - useful for stacking offsets, finding the displacement between two points, or doing per-channel color math if you're treating a VEC3 as RGB. Cross is the one worth pausing on, but for a good reason this time: unlike the Vec2 version of this node (where "cross product" doesn't have a real 2D vector definition), the 3D cross product is a standard, well-defined operation - it takes two vectors and returns a third that's perpendicular to both. That's genuinely useful for anything involving surface normals, camera-up vectors, or figuring out which way is "sideways" relative to two given directions.

Worth remembering: cross product isn't commutative. Cross(a, b) and Cross(b, a) point in opposite directions - same magnitude, flipped sign. If your perpendicular vector is pointing the wrong way, swap the inputs rather than assuming the math is wrong.

Inputs and outputs

  • op - Add, Sub, or Cross.
  • a (VEC3, default [0, 0, 0]) and b (VEC3, default [0, 0, 0]) - the two vectors being combined.
  • Output: VEC3 - the result, ready to feed into another ComfyMath vector node.

How to install it

Through ComfyUI Manager: search ComfyMath, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/evanspearman/ComfyMath.git

then restart ComfyUI. No dependencies, no models - plain Python arithmetic.

Common issues & troubleshooting

Cross product points the "wrong" way. Swap a and b - cross product is anti-commutative, so reversing the operands flips the sign of the result. That's expected behavior, not a bug.

You wanted Cross but a and b are parallel (or one is zero). The cross product of two parallel vectors - or anything crossed with a zero vector - is itself the zero vector. There's no unique perpendicular direction to return in that case, so a [0, 0, 0] result usually means your two inputs are pointing the same way (or one of them isn't set), not a broken node.

A VEC3 output won't wire where you expect. VEC3 is a ComfyMath-specific type, distinct from three separate FLOAT sockets. If a downstream node wants individual components, split the vector first rather than wiring VEC3 straight into a FLOAT input.

Missing node error on a shared workflow. Install ComfyMath via Manager as above, then reload.

Not sure you need Vec3 nodes. Most generation workflows never touch them - they show up when you're doing your own 3D coordinate, camera, or lighting-style math rather than a standard checkpoint-to-image pipeline.

The pack looks unmaintained. A 2024 community thread noted the author had stepped back from active development. The Vec3 side of ComfyMath is its quietest corner, so treat it as small and stable rather than actively developed.

Categorymath/vec3

Inputs (3)

NameTypeDefaultDescription
opCOMBO3 options: Add, Sub, Cross
aVEC30,0,0
bVEC30,0,0

Outputs (1)

NameTypeDescription
VEC3VEC3