Nodes/WAS Node Suite v3/Three Import Geometry
ComfyUI Node Runs on cloud

Three Import Geometry

Pull one named shape out of a Script Module

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Three Import Geometry
  • module
  • geometry
export_namering

The Three suite gives you two ways to get custom geometry. The blunt way is Three Custom Geometry, one node, one body of JavaScript, one shape out. The organised way is a Three Script Module - a single JavaScript body that returns a whole collection of named resources, built once per viewer load - and then a Three Import Geometry node for each shape you actually want on the graph. This node is the adapter that pulls one geometry out of a module by name and puts it on a normal geometry wire, so Three Mesh can use it without ever knowing it came from JavaScript.

The inputs are almost insultingly simple. module takes the THREE_MODULE output of a Three Script Module, and export_name is the key you want out of it - the default body on the module returns { gold: ..., ring: new THREE.TorusGeometry(1, 0.2, 24, 96) }, so export_name: ring hands you that torus on the geometry output. Two rules, straight from the node's description: the name has to match a key the module actually returned, and the value behind that key has to be a geometry. Get either wrong and the viewer reports the problem by name, which is friendlier than a silent black hole.

Why bother with the two-step when Custom Geometry exists? If one script builds a palette of a dozen shapes and materials, a single Script Module runs that code once and the Import nodes fan the results out across however many meshes need them. Write the code in one place, change a material colour in one spot, and every mesh that imported it updates together. The geometry output behaves exactly like the one from Three Box Geometry or any other geometry node - straight into Three Mesh's geometry socket, indistinguishable downstream.

This is also the node that makes big custom scenes legible: instead of ten Custom Geometry nodes each hiding a blob of JavaScript in the middle of your graph, you get one module node with the code and ten tidy Import nodes doing the wiring. For scenes with more than a couple of custom shapes, that's the difference between a workflow you can read and a workflow you're scared to open.

The standing trust note applies at one remove: the geometry originates in JavaScript that runs in your browser, so the module feeding this node carries the same frontend reach as any Custom node. Only import from modules whose code you trust.

Installing it

Part of WAS Node Suite v3. Install via ComfyUI Manager (search WAS Node Suite v3) or:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git

Restart; needs ComfyUI 0.14.0+ / Python 3.10+. If the Three menu's missing, set features.threejs: true in <ComfyUI user dir>/was-node-suite/config.yaml.

If it reports an error

The viewer names the problem: an export_name that isn't a key in the module, or a key whose value isn't a geometry. The module's JavaScript errors surface in the browser when it loads - a module that fails to run returns nothing, and every Import node fed by it comes up empty at once.

CategoryWAS Suite/Three

Inputs (2)

NameTypeDefaultDescription
moduleTHREE_MODULEThe named resources to pick from, from Three Script Module.
export_nameSTRINGringWhich key to take, as `ring`. It must match a key the module returned.

Outputs (1)

NameTypeDescription
geometryTHREE_GEOMETRYThe named shape, for the geometry socket on Three Mesh.