Vec3UnaryOperation
Negate or normalize a 3D vector
- a
- VEC3
Two of the most common single-vector transforms, in one node: flip it, or scale it down to a pure direction. Vec3UnaryOperation takes one VEC3 and applies either, returning a new VEC3.
It's part of ComfyMath, evanspearman's math/logic pack, and it's the node that pairs directly with the pack's own CM_Vec3ToScalarUnaryOperation (Norm, for measuring a vector's length) and CM_Vec3UnaryCondition (IsNormalized, for checking whether one's already unit length) - the three together cover most of what you'd want to do with a single 3D vector.
How it works
Feed it a (VEC3, default [0, 0, 0]) and pick an op: Neg or Normalize. Neg flips all three components - reverses the direction, same magnitude, the kind of thing you'd do to point a surface normal the other way. Normalize scales the vector down so its length becomes 1 while keeping its direction - the standard move when you have a direction-plus-magnitude vector but only care about the direction going forward.
Worth knowing: normalizing a zero vector ([0, 0, 0]) is mathematically undefined - there's no direction to preserve when there's no vector to begin with. If your graph might feed this node a zero vector, guard against it with CM_Vec3UnaryCondition's IsZero check first, rather than assuming Normalize will hand back something sensible.
Neg is the safer of the two - it's defined everywhere, including on the zero vector (negating [0, 0, 0] just gives you [0, 0, 0] back), so it's the one you can use without a guard clause in front of it.
Inputs and outputs
op- Neg or Normalize.a(VEC3, default[0, 0, 0]) - the vector being transformed.- Output:
VEC3- the result.
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.
Common issues & troubleshooting
Normalize gives back something unexpected (NaN, zero, or an error). Check whether a could be [0, 0, 0] at that point in the graph - normalizing a zero-length vector isn't a well-defined operation, and this is the most likely source of a weird result. Guard it upstream with an IsZero check if there's any chance of that happening.
You expected Normalize's output length to read as exactly 1 in a downstream check. Floating-point math rarely lands on exactly 1.0 - if you're feeding this into CM_Vec3UnaryCondition's IsNormalized and it's coming back false, that's rounding error, not a bug.
Missing node error loading a shared workflow. Install ComfyMath via Manager as above, then reload.
Not sure you need Vec3 nodes. Most workflows don't touch them - this is for graphs doing their own 3D direction, offset, or coordinate math.
The pack looks unmaintained. A 2024 community thread noted the author had stepped back from active development. It's simple vector math with no external dependencies, so there's little for it to break on.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| op | COMBO | 2 options: Neg, Normalize | |
| a | VEC3 | 0,0,0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| VEC3 | VEC3 | — |