|
| 1 | +# three.js TSL Visual Node Editor |
| 2 | + |
| 3 | +## **[!] Work in progress | Alpha state** <br/> |
| 4 | +Visual node editor, inspired by [Blender's shader editor](https://www.blender.org/), is a tool to visually build [Three.js](https://threejs.org/) materials using [Three.js-Shading-Language](https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language). |
| 5 | + |
| 6 | +It is currently in development, and hoping to welcome developers from the comunity to jump in and add new nodes. Credit will be given to everyone! |
| 7 | + |
| 8 | +# How does it work? |
| 9 | +When you use the app: You create the nodes and the output will be a javascript file that will contain the nodes you created + the node setup in a comment, in case you want to edit the nodes after saving. In your real life project you will import the materials from this js, that will export an array of the materials. You will do something like... |
| 10 | + |
| 11 | +```js |
| 12 | +import { materials } from "./your-saved-file.js"; |
| 13 | +const material1 = materials[0]; //<-- this is a THREE.Material |
| 14 | +``` |
| 15 | + |
| 16 | +# How to collaborate? |
| 17 | +I did a few basic nodes, I think the skeleton is setup to allow for easy addition of new nodes, the ideal is for "you" to add new nodes or even improve the current ones. To do so, you must check the [Three.js-Shading-Language Docs](https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language) |
| 18 | + |
| 19 | +You can also fix bugs or improve the code/interface. Just clone and do a pull request. |
| 20 | + |
| 21 | +# == Nodes "done"... == |
| 22 | +These are the nodes currently "done" (room for improvement)... |
| 23 | +- UV Channel |
| 24 | +- Scene Preview |
| 25 | +- (incomplete) MeshStandardNode shader node. ( only colorNode property ) |
| 26 | +- Image texture node |
| 27 | + |
| 28 | +------ |
| 29 | +------ |
| 30 | +------ |
| 31 | + |
| 32 | +# Design / How it works... |
| 33 | +## Concepts / Building blocks |
| 34 | +- **Node** : they live in `src/nodes` they are the objects in charge of defining a node and whatever that node does. A Node is not a 1:1 recreation of a TSL node, a node can do a bunch of things, even use many nodes at the same time and build complex structures in TSL. |
| 35 | +- **Property** : Nodes are a bag filled with properties. They live in `src/properties` and each property is in charge of one aspect of the node. |
| 36 | +- **Outlet**: the input or output socket of a node. A node can have many of both. An outlet is a property that handles the connection between the outside and the node. |
| 37 | +- **Component**: The most basic UI unit. A button, a TextLabel, etc... |
| 38 | +- **Script**: Since this exports a javascript, a `src/export/Script` object is created the moment of the export and each node will be asked to "write" on this script whatever it needs to function. Then this script is covnerted to a string and downloaded as the .js file. The layout info is stored in this file as a comment. |
| 39 | +- **ThreeScene**: object in charge of the preview scene running in the background that allows us to see how the material will look. |
| 40 | + |
| 41 | +## Theme / colors / styles |
| 42 | +The app is "skinned" using the theme provided by `src/colors/Theme`. A singleton class that provides the settings for the styles. |
| 43 | + |
| 44 | +## The Script |
| 45 | +Nodes in this app export to a javascript file. This object is in charge of handling how that file is written. |
| 46 | + |
| 47 | +A `Script` is an object that serves as a scope for every node when writing their scripts. "Writing their scripts" means basically writing the actual javascript TSL code that the node represents. |
| 48 | + |
| 49 | +The process is first triggered by the `src/Editor.ts:save()` that creates this object and then asks every node to `.writeScript( script )` to it. This process will generate a domino effect that will "travel" from the node, then it will to the connected nodes vía the input outlets that connect the node to the next node, and so on... until there's no more nodes with connections. |
| 50 | + |
| 51 | +For more info ask me here or via x @bandinopla... |
0 commit comments