Nodes/ComfyMath/Vec3ScalarOperation
ComfyUI Node

Vec3ScalarOperation

Scale a 3D vector by a plain number

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

If you're carrying a position, an offset, or an RGB color as a single VEC3 and you need to scale the whole thing by one plain number - brighten a color, extend a displacement, shrink a 3D offset proportionally - this is the node for that, in one step instead of splitting into three components and doing the math three times.

It's part of ComfyMath, evanspearman's math/logic pack, and it's the vector-times-number counterpart to CM_Vec3BinaryOperation (vector-plus-vector).

How it works

Feed it a (a VEC3, default [0, 0, 0]) and b (a plain FLOAT - the scalar), pick an op: Mul or Div, and it applies that operation to all three components of a using b. Reach for this to uniformly scale a 3D position by a zoom factor, dim an RGB color by a brightness multiplier, or shrink a displacement vector without recomputing X, Y, and Z separately.

Worth flagging directly from the node's own definition: b doesn't ship with a default the way a does - a defaults to [0, 0, 0], but b has no listed default. Make sure you've actually set b to something deliberate before running the graph, especially with Div selected - dividing by an unset or zero scalar is the kind of thing that produces infinity or NaN silently rather than throwing an obvious error.

Inputs and outputs

  • op - Mul or Div.
  • a (VEC3, default [0, 0, 0]) - the vector being scaled.
  • b (FLOAT) - the scalar to multiply or divide by. No default shown - set it explicitly.
  • Output: VEC3 - the scaled vector.

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 to fetch - plain Python.

Common issues & troubleshooting

Output is infinity or NaN. Almost certainly a Div with b at or near zero. Since b doesn't have a guaranteed default, double-check what's actually wired into it (or typed into the widget) before trusting the result downstream. ComfyMath's CM_FloatUnaryCondition (IsZero) is a quick way to catch this before it happens rather than after.

A color or position looks doubled or halved unexpectedly. Confirm you picked the operation you meant - Mul and Div sit right next to each other in the dropdown, and it's an easy misclick.

Missing node error on workflow load. Install ComfyMath through Manager as above, then reload.

Not sure you need this node at all. Most workflows never touch Vec3 nodes - this shows up specifically when you're building your own coordinate, offset, or color math rather than a standard generation graph.

The pack looks unmaintained. A 2024 community thread noted the author had stepped back from active development. It's plain math with no external dependencies, so there's little here that a ComfyUI update is likely to break.

Categorymath/vec3

Inputs (3)

NameTypeDefaultDescription
opCOMBO2 options: Mul, Div
aVEC30,0,0
bFLOAT

Outputs (1)

NameTypeDescription
VEC3VEC3