Skip to content

Commit 134a429

Browse files
committed
readme change + rename base classes + basic input property for just inputs with labels
1 parent 9e35dfe commit 134a429

File tree

6 files changed

+36
-43
lines changed

6 files changed

+36
-43
lines changed

README.md

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
# three.js TSL Visual Node Editor
22

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!
3+
![sdsad](/public/cover.png)
74

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...
5+
## **[!] Work in progress | Alpha state** <br/>
6+
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). The socket proximity detection was inspired by [Kennedy Richard](https://x.com/KennedyRichard)'s [Nodezator's node editor](https://x.com/KennedyRichard/status/1823905562192449762)
107

11-
```js
12-
import { materials } from "./your-saved-file.js";
13-
const material1 = materials[0]; //<-- this is a THREE.Material
14-
```
8+
### :bookmark_tabs: Read the [WIKI / Documentation](https://github.com/bandinopla/three.js-visual-node-editor/wiki/three.js-TSL-Visual-Node-Editor) to collaborate!
159

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)
10+
# Let's build this together!
11+
The idea is to let everybody add nodes and have this be the best shader node editor in the galaxy. To do so, you must check the [Three.js-Shading-Language Docs](https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language) to know how to implement the TSL sintax.
1812

1913
You can also fix bugs or improve the code/interface. Just clone and do a pull request.
2014

@@ -24,28 +18,3 @@ These are the nodes currently "done" (room for improvement)...
2418
- Scene Preview
2519
- (incomplete) MeshStandardNode shader node. ( only colorNode property )
2620
- 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...

src/nodes/attribute/AttributeTypeNode.ts renamed to src/nodes/attribute/BaseAttributeNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { WinNode } from "../WinNode";
55
/**
66
* Base class to every node in this category
77
*/
8-
export class AttributeTypeNode extends WinNode {
8+
export class BaseAttributeNode extends WinNode {
99
constructor( childs:LayoutElement[]) {
1010
super( "Attribute", Theme.config.groupAttribute, childs );
1111
}

src/nodes/attribute/UVNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import { DraggableValue } from "../../components/DraggableValue";
33
import { Script } from "../../export/Script";
44
import { UVAttributeProperty } from "../../properties/UVAttributeProperty";
5-
import { AttributeTypeNode } from "./AttributeTypeNode";
5+
import { BaseAttributeNode } from "./BaseAttributeNode";
66

7-
export class UVNode extends AttributeTypeNode {
7+
export class UVNode extends BaseAttributeNode {
88

99
private uvChannel:DraggableValue;
1010

File renamed without changes.

src/nodes/texture/ImageTextureNode.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import { Vector1Output } from '../../properties/Vector1Output';
44
import { TextureExtensionProperty } from "../../properties/TextureExtensionProperty";
55
import { TextureMappingModeProperty } from "../../properties/TextureMappingModeProperty";
66
import { UVTransformProperty } from "../../properties/UVTransformProperty";
7-
import { TextureTypeNode } from "./TextureTypeNode";
7+
import { TextureTypeNode } from "./BaseTextureNode";
88
import { Script } from '../../export/Script';
9-
import { texture } from 'three/tsl';
10-
119
export class ImageTextureNode extends TextureTypeNode {
1210

1311
private imageProp:TextureProperty;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { OutletSize } from "../core/IOutlet";
2+
import { Script } from "../export/Script";
3+
import { Input } from "./Input";
4+
5+
/**
6+
* Just an input with a label.
7+
*/
8+
export class BasicInputProperty extends Input {
9+
10+
/**
11+
* @param size
12+
* @param label
13+
* @param defaultScriptIfNotConnected If not connected, what should this input add to the script?
14+
*/
15+
constructor( size:OutletSize, protected label:string, protected defaultScriptIfNotConnected?:(script:Script)=>string ) {
16+
super(size);
17+
}
18+
19+
override renderContents(ctx: CanvasRenderingContext2D, maxWidth: number, maxHeight: number): void {
20+
this.writeText(ctx, this.label, this.fontSize, 0, maxHeight, this.fontColor);
21+
}
22+
23+
override writeScript(script: Script): string {
24+
return !this.connectedTo? this.defaultScriptIfNotConnected?.(script) ?? "" :super.writeScript(script);
25+
}
26+
}

0 commit comments

Comments
 (0)