Geometry scripting
Node graphs that generate and edit meshes, curves and instances, with timings shown on every node.
Geometry scripting is the procedural side of Nexara. A graph takes geometry in, changes it through nodes and outputs new geometry. The nodes are split by type into mesh, curve, instance, geometry, input and utility files under src/procedural/.
What flows along a link
A link carries geometry, a field, or a plain value such as a string or an object reference.
A field is a value that can differ per element. It can be a constant, an input read from the geometry (Position, Index or a named attribute), or a function of other fields. A node evaluates a field on the elements it is processing, and functions of constants are folded when the graph is built.
The shape of a socket shows what it accepts. A circle is a single value, a diamond is always a field, and a diamond with a dot can be either.
Sockets and types
Socket types are registered by ID, such as float, color or shader. Each type lists the implicit conversions it allows when linking, for example float to color. A node can change its sockets from its properties, so choosing a data type on a node retypes its inputs and outputs.
Nodes are looked up through a map from ID to position, because the evaluator calls find() for every node on every evaluation.
Debugging a graph
The evaluator records a result for each node, and the editor shows the time, whether the cached result was reused, a summary of the outputs and any problems.
The Scatter graph above covers a mesh in small spheres. Distribute Points on Faces creates 144 points in 0.03 ms, and Ico Sphere builds one 42 vertex sphere. Instance on Points places a sphere on each point in 0.04 ms, with a random scale from the Random Size node. Realize Instances turns them into 6,048 vertices in 5.17 ms, and Join Geometry merges them with the input mesh in 4.13 ms. The whole graph takes 9.45 ms.
The demo below uses the same layout of nodes in a much smaller form.
Node graph demo
Drag between sockets to rewire the graph, and drag a node by its title to move it. M mutes a node, which passes its input straight through. This is a small JavaScript version written for this site. Nexara's graph is C++.