tensor new
Spawn a fresh tensor of any shape, filled or random, when you need a blank canvas
- tensor_shape
- Tensor
Sometimes you don't have data yet - you need a tensor to exist so you can test a workflow, drive a camera, or fill in a slot. tensor new (from ComfyUI-3D-MeshTool) creates a fresh tensor of whatever shape you ask for, either filled with a constant value or filled with random floats. It's the "blank sheet of paper" node of the pack's tensor side.
You'll reach for it when prototyping camera paths (spawn a [N, 3] tensor and feed it into RT-to-camposes), when you need placeholder data to test a downstream math chain, or when you want a deterministic starting point before running data through it.
How it works
Three inputs:
tensor_shape(TUPLE) - the dimensions. There's no built-in shape box on this node; the pack's tensor-shape node builds aTUPLEfrom five dimension integers and feeds it in.(10, 3)gives you a[10, 3]tensor.Value(FLOAT, default 0.5) - the fill value, used whenrandomis off.random(BOOLEAN, default false) - when toggled on, the node ignoresValueand fills the tensor withtorch.rand(...)uniform floats in [0, 1) instead.
Under the hood it's two one-liners: torch.full(tensor_shape, Value) or torch.rand(tensor_shape). Output is a float32 Tensor.
Output
Tensor- your new tensor.
Install
It's part of the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-3D-MeshTool
cd ComfyUI-3D-MeshTool
pip install -r requirements.txt
Restart ComfyUI, or install via ComfyUI Manager (search "ComfyUI-3D-MeshTool").
Notes
Two practical things. First, torch.rand re-rolls every time the graph runs - there's no seed input, so "random" workflows aren't reproducible through this node. If you need a fixed random tensor, generate it once, pass it through Tensor to List, and reuse the frozen values. Second, all-zero or all-0.5 tensors are genuinely useful for testing (a camera path of constant value still exercises the downstream math), but they're not real data - don't ship a render on a placeholder and wonder why every view looks identical.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| tensor_shape | TUPLE | — | |
| Value | FLOAT | 0.500-999999–999999 | — |
| random | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Tensor | Tensor | — |