> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nodi3d.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> This tutorial explains the basic usage of Nodi through an example of creating an attractor.

This example demonstrates a grid of spheres that change in size based on their distance from an input point.\
Here is the link to the final example: [https://app.nodi3d.com/?example=Attractor](https://app.nodi3d.com/?example=Attractor)

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/f74cce91-0dca-4070-8f2f-0491a9b5aa13" />

## Add a Sphere Node

To add a node, double-click on the node canvas or press the Tab key to open the node search menu.\
You can browse through the node categories to find the desired node. Alternatively, you can type the node name into the search bar to add it.
In the node search bar, type `Sphere` to display the `Sphere` node as a suggestion. Click on it to add it.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/a10762a9-bf70-481e-b41d-405b39d58822" />

## Check the Node Information

When you click on a node placed on the node canvas, the information of the selected node is displayed in the Node Inspector.

In the Inspector, you can configure the properties of the node and check the data output by the node.

The `Sphere` node has properties representing its center position and radius. By editing these properties in the Inspector, you can adjust the shape generated by the Sphere node.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/6b3f1906-db2e-4037-9432-bc7b15627a9a" />

Each node has input parameters and output parameters. By connecting the output of one node to the input of another, you can create data flows and perform modeling.
This structure, composed of nodes that hold data and edges that connect the nodes, is called a **node graph**.

You can check what type of data a node's input expects and what data is available from its output by hovering your mouse over the input or output sections.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/9d7d8f70-6bb0-4082-9c8d-9da42f191e2e" />

## Create a Data Flow

Try connecting a node that outputs a numerical value to the Sphere node to parametrically change the radius of the sphere.

Add a `Number Slider` to the node canvas and connect it to the `Sphere` node.\
You can create an edge between nodes by clicking on the input/output section of a node and dragging it to the desired connection point.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/8fcec907-ca02-497d-be2a-408b8b243aa1" />

With the Number Slider's output connected to the radius input of the Sphere node, you can observe the sphere's size change as you adjust the output value in the Number Slider's Inspector.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/e987b137-32a8-4386-80c4-72d9807975dc" />

This achieves the simplest form of parametric modeling!

### How to Disconnect Nodes

To disconnect an edge between nodes, right-click on the input or output connected by the edge and select **Disconnect** from the menu.

Alternatively, you can hold the **\[Ctrl or Command]** key and left-drag to activate a drawing tool for quickly cutting multiple edges at once.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/fcdc98bd-d5e2-4f1d-b94d-a12d3b900227" />

## Move a Sphere

By connecting the output of the `Sphere` node to a `Move` node, you can change the position of the sphere.

The `Move` node accepts geometry data to be moved and a vector representing the translation offset. This vector data can also be modified directly in the Inspector.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/30a78abc-a15a-4919-b743-cce6c35774cd" />

At this point, you may notice that two spheres are displayed.\
This happens because the geometry output from the original `Sphere` node and the geometry moved by the `Move` node are both being displayed.

If you want to hide certain geometry, you can turn off the visibility setting of the node that outputs that geometry.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/d9b27de8-a0c9-463d-b428-66d49967eacd" />

## Arrange Spheres in a Grid

Add a `Square Grid` node to the node canvas.\
The `Square Grid` node allows you to create a grid with square cells by specifying its size and the number of divisions in the x and y directions.

The `Square Grid` outputs rectangle curves representing each cell and the positional data of the grid's vertices. This vertex information can be viewed in the Inspector.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/dea4ee99-c6fc-482d-a449-b27951f74b08" />

By connecting the position data output of the `Square Grid`, which represents its vertices, to the translation vector input of the `Move` node, you can arrange spheres in a grid pattern.

<img width="1136" alt="t8-arrange-grid" src="https://github.com/user-attachments/assets/f6650eb1-1953-4fe0-96be-dbddae73a21a" />

## Create an Attractor

An **attractor** is an object that influences other objects based on spatial relationships, such as distance.\
In following sections, we will create an attractor that changes the size of spheres based on their distance from the attractor.

First, create the attractor's position data using a `Construct Point` node.

Next, calculate the distance between the vertex coordinates output from the Square Grid and the attractor's position using a `Distance` node.

<img width="1136" alt="t9-attractor-distance" src="https://github.com/user-attachments/assets/2a47177e-f33d-467f-9e03-596c734569fc" />

To change the size of the geometry arranged on the grid via the `Move` node, use a `Scale` node. The `Scale` node takes the following inputs:

* Geometry to scale
* Center point for scaling
* Scale factor

Connect the output of the `Move` node to the geometry input of the Scale node,\
and the output of the `Square Grid` to the center position input.

[https://github.com/user-attachments/assets/8adb6512-37cb-4f1e-8c19-50ac482adcac](https://github.com/user-attachments/assets/8adb6512-37cb-4f1e-8c19-50ac482adcac)

Finally, connect the output of the `Distance` node to the scale factor input of the `Scale` node. This completes a node graph where the sphere sizes change based on their distance from the attractor's position.

However, directly inputting the `Distance` values into the scale factor would result in values that are too large. To address this, use a `Division` node to scale down the `Distance` values before connecting them to the `Scale` node.

<img width="1136" alt="t11-scale-by-attractor" src="https://github.com/user-attachments/assets/ee90b069-7ef8-4511-a133-3cb28e11fa48" />

## Adjust the Attractor's Position to Be Relative to the Grid

In the current setup, you can edit the attractor's position by adjusting the XY properties of the `Construct Point` node. However, the attractor's position is not relative to the grid size, so when the grid size changes, the attractor's position becomes misaligned.

For example, if the grid size spans **X: 0 to 10** and **Y: 0 to 10**, and the attractor is positioned at **(5, 5)**, it will be perfectly centered on the grid.

<img width="659" alt="t12-grid-center" src="https://github.com/user-attachments/assets/c9c202af-fc5e-4370-a2e5-e3c72e84b9e3" />

However, if the grid size doubles along both the X and Y axes(**0 to 20**), the attractor's position remains at **(5, 5)**, which is no longer the center of the grid.

<img width="655" alt="t13-grid-non-center" src="https://github.com/user-attachments/assets/c7f827a4-f488-4bf3-9978-e8d1014da26d" />

This misalignment occurs because the attractor's position is defined in absolute terms rather than being relative to the grid's size.

To make the attractor's position relative to the grid size, first modify the setup to output the grid's size as a variable from a separate node.

The grid size is determined by two inputs of the `Square Grid` node:

* The input that sets the size of each cell.
* The inputs that set the number of cells along the X and Y axes.

Edit the node graph so that these inputs are influenced by values output from `Number` nodes.

<img width="776" alt="t13-grid-variables" src="https://github.com/user-attachments/assets/553cd8c7-7ca3-4bdf-a22d-4ed75be6d29b" />

The grid size is calculated as **"cell size × number of cells"**.

To represent this, connect the outputs of the two **Number** nodes to a **Multiply** node.

<img width="843" alt="t14-multiply-grid-variables" src="https://github.com/user-attachments/assets/41988b78-fdc9-43c7-b243-b2b1985ed32b" />

The attractor's position will be determined using an `MDSlider` node.

The `MDSlider` node provides a UI for editing 2D values. The values edited in the Inspector always range from **0.0 to 1.0**. The actual output from the MDSlider is calculated based on the configured numerical range using the formula:

`output = (max - min) * t + min`

where `t` is the value in the range of **0.0 to 1.0**.

By connecting the previously calculated grid size values as inputs to the `MDSlider`, the coordinates output from the `MDSlider` will always fall within the range of **(0.0 to grid size)**.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/858486e8-b7dd-4e83-b4df-68a8a20a5b58" />

Finally, connect the output of the `MDSlider` to the input of the `Distance` node. This ensures that the attractor's position is determined relative to the grid size.

<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/50a72b89-e019-4c5d-9bbe-496cca67eb72" />

## It's Complete!

Now you have learned the basics of using Nodi.\
By exploring \[\[other examples|Examples]], you can discover the functionalities of various nodes and how to utilize them effectively.

Regarding this attractor example, note that the sphere's size and the scaling factor based on the attractor's distance are not yet relative to the grid. However, the attractor example available from the application has these aspects adjusted to be relative. Feel free to check it out if you're interested!
[https://app.nodi3d.com/?example=Attractor](https://app.nodi3d.com/?example=Attractor)
