Nodes/ComfyUI-3D-MeshTool/img bath rotationZ
ComfyUI Node

img bath rotationZ

Straighten the multi-view batch so your camera angles actually line up

By 807502278·Created 2 years ago·Updated 2 years ago· 23
img bath rotationZ
  • rotation
  • image_bath
  • rotation_Z0
  • Image_z0
flip_angletrue

If you've ever fed a multi-view image batch into a 3D reconstruction pipeline and gotten twisted, sideways frames back, this is the node that fixes it. img bath rotationZ takes a batch of images plus the rotation data that describes where each shot was taken, and physically rotates every image by its Z (azimuth) angle so the batch matches the camera rig. It's the classic "your renderer wants upright views, your dataset gave you angled views" fix.

This is a node from ComfyUI-3D-MeshTool, a niche 3D-processing pack that sits alongside ComfyUI-3D-Pack and reuses its data types. Nobody on Reddit is really talking about this pack - the docs are thin and partly machine-translated, so the source in custom_nodes/ComfyUI-3D-MeshTool is your best friend when things behave oddly.

How it works

You feed it three things: a rotation tensor (typically from json-to-campos or RT-to-camposes, each row being one camera's angles), an image_bath (the batch of frames), and a flip_angle boolean.

Under the hood it grabs the Z component of each rotation and calls torchvision.transforms.functional.rotate on the matching image. Here's the gotcha most people hit first: flip_angle is on by default, which negates the Z angle. That's not a bug - the 3D-Pack camera convention points down the −Z axis, so the visual rotation you want is the opposite sign of the stored azimuth. If your rotated frames come out upside-down or mirrored in rotation, flip it off and see which way your data wants to go.

The node also zeroes out the X and Y columns of the rotation tensor it returns, so the rotation_Z0 output carries only the azimuth. That's deliberate: downstream camera math for this rig only cares about the orbit angle.

Inputs and outputs that matter

  • rotation (Tensor) - one row per image, at least 3 columns, Z used as the angle.
  • image_bath (IMAGE) - the batch to rotate.
  • flip_angle (BOOLEAN, default true) - the sign convention toggle.

Outputs: rotation_Z0 (Tensor, azimuth-only rotation) and Image_z0 (the rotated batch).

Install

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-3D-MeshTool
cd ComfyUI-3D-MeshTool
pip install -r requirements.txt

Then restart ComfyUI. ComfyUI Manager also has it - search "ComfyUI-3D-MeshTool". The requirements (kiui, xatlas, pyfqmr, plyfile) are small and there are no model files to download. The kiui package is the heavy one; it drags in torch/trimesh, which you almost certainly already have.

Common issues

The two errors this node prints are worth knowing before they hit you. First, the image batch must be bigger than one frame - a single image just triggers a warning and passes through untouched. Second, the number of rotations must equal the batch size; if they don't match it prints an error and leaves your images unrotated, so check the counts when you chain it after json-to-campos. Missing-rotation mismatches are the most common way this node silently does nothing. The rotation fill is mid-gray (0.5), so don't panic when rotated frames show gray edges - that's expected behavior, not corruption.

Category3D_MeshTool/Camera

Inputs (3)

NameTypeDefaultDescription
rotationTensor
image_bathIMAGE
flip_angleBOOLEANtrue

Outputs (2)

NameTypeDescription
rotation_Z0Tensor
Image_z0IMAGE