浏览代码

Split InputNode into ConstNode and UniformNode (#23663)

* Split InputNode into ConstNode and UniformNode

* ArrayInputNode -> ArrayUniformNode

* Fix nodes

* Fix examples

* Fix

* Fix NodeEditor

* Fix b/u/ivec constants

* Fix

* Fix webgpu_instance_uniform.html

* Change signature

* Fix serialization/deserialization

* Fixes

* Fix for nodeType

* cleanup

* Update InputNode.js

cleanup(2)

* More cleanup

* fix class name

* reuse uniformNode

* fix uniform

* fix non-node params

* fix updateUniforms default values

* intro to InputNode.getInputType()

* cleanup

Co-authored-by: sunag <[email protected]>
LeviPesin 3 年之前
父节点
当前提交
6e37b45ab0
共有 64 个文件被更改,包括 479 次插入727 次删除
  1. 3 3
      examples/jsm/node-editor/display/BlendEditor.js
  2. 2 2
      examples/jsm/node-editor/display/NormalMapEditor.js
  3. 3 2
      examples/jsm/node-editor/inputs/ColorEditor.js
  4. 2 2
      examples/jsm/node-editor/inputs/FloatEditor.js
  5. 2 2
      examples/jsm/node-editor/inputs/SliderEditor.js
  6. 3 2
      examples/jsm/node-editor/inputs/Vector2Editor.js
  7. 3 2
      examples/jsm/node-editor/inputs/Vector3Editor.js
  8. 3 2
      examples/jsm/node-editor/inputs/Vector4Editor.js
  9. 3 2
      examples/jsm/node-editor/math/AngleEditor.js
  10. 2 2
      examples/jsm/node-editor/math/DotEditor.js
  11. 2 2
      examples/jsm/node-editor/math/InvertEditor.js
  12. 2 3
      examples/jsm/node-editor/math/LimiterEditor.js
  13. 3 2
      examples/jsm/node-editor/math/NormalizeEditor.js
  14. 2 3
      examples/jsm/node-editor/math/OperatorEditor.js
  15. 2 3
      examples/jsm/node-editor/math/PowerEditor.js
  16. 3 2
      examples/jsm/node-editor/math/TrigonometryEditor.js
  17. 2 2
      examples/jsm/node-editor/utils/JoinEditor.js
  18. 2 2
      examples/jsm/node-editor/utils/OscillatorEditor.js
  19. 2 2
      examples/jsm/node-editor/utils/PreviewEditor.js
  20. 2 2
      examples/jsm/node-editor/utils/SplitEditor.js
  21. 15 39
      examples/jsm/nodes/Nodes.js
  22. 49 64
      examples/jsm/nodes/ShaderNode.js
  23. 5 6
      examples/jsm/nodes/accessors/BufferNode.js
  24. 4 7
      examples/jsm/nodes/accessors/CameraNode.js
  25. 15 15
      examples/jsm/nodes/accessors/Object3DNode.js
  26. 13 39
      examples/jsm/nodes/accessors/ReferenceNode.js
  27. 29 33
      examples/jsm/nodes/accessors/SkinningNode.js
  28. 15 12
      examples/jsm/nodes/accessors/TextureNode.js
  29. 0 23
      examples/jsm/nodes/core/ArrayInputNode.js
  30. 23 0
      examples/jsm/nodes/core/ArrayUniformNode.js
  31. 23 0
      examples/jsm/nodes/core/ConstNode.js
  32. 85 35
      examples/jsm/nodes/core/InputNode.js
  33. 37 4
      examples/jsm/nodes/core/NodeBuilder.js
  34. 40 0
      examples/jsm/nodes/core/UniformNode.js
  35. 11 19
      examples/jsm/nodes/display/NormalMapNode.js
  36. 0 33
      examples/jsm/nodes/inputs/BoolNode.js
  37. 0 43
      examples/jsm/nodes/inputs/ColorNode.js
  38. 0 33
      examples/jsm/nodes/inputs/FloatNode.js
  39. 0 33
      examples/jsm/nodes/inputs/IntNode.js
  40. 0 18
      examples/jsm/nodes/inputs/Matrix3Node.js
  41. 0 18
      examples/jsm/nodes/inputs/Matrix4Node.js
  42. 0 33
      examples/jsm/nodes/inputs/UintNode.js
  43. 0 41
      examples/jsm/nodes/inputs/Vector2Node.js
  44. 0 43
      examples/jsm/nodes/inputs/Vector3Node.js
  45. 0 45
      examples/jsm/nodes/inputs/Vector4Node.js
  46. 4 3
      examples/jsm/nodes/lights/LightContextNode.js
  47. 4 5
      examples/jsm/nodes/lights/LightNode.js
  48. 2 3
      examples/jsm/nodes/procedural/CheckerNode.js
  49. 3 3
      examples/jsm/nodes/utils/SpriteSheetUVNode.js
  50. 3 3
      examples/jsm/nodes/utils/TimerNode.js
  51. 20 1
      examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js
  52. 2 2
      examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js
  53. 3 3
      examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js
  54. 3 3
      examples/webgl_materials_instance_uniform_nodes.html
  55. 1 1
      examples/webgl_materials_standard_nodes.html
  56. 2 2
      examples/webgl_nodes_playground.html
  57. 2 2
      examples/webgl_points_nodes.html
  58. 1 1
      examples/webgpu_compute.html
  59. 5 3
      examples/webgpu_instance_uniform.html
  60. 2 2
      examples/webgpu_materials.html
  61. 2 2
      examples/webgpu_nodes_playground.html
  62. 1 1
      examples/webgpu_rtt.html
  63. 6 6
      examples/webgpu_sandbox.html
  64. 1 1
      examples/webgpu_skinning_points.html

+ 3 - 3
examples/jsm/node-editor/display/BlendEditor.js

@@ -1,9 +1,9 @@
 import { LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { MathNode, FloatNode } from 'three-nodes/Nodes.js';
+import { MathNode, UniformNode } from 'three-nodes/Nodes.js';
 
-const NULL_VALUE = new FloatNode();
-const ONE_VALUE = new FloatNode( 1 );
+const NULL_VALUE = new UniformNode( 0 );
+const ONE_VALUE = new UniformNode( 1 );
 
 export class BlendEditor extends BaseNode {
 

+ 2 - 2
examples/jsm/node-editor/display/NormalMapEditor.js

@@ -1,9 +1,9 @@
 import { SelectInput, Element, LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { NormalMapNode, FloatNode } from 'three-nodes/Nodes.js';
+import { NormalMapNode, ConstNode } from 'three-nodes/Nodes.js';
 import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from 'three';
 
-const nullValue = new FloatNode( 0 ).setConst( true );
+const nullValue = new ConstNode( 0 );
 
 export class NormalMapEditor extends BaseNode {
 

+ 3 - 2
examples/jsm/node-editor/inputs/ColorEditor.js

@@ -1,12 +1,13 @@
 import { ColorInput, StringInput, NumberInput, LabelElement, Element } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { ColorNode } from 'three-nodes/Nodes.js';
+import { Color } from 'three';
+import { UniformNode } from 'three-nodes/Nodes.js';
 
 export class ColorEditor extends BaseNode {
 
 	constructor() {
 
-		const node = new ColorNode();
+		const node = new UniformNode( new Color() );
 
 		super( 'Color', 3, node );
 

+ 2 - 2
examples/jsm/node-editor/inputs/FloatEditor.js

@@ -1,12 +1,12 @@
 import { NumberInput, Element } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { FloatNode } from 'three-nodes/Nodes.js';
+import { UniformNode } from 'three-nodes/Nodes.js';
 
 export class FloatEditor extends BaseNode {
 
 	constructor() {
 
-		const node = new FloatNode();
+		const node = new UniformNode( 0 );
 
 		super( 'Float', 1, node, 150 );
 

+ 2 - 2
examples/jsm/node-editor/inputs/SliderEditor.js

@@ -1,12 +1,12 @@
 import { ButtonInput, SliderInput, NumberInput, LabelElement, Element } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { FloatNode } from 'three-nodes/Nodes.js';
+import { UniformNode } from 'three-nodes/Nodes.js';
 
 export class SliderEditor extends BaseNode {
 
 	constructor() {
 
-		const node = new FloatNode();
+		const node = new UniformNode( 0 );
 
 		super( 'Slider', 1, node );
 

+ 3 - 2
examples/jsm/node-editor/inputs/Vector2Editor.js

@@ -1,12 +1,13 @@
 import { NumberInput, LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { Vector2Node } from 'three-nodes/Nodes.js';
+import { Vector2 } from 'three';
+import { UniformNode } from 'three-nodes/Nodes.js';
 
 export class Vector2Editor extends BaseNode {
 
 	constructor() {
 
-		const node = new Vector2Node();
+		const node = new UniformNode( new Vector2() );
 
 		super( 'Vector 2', 2, node );
 

+ 3 - 2
examples/jsm/node-editor/inputs/Vector3Editor.js

@@ -1,12 +1,13 @@
 import { NumberInput, LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { Vector3Node } from 'three-nodes/Nodes.js';
+import { Vector3 } from 'three';
+import { UniformNode } from 'three-nodes/Nodes.js';
 
 export class Vector3Editor extends BaseNode {
 
 	constructor() {
 
-		const node = new Vector3Node();
+		const node = new UniformNode( new Vector3() );
 
 		super( 'Vector 3', 3, node, 325 );
 

+ 3 - 2
examples/jsm/node-editor/inputs/Vector4Editor.js

@@ -1,12 +1,13 @@
 import { NumberInput, LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { Vector4Node } from 'three-nodes/Nodes.js';
+import { Vector4 } from 'three';
+import { UniformNode } from 'three-nodes/Nodes.js';
 
 export class Vector4Editor extends BaseNode {
 
 	constructor() {
 
-		const node = new Vector4Node();
+		const node = new UniformNode( new Vector4() );
 
 		super( 'Vector 4', 4, node, 350 );
 

+ 3 - 2
examples/jsm/node-editor/math/AngleEditor.js

@@ -1,8 +1,9 @@
 import { SelectInput, Element, LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { MathNode, Vector3Node } from 'three-nodes/Nodes.js';
+import { Vector3 } from 'three';
+import { MathNode, UniformNode } from 'three-nodes/Nodes.js';
 
-const DEFAULT_VALUE = new Vector3Node();
+const DEFAULT_VALUE = new UniformNode( new Vector3() );
 
 export class AngleEditor extends BaseNode {
 

+ 2 - 2
examples/jsm/node-editor/math/DotEditor.js

@@ -1,8 +1,8 @@
 import { LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { MathNode, FloatNode } from 'three-nodes/Nodes.js';
+import { MathNode, UniformNode } from 'three-nodes/Nodes.js';
 
-const NULL_VALUE = new FloatNode();
+const NULL_VALUE = new UniformNode( 0 );
 
 export class DotEditor extends BaseNode {
 

+ 2 - 2
examples/jsm/node-editor/math/InvertEditor.js

@@ -1,8 +1,8 @@
 import { SelectInput, LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { MathNode, FloatNode } from 'three-nodes/Nodes.js';
+import { MathNode, UniformNode } from 'three-nodes/Nodes.js';
 
-const DEFAULT_VALUE = new FloatNode();
+const DEFAULT_VALUE = new UniformNode( 0 );
 
 export class InvertEditor extends BaseNode {
 

+ 2 - 3
examples/jsm/node-editor/math/LimiterEditor.js

@@ -1,13 +1,12 @@
 import { SelectInput, LabelElement, Element, NumberInput } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { MathNode, FloatNode } from 'three-nodes/Nodes.js';
-
+import { MathNode, UniformNode } from 'three-nodes/Nodes.js';
 
 export class LimiterEditor extends BaseNode {
 
 	constructor() {
 
-		const NULL_VALUE = new FloatNode();
+		const NULL_VALUE = new UniformNode( 0 );
 
 		const node = new MathNode( MathNode.MIN, NULL_VALUE, NULL_VALUE );
 

+ 3 - 2
examples/jsm/node-editor/math/NormalizeEditor.js

@@ -1,8 +1,9 @@
 import { LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { MathNode, Vector3Node } from 'three-nodes/Nodes.js';
+import { Vector3 } from 'three';
+import { MathNode, UniformNode } from 'three-nodes/Nodes.js';
 
-const DEFAULT_VALUE = new Vector3Node();
+const DEFAULT_VALUE = new UniformNode( new Vector3() );
 
 export class NormalizeEditor extends BaseNode {
 

+ 2 - 3
examples/jsm/node-editor/math/OperatorEditor.js

@@ -1,13 +1,12 @@
 import { Element, LabelElement, NumberInput, SelectInput } from '../../libs/flow.module.js';
-import { FloatNode, OperatorNode } from 'three-nodes/Nodes.js';
+import { UniformNode, OperatorNode } from 'three-nodes/Nodes.js';
 import { BaseNode } from '../core/BaseNode.js';
 
-
 export class OperatorEditor extends BaseNode {
 
 	constructor() {
 
-		const NULL_VALUE = new FloatNode();
+		const NULL_VALUE = new UniformNode( 0 );
 
 		const node = new OperatorNode( '+', NULL_VALUE, NULL_VALUE );
 

+ 2 - 3
examples/jsm/node-editor/math/PowerEditor.js

@@ -1,13 +1,12 @@
 import { LabelElement, NumberInput } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { MathNode, FloatNode } from 'three-nodes/Nodes.js';
-
+import { MathNode, UniformNode } from 'three-nodes/Nodes.js';
 
 export class PowerEditor extends BaseNode {
 
 	constructor() {
 
-		const NULL_VALUE = new FloatNode();
+		const NULL_VALUE = new UniformNode( 0 );
 		const node = new MathNode( MathNode.POW, NULL_VALUE, NULL_VALUE );
 
 		super( 'Power', 1, node, 175 );

+ 3 - 2
examples/jsm/node-editor/math/TrigonometryEditor.js

@@ -1,8 +1,9 @@
 import { SelectInput, Element, LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { MathNode, Vector3Node } from 'three-nodes/Nodes.js';
+import { Vector3 } from 'three';
+import { MathNode, UniformNode } from 'three-nodes/Nodes.js';
 
-const DEFAULT_VALUE = new Vector3Node();
+const DEFAULT_VALUE = new UniformNode( new Vector3() );
 
 export class TrigonometryEditor extends BaseNode {
 

+ 2 - 2
examples/jsm/node-editor/utils/JoinEditor.js

@@ -1,8 +1,8 @@
 import { LabelElement } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { JoinNode, FloatNode } from 'three-nodes/Nodes.js';
+import { JoinNode, UniformNode } from 'three-nodes/Nodes.js';
 
-const NULL_VALUE = new FloatNode();
+const NULL_VALUE = new UniformNode( 0 );
 
 export class JoinEditor extends BaseNode {
 

+ 2 - 2
examples/jsm/node-editor/utils/OscillatorEditor.js

@@ -1,8 +1,8 @@
 import { SelectInput, LabelElement, Element } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { OscNode, FloatNode } from 'three-nodes/Nodes.js';
+import { OscNode, UniformNode } from 'three-nodes/Nodes.js';
 
-const NULL_VALUE = new FloatNode();
+const NULL_VALUE = new UniformNode( 0 );
 
 export class OscillatorEditor extends BaseNode {
 

+ 2 - 2
examples/jsm/node-editor/utils/PreviewEditor.js

@@ -2,10 +2,10 @@ import { OrbitControls } from 'three-addons/controls/OrbitControls.js';
 import { ViewHelper } from 'three-addons/helpers/ViewHelper.js';
 import { Element, LabelElement, SelectInput } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { MeshBasicNodeMaterial, FloatNode } from 'three-nodes/Nodes.js';
+import { MeshBasicNodeMaterial, ConstNode } from 'three-nodes/Nodes.js';
 import { WebGLRenderer, PerspectiveCamera, Scene, Mesh, DoubleSide, SphereGeometry, BoxGeometry, PlaneGeometry, TorusKnotGeometry } from 'three';
 
-const nullValue = new FloatNode().setConst( true );
+const nullValue = new ConstNode( 0 );
 
 const sceneDict = {};
 

+ 2 - 2
examples/jsm/node-editor/utils/SplitEditor.js

@@ -1,8 +1,8 @@
 import { SelectInput, Element } from '../../libs/flow.module.js';
 import { BaseNode } from '../core/BaseNode.js';
-import { SplitNode, FloatNode } from 'three-nodes/Nodes.js';
+import { SplitNode, UniformNode } from 'three-nodes/Nodes.js';
 
-const NULL_VALUE = new FloatNode();
+const NULL_VALUE = new UniformNode( 0 );
 
 export class SplitEditor extends BaseNode {
 

+ 15 - 39
examples/jsm/nodes/Nodes.js

@@ -1,13 +1,13 @@
 // core
-import ArrayInputNode from './core/ArrayInputNode.js';
+import ArrayUniformNode from './core/ArrayUniformNode.js';
 import AttributeNode from './core/AttributeNode.js';
 import BypassNode from './core/BypassNode.js';
 import CodeNode from './core/CodeNode.js';
+import ConstNode from './core/ConstNode.js';
 import ContextNode from './core/ContextNode.js';
 import ExpressionNode from './core/ExpressionNode.js';
 import FunctionCallNode from './core/FunctionCallNode.js';
 import FunctionNode from './core/FunctionNode.js';
-import InputNode from './core/InputNode.js';
 import Node from './core/Node.js';
 import NodeAttribute from './core/NodeAttribute.js';
 import NodeBuilder from './core/NodeBuilder.js';
@@ -20,10 +20,12 @@ import NodeVar from './core/NodeVar.js';
 import NodeVary from './core/NodeVary.js';
 import PropertyNode from './core/PropertyNode.js';
 import TempNode from './core/TempNode.js';
+import UniformNode from './core/UniformNode.js';
 import VarNode from './core/VarNode.js';
 import VaryNode from './core/VaryNode.js';
 
 // accessors
+import BufferNode from './accessors/BufferNode.js';
 import CameraNode from './accessors/CameraNode.js';
 import MaterialNode from './accessors/MaterialNode.js';
 import MaterialReferenceNode from './accessors/MaterialReferenceNode.js';
@@ -35,19 +37,9 @@ import PointUVNode from './accessors/PointUVNode.js';
 import PositionNode from './accessors/PositionNode.js';
 import ReferenceNode from './accessors/ReferenceNode.js';
 import SkinningNode from './accessors/SkinningNode.js';
+import TextureNode from './accessors/TextureNode.js';
 import UVNode from './accessors/UVNode.js';
 
-// inputs
-import ColorNode from './inputs/ColorNode.js';
-import FloatNode from './inputs/FloatNode.js';
-import IntNode from './inputs/IntNode.js';
-import Matrix3Node from './inputs/Matrix3Node.js';
-import Matrix4Node from './inputs/Matrix3Node.js';
-import TextureNode from './inputs/TextureNode.js';
-import Vector2Node from './inputs/Vector2Node.js';
-import Vector3Node from './inputs/Vector3Node.js';
-import Vector4Node from './inputs/Vector4Node.js';
-
 // display
 import ColorSpaceNode from './display/ColorSpaceNode.js';
 import NormalMapNode from './display/NormalMapNode.js';
@@ -98,15 +90,15 @@ export * from './ShaderNode.js';
 
 const nodeLib = {
 	// core
-	ArrayInputNode,
+	ArrayUniformNode,
 	AttributeNode,
 	BypassNode,
 	CodeNode,
 	ContextNode,
+	ConstNode,
 	ExpressionNode,
 	FunctionCallNode,
 	FunctionNode,
-	InputNode,
 	Node,
 	NodeAttribute,
 	NodeBuilder,
@@ -119,10 +111,12 @@ const nodeLib = {
 	NodeVary,
 	PropertyNode,
 	TempNode,
+	UniformNode,
 	VarNode,
 	VaryNode,
 
 	// accessors
+	BufferNode,
 	CameraNode,
 	MaterialNode,
 	MaterialReferenceNode,
@@ -134,18 +128,8 @@ const nodeLib = {
 	PositionNode,
 	ReferenceNode,
 	SkinningNode,
-	UVNode,
-
-	// inputs
-	ColorNode,
-	FloatNode,
-	IntNode,
-	Matrix3Node,
-	Matrix4Node,
 	TextureNode,
-	Vector2Node,
-	Vector3Node,
-	Vector4Node,
+	UVNode,
 
 	// display
 	ColorSpaceNode,
@@ -193,15 +177,15 @@ export const fromType = ( type ) => {
 
 export {
 	// core
-	ArrayInputNode,
+	ArrayUniformNode,
 	AttributeNode,
 	BypassNode,
 	CodeNode,
 	ContextNode,
+	ConstNode,
 	ExpressionNode,
 	FunctionCallNode,
 	FunctionNode,
-	InputNode,
 	Node,
 	NodeAttribute,
 	NodeBuilder,
@@ -214,10 +198,12 @@ export {
 	NodeVary,
 	PropertyNode,
 	TempNode,
+	UniformNode,
 	VarNode,
 	VaryNode,
 
 	// accessors
+	BufferNode,
 	CameraNode,
 	MaterialNode,
 	MaterialReferenceNode,
@@ -229,18 +215,8 @@ export {
 	PositionNode,
 	ReferenceNode,
 	SkinningNode,
-	UVNode,
-
-	// inputs
-	ColorNode,
-	FloatNode,
-	IntNode,
-	Matrix3Node,
-	Matrix4Node,
 	TextureNode,
-	Vector2Node,
-	Vector3Node,
-	Vector4Node,
+	UVNode,
 
 	// display
 	ColorSpaceNode,

+ 49 - 64
examples/jsm/nodes/ShaderNode.js

@@ -2,24 +2,14 @@
 import PropertyNode from './core/PropertyNode.js';
 import VarNode from './core/VarNode.js';
 import AttributeNode from './core/AttributeNode.js';
-
-// input nodes
-import BoolNode from './inputs/BoolNode.js';
-import BufferNode from './inputs/BufferNode.js';
-import ColorNode from './inputs/ColorNode.js';
-import FloatNode from './inputs/FloatNode.js';
-import IntNode from './inputs/IntNode.js';
-import UintNode from './inputs/UintNode.js';
-import Vector2Node from './inputs/Vector2Node.js';
-import Vector3Node from './inputs/Vector3Node.js';
-import Vector4Node from './inputs/Vector4Node.js';
-import Matrix3Node from './inputs/Matrix3Node.js';
-import Matrix4Node from './inputs/Matrix4Node.js';
-import TextureNode from './inputs/TextureNode.js';
+import ConstNode from './core/ConstNode.js';
+import UniformNode from './core/UniformNode.js';
 
 // accessor nodes
+import BufferNode from './accessors/BufferNode.js';
 import PositionNode from './accessors/PositionNode.js';
 import NormalNode from './accessors/NormalNode.js';
+import TextureNode from './accessors/TextureNode.js';
 import UVNode from './accessors/UVNode.js';
 
 // math nodes
@@ -66,7 +56,7 @@ const NodeHandler = {
 
 				// accessing array
 
-				return new ShaderNodeObject( new ArrayElementNode( node, new FloatNode( Number( prop ) ).setConst( true ) ) );
+				return new ShaderNodeObject( new ArrayElementNode( node, new ConstNode( Number( prop ), 'uint' ) ) );
 
 			}
 
@@ -84,9 +74,9 @@ const ShaderNodeObject = function( obj ) {
 
 	const type = typeof obj;
 
-	if ( type === 'number' ) {
+	if ( ( type === 'number' ) || ( type === 'boolean' ) ) {
 
-		return new ShaderNodeObject( new FloatNode( obj ).setConst( true ) );
+		return new ShaderNodeObject( new ConstNode( obj ) );
 
 	} else if ( type === 'object' ) {
 
@@ -188,17 +178,15 @@ export const ShaderNode = new Proxy( ShaderNodeScript, NodeHandler );
 // Node Material Shader Syntax
 //
 
-export const uniform = new ShaderNode( ( inputNode ) => {
+export const nodeObject = ( val ) => {
 
-	inputNode.setConst( false );
+	return new ShaderNodeObject( val );
 
-	return inputNode;
+};
 
-} );
+export const uniform = ( constNode ) => {
 
-export const nodeObject = ( val ) => {
-
-	return new ShaderNodeObject( val );
+	return nodeObject( new UniformNode( constNode.value, constNode.nodeType ) );
 
 };
 
@@ -220,7 +208,7 @@ export const label = ( node, name ) => {
 
 export const temp = ( node ) => nodeObject( new VarNode( nodeObject( node ) ) );
 
-const ConvertType = function ( nodeClass, type, valueClass = null, valueComponents = 1, convertAfter = false ) {
+const ConvertType = function ( type, valueClass = null, valueComponents = 1 ) {
 
 	return ( ...params ) => {
 
@@ -244,44 +232,42 @@ const ConvertType = function ( nodeClass, type, valueClass = null, valueComponen
 
 		const val = ( ( valueClass === null ) || ( params[ 0 ] instanceof valueClass ) ) ? params[ 0 ] : new valueClass().set( ...params );
 
-		const node = nodeObject( new nodeClass( val ).setConst( true ) );
-
-		return convertAfter === true ? nodeObject( new ConvertNode( node, type ) ) : node;
+		return nodeObject( new ConstNode( val, type ) );
 
 	};
 
 };
 
-export const float = new ConvertType( FloatNode, 'float' );
-export const int = new ConvertType( IntNode, 'int' );
-export const uint = new ConvertType( UintNode, 'uint' );
-export const bool = new ConvertType( BoolNode, 'bool' );
-export const color = new ConvertType( ColorNode, 'color', Color );
-
-export const vec2 = new ConvertType( Vector2Node, 'vec2', Vector2, 2 );
-export const ivec2 = new ConvertType( Vector2Node, 'ivec2', Vector2, 2, true );
-export const uvec2 = new ConvertType( Vector2Node, 'uvec2', Vector2, 2, true );
-export const bvec2 = new ConvertType( Vector2Node, 'bvec2', Vector2, 2, true );
-
-export const vec3 = new ConvertType( Vector3Node, 'vec3', Vector3, 3 );
-export const ivec3 = new ConvertType( Vector3Node, 'ivec3', Vector3, 3, true );
-export const uvec3 = new ConvertType( Vector3Node, 'uvec3', Vector3, 3, true );
-export const bvec3 = new ConvertType( Vector3Node, 'bvec3', Vector3, 3, true );
-
-export const vec4 = new ConvertType( Vector4Node, 'vec4', Vector4, 4 );
-export const ivec4 = new ConvertType( Vector4Node, 'ivec4', Vector4, 4, true );
-export const uvec4 = new ConvertType( Vector4Node, 'uvec4', Vector4, 4, true );
-export const bvec4 = new ConvertType( Vector4Node, 'bvec4', Vector4, 4, true );
-
-export const mat3 = new ConvertType( Matrix3Node, 'mat3', Matrix3 );
-export const imat3 = new ConvertType( Matrix3Node, 'imat3', Matrix3, 1, true );
-export const umat3 = new ConvertType( Matrix3Node, 'umat3', Matrix3, 1, true );
-export const bmat3 = new ConvertType( Matrix3Node, 'bmat3', Matrix3, 1, true );
-
-export const mat4 = new ConvertType( Matrix4Node, 'mat4', Matrix4 );
-export const imat4 = new ConvertType( Matrix4Node, 'imat4', Matrix4, 1, true );
-export const umat4 = new ConvertType( Matrix4Node, 'umat4', Matrix4, 1, true );
-export const bmat4 = new ConvertType( Matrix4Node, 'bmat4', Matrix4, 1, true );
+export const float = new ConvertType( 'float' );
+export const int = new ConvertType( 'int' );
+export const uint = new ConvertType( 'uint' );
+export const bool = new ConvertType( 'bool' );
+export const color = new ConvertType( 'color', Color );
+
+export const vec2 = new ConvertType( 'vec2', Vector2, 2 );
+export const ivec2 = new ConvertType( 'ivec2', Vector2, 2 );
+export const uvec2 = new ConvertType( 'uvec2', Vector2, 2 );
+export const bvec2 = new ConvertType( 'bvec2', Vector2, 2 );
+
+export const vec3 = new ConvertType( 'vec3', Vector3, 3 );
+export const ivec3 = new ConvertType( 'ivec3', Vector3, 3 );
+export const uvec3 = new ConvertType( 'uvec3', Vector3, 3 );
+export const bvec3 = new ConvertType( 'bvec3', Vector3, 3 );
+
+export const vec4 = new ConvertType( 'vec4', Vector4, 4 );
+export const ivec4 = new ConvertType( 'ivec4', Vector4, 4 );
+export const uvec4 = new ConvertType( 'uvec4', Vector4, 4 );
+export const bvec4 = new ConvertType( 'bvec4', Vector4, 4 );
+
+export const mat3 = new ConvertType( 'mat3', Matrix3 );
+export const imat3 = new ConvertType( 'imat3', Matrix3 );
+export const umat3 = new ConvertType( 'umat3', Matrix3 );
+export const bmat3 = new ConvertType( 'bmat3', Matrix3 );
+
+export const mat4 = new ConvertType( 'mat4', Matrix4 );
+export const imat4 = new ConvertType( 'imat4', Matrix4 );
+export const umat4 = new ConvertType( 'umat4', Matrix4 );
+export const bmat4 = new ConvertType( 'bmat4', Matrix4 );
 
 export const join = ( ...params ) => {
 
@@ -289,6 +275,11 @@ export const join = ( ...params ) => {
 
 };
 
+export const uv = ( ...params ) => nodeObject( new UVNode( ...params ) );
+export const attribute = ( ...params ) => nodeObject( new AttributeNode( ...params ) );
+export const buffer = ( ...params ) => nodeObject( new BufferNode( ...params ) );
+export const texture = ( ...params ) => nodeObject( new TextureNode( ...params ) );
+
 export const cond = ( ...params ) => {
 
 	return nodeObject( new CondNode( ...getShaderNodeArray( params ) ) );
@@ -303,12 +294,6 @@ export const addTo = ( varNode, ...params ) => {
 
 };
 
-export const uv = new ShaderNodeProxy( UVNode );
-export const attribute = new ShaderNodeProxy( AttributeNode );
-
-export const buffer = new ShaderNodeProxy( BufferNode );
-export const texture = new ShaderNodeProxy( TextureNode );
-
 export const add = new ShaderNodeProxy( OperatorNode, '+' );
 export const sub = new ShaderNodeProxy( OperatorNode, '-' );
 export const mul = new ShaderNodeProxy( OperatorNode, '*' );

+ 5 - 6
examples/jsm/nodes/inputs/BufferNode.js → examples/jsm/nodes/accessors/BufferNode.js

@@ -1,20 +1,19 @@
-import InputNode from '../core/InputNode.js';
+import UniformNode from '../core/UniformNode.js';
 
-class BufferNode extends InputNode {
+class BufferNode extends UniformNode {
 
 	constructor( value, bufferType, bufferCount = 0 ) {
 
-		super( 'buffer' );
+		super( value, bufferType );
 
-		this.value = value;
 		this.bufferType = bufferType;
 		this.bufferCount = bufferCount;
 
 	}
 
-	getNodeType( /* builder */ ) {
+	getInputType( /*builder*/ ) {
 
-		return this.bufferType;
+		return 'buffer';
 
 	}
 

+ 4 - 7
examples/jsm/nodes/accessors/CameraNode.js

@@ -1,5 +1,4 @@
 import Object3DNode from './Object3DNode.js';
-import Matrix4Node from '../inputs/Matrix4Node.js';
 
 class CameraNode extends Object3DNode {
 
@@ -9,8 +8,6 @@ class CameraNode extends Object3DNode {
 
 		super( scope );
 
-		this._inputNode = null;
-
 	}
 
 	getNodeType( builder ) {
@@ -30,16 +27,16 @@ class CameraNode extends Object3DNode {
 	update( frame ) {
 
 		const camera = frame.camera;
-		const inputNode = this._inputNode;
+		const uniformNode = this._uniformNode;
 		const scope = this.scope;
 
 		if ( scope === CameraNode.PROJECTION_MATRIX ) {
 
-			inputNode.value = camera.projectionMatrix;
+			uniformNode.value = camera.projectionMatrix;
 
 		} else if ( scope === CameraNode.VIEW_MATRIX ) {
 
-			inputNode.value = camera.matrixWorldInverse;
+			uniformNode.value = camera.matrixWorldInverse;
 
 		} else {
 
@@ -55,7 +52,7 @@ class CameraNode extends Object3DNode {
 
 		if ( scope === CameraNode.PROJECTION_MATRIX ) {
 
-			this._inputNode = new Matrix4Node( null );
+			this._uniformNode.nodeType = 'mat4';
 
 		}
 

+ 15 - 15
examples/jsm/nodes/accessors/Object3DNode.js

@@ -1,7 +1,6 @@
+import { Vector3 } from 'three';
 import Node from '../core/Node.js';
-import Matrix4Node from '../inputs/Matrix4Node.js';
-import Matrix3Node from '../inputs/Matrix3Node.js';
-import Vector3Node from '../inputs/Vector3Node.js';
+import UniformNode from '../core/UniformNode.js';
 import { NodeUpdateType } from '../core/constants.js';
 
 class Object3DNode extends Node {
@@ -21,7 +20,7 @@ class Object3DNode extends Node {
 
 		this.updateType = NodeUpdateType.Object;
 
-		this._inputNode = null;
+		this._uniformNode = new UniformNode( null );
 
 	}
 
@@ -48,31 +47,31 @@ class Object3DNode extends Node {
 	update( frame ) {
 
 		const object = this.object3d !== null ? this.object3d : frame.object;
-		const inputNode = this._inputNode;
+		const uniformNode = this._uniformNode;
 		const camera = frame.camera;
 		const scope = this.scope;
 
 		if ( scope === Object3DNode.VIEW_MATRIX ) {
 
-			inputNode.value = object.modelViewMatrix;
+			uniformNode.value = object.modelViewMatrix;
 
 		} else if ( scope === Object3DNode.NORMAL_MATRIX ) {
 
-			inputNode.value = object.normalMatrix;
+			uniformNode.value = object.normalMatrix;
 
 		} else if ( scope === Object3DNode.WORLD_MATRIX ) {
 
-			inputNode.value = object.matrixWorld;
+			uniformNode.value = object.matrixWorld;
 
 		} else if ( scope === Object3DNode.POSITION ) {
 
-			inputNode.value.setFromMatrixPosition( object.matrixWorld );
+			uniformNode.value.setFromMatrixPosition( object.matrixWorld );
 
 		} else if ( scope === Object3DNode.VIEW_POSITION ) {
 
-			inputNode.value.setFromMatrixPosition( object.matrixWorld );
+			uniformNode.value.setFromMatrixPosition( object.matrixWorld );
 
-			inputNode.value.applyMatrix4( camera.matrixWorldInverse );
+			uniformNode.value.applyMatrix4( camera.matrixWorldInverse );
 
 		}
 
@@ -84,19 +83,20 @@ class Object3DNode extends Node {
 
 		if ( scope === Object3DNode.WORLD_MATRIX || scope === Object3DNode.VIEW_MATRIX ) {
 
-			this._inputNode = new Matrix4Node( /*null*/ );
+			this._uniformNode.nodeType = 'mat4';
 
 		} else if ( scope === Object3DNode.NORMAL_MATRIX ) {
 
-			this._inputNode = new Matrix3Node( /*null*/ );
+			this._uniformNode.nodeType = 'mat3';
 
 		} else if ( scope === Object3DNode.POSITION || scope === Object3DNode.VIEW_POSITION ) {
 
-			this._inputNode = new Vector3Node();
+			this._uniformNode.nodeType = 'vec3';
+			this._uniformNode.value = new Vector3();
 
 		}
 
-		return this._inputNode.build( builder );
+		return this._uniformNode.build( builder );
 
 	}
 

+ 13 - 39
examples/jsm/nodes/accessors/ReferenceNode.js

@@ -1,20 +1,16 @@
 import Node from '../core/Node.js';
-import FloatNode from '../inputs/FloatNode.js';
-import Vector2Node from '../inputs/Vector2Node.js';
-import Vector3Node from '../inputs/Vector3Node.js';
-import Vector4Node from '../inputs/Vector4Node.js';
-import ColorNode from '../inputs/ColorNode.js';
-import TextureNode from '../inputs/TextureNode.js';
+import UniformNode from '../core/UniformNode.js';
 import { NodeUpdateType } from '../core/constants.js';
 
 class ReferenceNode extends Node {
 
-	constructor( property, inputType, object = null ) {
+	constructor( property, uniformType, object = null ) {
 
 		super();
 
 		this.property = property;
-		this.inputType = inputType;
+
+		this.uniformType = uniformType;
 
 		this.object = object;
 
@@ -22,52 +18,30 @@ class ReferenceNode extends Node {
 
 		this.updateType = NodeUpdateType.Object;
 
-		this.setNodeType( inputType );
+		this.setNodeType( uniformType );
 
 	}
 
-	setNodeType( inputType ) {
-
-		let node = null;
-		let nodeType = inputType;
-
-		if ( nodeType === 'float' ) {
-
-			node = new FloatNode();
-
-		} else if ( nodeType === 'vec2' ) {
+	setNodeType( uniformType ) {
 
-			node = new Vector2Node( null );
+		this.node = new UniformNode( null, uniformType );
+		this.nodeType = uniformType;
 
-		} else if ( nodeType === 'vec3' ) {
+		if ( uniformType === 'color' ) {
 
-			node = new Vector3Node( null );
+			this.nodeType = 'vec3';
 
-		} else if ( nodeType === 'vec4' ) {
+		} else if ( uniformType === 'texture' ) {
 
-			node = new Vector4Node( null );
-
-		} else if ( nodeType === 'color' ) {
-
-			node = new ColorNode( null );
-			nodeType = 'vec3';
-
-		} else if ( nodeType === 'texture' ) {
-
-			node = new TextureNode();
-			nodeType = 'vec4';
+			this.nodeType = 'vec4';
 
 		}
 
-		this.node = node;
-		this.nodeType = nodeType;
-		this.inputType = inputType;
-
 	}
 
 	getNodeType() {
 
-		return this.inputType;
+		return this.uniformType;
 
 	}
 

+ 29 - 33
examples/jsm/nodes/accessors/SkinningNode.js

@@ -1,17 +1,25 @@
 import Node from '../core/Node.js';
-import AttributeNode from '../core/AttributeNode.js';
-import PositionNode from '../accessors/PositionNode.js';
-import NormalNode from '../accessors/NormalNode.js';
-import Matrix4Node from '../inputs/Matrix4Node.js';
-import BufferNode from '../inputs/BufferNode.js';
 
-import { ShaderNode, assign, element, add, mul, transformDirection } from '../ShaderNode.js';
+import {
+	ShaderNode,
+	attribute,
+	buffer,
+	mat4,
+	uniform,
+	positionLocal,
+	normalLocal,
+	assign,
+	element,
+	add,
+	mul,
+	transformDirection
+} from '../ShaderNode.js';
 
 import { NodeUpdateType } from '../core/constants.js';
 
 const Skinning = new ShaderNode( ( inputs, builder ) => {
 
-	const { position, normal, index, weight, bindMatrix, bindMatrixInverse, boneMatrices } = inputs;
+	const { index, weight, bindMatrix, bindMatrixInverse, boneMatrices } = inputs;
 
 	const boneMatX = element( boneMatrices, index.x );
 	const boneMatY = element( boneMatrices, index.y );
@@ -20,7 +28,7 @@ const Skinning = new ShaderNode( ( inputs, builder ) => {
 
 	// POSITION
 
-	const skinVertex = mul( bindMatrix, position );
+	const skinVertex = mul( bindMatrix, positionLocal );
 
 	const skinned = add(
 		mul( mul( boneMatX, skinVertex ), weight.x ),
@@ -42,12 +50,12 @@ const Skinning = new ShaderNode( ( inputs, builder ) => {
 
 	skinMatrix = mul( mul( bindMatrixInverse, skinMatrix ), bindMatrix );
 
-	const skinNormal = transformDirection( skinMatrix, normal ).xyz;
+	const skinNormal = transformDirection( skinMatrix, normalLocal ).xyz;
 
 	// ASSIGNS
 
-	assign( position, skinPosition ).build( builder );
-	assign( normal, skinNormal ).build( builder );
+	assign( positionLocal, skinPosition ).build( builder );
+	assign( normalLocal, skinNormal ).build( builder );
 
 } );
 
@@ -63,35 +71,23 @@ class SkinningNode extends Node {
 
 		//
 
-		this.skinIndexNode = new AttributeNode( 'skinIndex', 'uvec4' );
-		this.skinWeightNode = new AttributeNode( 'skinWeight', 'vec4' );
+		this.skinIndexNode = attribute( 'skinIndex', 'uvec4' );
+		this.skinWeightNode = attribute( 'skinWeight', 'vec4' );
 
-		this.bindMatrixNode = new Matrix4Node( skinnedMesh.bindMatrix );
-		this.bindMatrixInverseNode = new Matrix4Node( skinnedMesh.bindMatrixInverse );
-		this.boneMatricesNode = new BufferNode( skinnedMesh.skeleton.boneMatrices, 'mat4', skinnedMesh.skeleton.bones.length );
+		this.bindMatrixNode = uniform( mat4( skinnedMesh.bindMatrix ) );
+		this.bindMatrixInverseNode = uniform( mat4( skinnedMesh.bindMatrixInverse ) );
+		this.boneMatricesNode = buffer( skinnedMesh.skeleton.boneMatrices, 'mat4', skinnedMesh.skeleton.bones.length );
 
 	}
 
 	generate( builder ) {
 
-		// inout nodes
-		const position = new PositionNode( PositionNode.LOCAL );
-		const normal = new NormalNode( NormalNode.LOCAL );
-
-		const index = this.skinIndexNode;
-		const weight = this.skinWeightNode;
-		const bindMatrix = this.bindMatrixNode;
-		const bindMatrixInverse = this.bindMatrixInverseNode;
-		const boneMatrices = this.boneMatricesNode;
-
 		Skinning( {
-			position,
-			normal,
-			index,
-			weight,
-			bindMatrix,
-			bindMatrixInverse,
-			boneMatrices
+			index: this.skinIndexNode,
+			weight: this.skinWeightNode,
+			bindMatrix: this.bindMatrixNode,
+			bindMatrixInverse: this.bindMatrixInverseNode,
+			boneMatrices: this.boneMatricesNode
 		}, builder );
 
 	}

+ 15 - 12
examples/jsm/nodes/inputs/TextureNode.js → examples/jsm/nodes/accessors/TextureNode.js

@@ -1,24 +1,29 @@
-import InputNode from '../core/InputNode.js';
-import UVNode from '../accessors/UVNode.js';
+import UniformNode from '../core/UniformNode.js';
+import UVNode from './UVNode.js';
 
-class TextureNode extends InputNode {
+class TextureNode extends UniformNode {
 
-	constructor( value = null, uvNode = new UVNode(), biasNode = null ) {
+	constructor( value, uvNode = new UVNode(), biasNode = null ) {
 
-		super( 'texture' );
+		super( value, 'vec4' );
 
-		this.value = value;
 		this.uvNode = uvNode;
 		this.biasNode = biasNode;
 
 	}
 
-	getInputHash( /*builder*/ ) {
+	getUniformHash( /*builder*/ ) {
 
 		return this.value.uuid;
 
 	}
 
+	getInputType( /*builder*/ ) {
+
+		return 'texture';
+
+	}
+
 	generate( builder, output ) {
 
 		const texture = this.value;
@@ -29,9 +34,7 @@ class TextureNode extends InputNode {
 
 		}
 
-		const type = this.getNodeType( builder );
-
-		const textureProperty = super.generate( builder, type );
+		const textureProperty = super.generate( builder, 'texture' );
 
 		if ( output === 'sampler2D' || output === 'texture2D' ) {
 
@@ -66,7 +69,7 @@ class TextureNode extends InputNode {
 
 			}
 
-			return builder.format( snippet, 'vec4', output );
+			return builder.format( snippet, 'texture', output );
 
 		}
 
@@ -82,7 +85,7 @@ class TextureNode extends InputNode {
 
 	deserialize( data ) {
 
-		super.serialize( data );
+		super.deserialize( data );
 
 		this.value = data.meta.textures[ data.value ];
 

+ 0 - 23
examples/jsm/nodes/core/ArrayInputNode.js

@@ -1,23 +0,0 @@
-import InputNode from './InputNode.js';
-
-class ArrayInputNode extends InputNode {
-
-	constructor( nodes = [] ) {
-
-		super();
-
-		this.nodes = nodes;
-
-	}
-
-	getNodeType( builder ) {
-
-		return this.nodes[ 0 ].getNodeType( builder );
-
-	}
-
-}
-
-ArrayInputNode.prototype.isArrayInputNode = true;
-
-export default ArrayInputNode;

+ 23 - 0
examples/jsm/nodes/core/ArrayUniformNode.js

@@ -0,0 +1,23 @@
+import UniformNode from './UniformNode.js';
+
+class ArrayUniformNode extends UniformNode {
+
+	constructor( nodes = [] ) {
+
+		super();
+
+		this.nodes = nodes;
+
+	}
+
+	getNodeType( builder ) {
+
+		return this.nodes[ 0 ].getNodeType( builder );
+
+	}
+
+}
+
+ArrayUniformNode.prototype.isArrayUniformNode = true;
+
+export default ArrayUniformNode;

+ 23 - 0
examples/jsm/nodes/core/ConstNode.js

@@ -0,0 +1,23 @@
+import InputNode from './InputNode.js';
+
+class ConstNode extends InputNode {
+
+	generateConst( builder ) {
+
+		return builder.getConst( this.getNodeType( builder ), this.value );
+
+	}
+
+	generate( builder, output ) {
+
+		const type = this.getNodeType( builder );
+
+		return builder.format( this.generateConst( builder ), type, output );
+
+	}
+
+}
+
+ConstNode.prototype.isConstNode = true;
+
+export default ConstNode;

+ 85 - 35
examples/jsm/nodes/core/InputNode.js

@@ -1,79 +1,129 @@
+import { Color, Matrix3, Matrix4, Vector2, Vector3, Vector4 } from 'three';
 import Node from './Node.js';
 
-class InputNode extends Node {
+function getValueType( value ) {
 
-	constructor( inputType ) {
+	if ( typeof value === 'number' ) {
 
-		super( inputType );
+		return 'float';
 
-		this.inputType = inputType;
+	} else if ( typeof value === 'boolean' ) {
 
-		this.constant = false;
+		return 'bool';
 
-	}
+	} else if ( value?.isVector2 === true ) {
 
-	setConst( value ) {
+		return 'vec2';
 
-		this.constant = value;
+	} else if ( value?.isVector3 === true ) {
 
-		return this;
+		return 'vec3';
 
-	}
+	} else if ( value?.isVector4 === true ) {
 
-	getConst() {
+		return 'vec4';
 
-		return this.constant;
+	} else if ( value?.isMatrix3 === true ) {
 
-	}
+		return 'mat3';
+
+	} else if ( value?.isMatrix4 === true ) {
 
-	getInputType( /* builder */ ) {
+		return 'mat4';
 
-		return this.inputType;
+	} else if ( value?.isColor === true ) {
+
+		return 'color';
 
 	}
 
-	getInputHash( builder ) {
+	return null;
+
+}
+
+function getValueFromType( type ) {
+
+	if ( type === 'color' ) {
+
+		return new Color();
+
+	} else if ( type === 'vec2' ) {
+
+		return new Vector2();
+
+	} else if ( type === 'vec3' ) {
+
+		return new Vector3();
+
+	} else if ( type === 'vec4' ) {
+
+		return new Vector4();
+
+	} else if ( type === 'mat3' ) {
 
-		return this.getHash( builder );
+		return new Matrix3();
+
+	} else if ( type === 'mat4' ) {
+
+		return new Matrix4();
 
 	}
 
-	generateConst( builder ) {
+	return null;
 
-		return builder.getConst( this.getNodeType( builder ), this.value );
+}
+
+class InputNode extends Node {
+
+	constructor( value, nodeType = null ) {
+
+		super( nodeType );
+
+		this.value = value;
 
 	}
 
-	generate( builder, output ) {
+	getNodeType( /*builder*/ ) {
+
+		if ( this.nodeType === null ) {
 
-		const type = this.getNodeType( builder );
+			return getValueType( this.value );
 
-		if ( this.constant === true ) {
+		}
 
-			return builder.format( this.generateConst( builder ), type, output );
+		return this.nodeType;
 
-		} else {
+	}
 
-			const inputHash = this.getInputHash( builder );
+	getInputType( builder ) {
 
-			let sharedNode = builder.getNodeFromHash( inputHash );
+		return this.getNodeType( builder );
 
-			if ( sharedNode === undefined ) {
+	}
 
-				builder.setHashNode( this, inputHash );
+	serialize( data ) {
 
-				sharedNode = this;
+		super.serialize( data );
 
-			}
+		data.value = this.value?.toArray?.() || this.value;
+		data.valueType = getValueType( this.value );
+		data.nodeType = this.nodeType;
 
-			const inputType = sharedNode.getInputType( builder );
+	}
 
-			const nodeUniform = builder.getUniformFromNode( sharedNode, builder.shaderStage, inputType );
-			const propertyName = builder.getPropertyName( nodeUniform );
+	deserialize( data ) {
 
-			return builder.format( propertyName, type, output );
+		super.deserialize( data );
 
-		}
+		this.nodeType = data.nodeType;
+		this.value = getValueFromType( data.valueType );
+		this.value = this.value?.fromArray?.( data.value ) || data.value;
+
+	}
+
+	generate( /*builder, output*/ ) {
+
+		console.warn('Abstract function.');
 
 	}
 

+ 37 - 4
examples/jsm/nodes/core/NodeBuilder.js

@@ -161,11 +161,28 @@ class NodeBuilder {
 		if ( type === 'int' ) return `${ Math.round( value ) }`;
 		if ( type === 'uint' ) return value >= 0 ? `${ Math.round( value ) }` : '0';
 		if ( type === 'bool' ) return value ? 'true' : 'false';
-		if ( type === 'vec2' ) return `${ this.getType( 'vec2' ) }( ${ toFloat( value.x ) }, ${ toFloat( value.y ) } )`;
-		if ( type === 'vec3' ) return `${ this.getType( 'vec3' ) }( ${ toFloat( value.x ) }, ${ toFloat( value.y ) }, ${ toFloat( value.z ) } )`;
-		if ( type === 'vec4' ) return `${ this.getType( 'vec4' ) }( ${ toFloat( value.x ) }, ${ toFloat( value.y ) }, ${ toFloat( value.z ) }, ${ toFloat( value.w ) } )`;
 		if ( type === 'color' ) return `${ this.getType( 'vec3' ) }( ${ toFloat( value.r ) }, ${ toFloat( value.g ) }, ${ toFloat( value.b ) } )`;
 
+		const typeLength = this.getTypeLength( type );
+
+		const componentType = this.getComponentType( type );
+
+		const getConst = value => this.getConst( componentType, value );
+
+		if ( typeLength === 2 ) {
+
+			return `${ this.getType( type ) }( ${ getConst( value.x ) }, ${ getConst( value.y ) } )`;
+
+		} else if ( typeLength === 3 ) {
+
+			return `${ this.getType( type ) }( ${ getConst( value.x ) }, ${ getConst( value.y ) }, ${ getConst( value.z ) } )`;
+
+		} else if ( typeLength === 4 ) {
+
+			return `${ this.getType( type ) }( ${ getConst( value.x ) }, ${ getConst( value.y ) }, ${ getConst( value.z ) }, ${ getConst( value.w ) } )`;
+
+		}
+
 		throw new Error( `NodeBuilder: Type '${type}' not found in generate constant attempt.` );
 
 	}
@@ -254,6 +271,22 @@ class NodeBuilder {
 
 	}
 
+	getComponentType( type ) {
+
+		type = this.getVectorType( type );
+
+		const componentType = /(b|i|u|)(vec|mat)([2-4])/.exec( type );
+
+		if ( componentType === null ) return null;
+
+		if ( componentType[ 1 ] === 'b' ) return 'bool';
+		if ( componentType[ 1 ] === 'i' ) return 'int';
+		if ( componentType[ 1 ] === 'u' ) return 'uint';
+
+		return 'float';
+
+	}
+
 	getVectorType( type ) {
 
 		if ( type === 'color' ) return 'vec3';
@@ -650,7 +683,7 @@ class NodeBuilder {
 
 		}
 
-		return `${ this.getType( toType ) }( ${ snippet } )`;
+		return `${ this.getType( toType ) }( ${ snippet } )`; // fromType is float-like
 
 	}
 

+ 40 - 0
examples/jsm/nodes/core/UniformNode.js

@@ -0,0 +1,40 @@
+import InputNode from './InputNode.js';
+
+class UniformNode extends InputNode {
+
+	getUniformHash( builder ) {
+
+		return this.getHash( builder );
+
+	}
+
+	generate( builder, output ) {
+
+		const type = this.getNodeType( builder );
+
+		const hash = this.getUniformHash( builder );
+
+		let sharedNode = builder.getNodeFromHash( hash );
+
+		if ( sharedNode === undefined ) {
+
+			builder.setHashNode( this, hash );
+
+			sharedNode = this;
+
+		}
+
+		const sharedNodeType = sharedNode.getInputType( builder );
+
+		const nodeUniform = builder.getUniformFromNode( sharedNode, builder.shaderStage, sharedNodeType );
+		const propertyName = builder.getPropertyName( nodeUniform );
+
+		return builder.format( propertyName, type, output );
+
+	}
+
+}
+
+UniformNode.prototype.isUniformNode = true;
+
+export default UniformNode;

+ 11 - 19
examples/jsm/nodes/display/NormalMapNode.js

@@ -1,14 +1,6 @@
-import PositionNode from '../accessors/PositionNode.js';
-import NormalNode from '../accessors/NormalNode.js';
-import UVNode from '../accessors/UVNode.js';
-import MathNode from '../math/MathNode.js';
-import OperatorNode from '../math/OperatorNode.js';
-import FloatNode from '../inputs/FloatNode.js';
 import TempNode from '../core/TempNode.js';
 import ModelNode from '../accessors/ModelNode.js';
-import SplitNode from '../utils/SplitNode.js';
-import JoinNode from '../utils/JoinNode.js';
-import { ShaderNode, cond, add, mul, dFdx, dFdy, cross, max, dot, normalize, inversesqrt, equal } from '../ShaderNode.js';
+import { ShaderNode, positionView, normalView, uv, join, cond, add, sub, mul, dFdx, dFdy, cross, max, dot, normalize, inversesqrt, equal } from '../ShaderNode.js';
 
 import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from 'three';
 
@@ -58,32 +50,32 @@ class NormalMapNode extends TempNode {
 
 		const { normalMapType, scaleNode } = this;
 
-		const normalOP = new OperatorNode( '*', this.node, new FloatNode( 2.0 ).setConst( true ) );
-		let normalMap = new OperatorNode( '-', normalOP, new FloatNode( 1.0 ).setConst( true ) );
+		const normalOP = mul( this.node, 2.0 );
+		let normalMap = sub( normalOP, 1.0 );
 
 		if ( scaleNode !== null ) {
 
-			const normalMapScale = new OperatorNode( '*', new SplitNode( normalMap, 'xy'), scaleNode );
-			normalMap = new JoinNode( [ normalMapScale, new SplitNode( normalMap, 'z' ) ] );
+			const normalMapScale = mul( normalMap.xy, scaleNode );
+			normalMap = join( normalMapScale, normalMap.z );
 
 		}
 
 		if ( normalMapType === ObjectSpaceNormalMap ) {
 
-			const vertexNormalNode = new OperatorNode( '*', new ModelNode( ModelNode.NORMAL_MATRIX ), normalMap );
+			const vertexNormalNode = mul( new ModelNode( ModelNode.NORMAL_MATRIX ), normalMap );
 
-			const normal = new MathNode( MathNode.NORMALIZE, vertexNormalNode );
+			const normal = normalize( vertexNormalNode );
 
 			return normal.build( builder, type );
 
 		} else if ( normalMapType === TangentSpaceNormalMap ) {
 
 			const perturbNormal2ArbCall = perturbNormal2ArbNode( {
-				eye_pos: new PositionNode( PositionNode.VIEW ),
-				surf_norm: new NormalNode( NormalNode.VIEW ),
+				eye_pos: positionView,
+				surf_norm: normalView,
 				mapN: normalMap,
-				faceDirection: new FloatNode( 1.0 ).setConst( true ),
-				uv: new UVNode()
+				faceDirection: 1.0,
+				uv: uv()
 			} );
 
 			return perturbNormal2ArbCall.build( builder, type );

+ 0 - 33
examples/jsm/nodes/inputs/BoolNode.js

@@ -1,33 +0,0 @@
-import InputNode from '../core/InputNode.js';
-
-class BoolNode extends InputNode {
-
-	constructor( value = false ) {
-
-		super( 'bool' );
-
-		this.value = value;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		data.value = this.value;
-
-	}
-
-	deserialize( data ) {
-
-		super.serialize( data );
-
-		this.value = data.value;
-
-	}
-
-}
-
-BoolNode.prototype.isBoolNode = true;
-
-export default BoolNode;

+ 0 - 43
examples/jsm/nodes/inputs/ColorNode.js

@@ -1,43 +0,0 @@
-import InputNode from '../core/InputNode.js';
-import { Color } from 'three';
-
-class ColorNode extends InputNode {
-
-	constructor( value = new Color() ) {
-
-		super( 'color' );
-
-		this.value = value;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		const { r, g, b } = this.value;
-
-		data.r = r;
-		data.g = g;
-		data.b = b;
-
-	}
-
-	deserialize( data ) {
-
-		super.serialize( data );
-
-		const { r, g, b } = data;
-		const value = this.value;
-
-		value.r = r;
-		value.g = g;
-		value.b = b;
-
-	}
-
-}
-
-ColorNode.prototype.isColorNode = true;
-
-export default ColorNode;

+ 0 - 33
examples/jsm/nodes/inputs/FloatNode.js

@@ -1,33 +0,0 @@
-import InputNode from '../core/InputNode.js';
-
-class FloatNode extends InputNode {
-
-	constructor( value = 0 ) {
-
-		super( 'float' );
-
-		this.value = value;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		data.value = this.value;
-
-	}
-
-	deserialize( data ) {
-
-		super.serialize( data );
-
-		data.value = this.value;
-
-	}
-
-}
-
-FloatNode.prototype.isFloatNode = true;
-
-export default FloatNode;

+ 0 - 33
examples/jsm/nodes/inputs/IntNode.js

@@ -1,33 +0,0 @@
-import InputNode from '../core/InputNode.js';
-
-class IntNode extends InputNode {
-
-	constructor( value = 0 ) {
-
-		super( 'int' );
-
-		this.value = value;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		data.value = this.value;
-
-	}
-
-	deserialize( data ) {
-
-		super.serialize( data );
-
-		this.value = data.value;
-
-	}
-
-}
-
-IntNode.prototype.isIntNode = true;
-
-export default IntNode;

+ 0 - 18
examples/jsm/nodes/inputs/Matrix3Node.js

@@ -1,18 +0,0 @@
-import InputNode from '../core/InputNode.js';
-import { Matrix3 } from 'three';
-
-class Matrix3Node extends InputNode {
-
-	constructor( value = new Matrix3() ) {
-
-		super( 'mat3' );
-
-		this.value = value;
-
-	}
-
-}
-
-Matrix3Node.prototype.isMatrix3Node = true;
-
-export default Matrix3Node;

+ 0 - 18
examples/jsm/nodes/inputs/Matrix4Node.js

@@ -1,18 +0,0 @@
-import InputNode from '../core/InputNode.js';
-import { Matrix4 } from 'three';
-
-class Matrix4Node extends InputNode {
-
-	constructor( value = new Matrix4() ) {
-
-		super( 'mat4' );
-
-		this.value = value;
-
-	}
-
-}
-
-Matrix4Node.prototype.isMatrix4Node = true;
-
-export default Matrix4Node;

+ 0 - 33
examples/jsm/nodes/inputs/UintNode.js

@@ -1,33 +0,0 @@
-import InputNode from '../core/InputNode.js';
-
-class UintNode extends InputNode {
-
-	constructor( value = 0 ) {
-
-		super( 'uint' );
-
-		this.value = value;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		data.value = this.value;
-
-	}
-
-	deserialize( data ) {
-
-		super.serialize( data );
-
-		this.value = data.value;
-
-	}
-
-}
-
-UintNode.prototype.isUintNode = true;
-
-export default UintNode;

+ 0 - 41
examples/jsm/nodes/inputs/Vector2Node.js

@@ -1,41 +0,0 @@
-import InputNode from '../core/InputNode.js';
-import { Vector2 } from 'three';
-
-class Vector2Node extends InputNode {
-
-	constructor( value = new Vector2() ) {
-
-		super( 'vec2' );
-
-		this.value = value;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		const { x, y } = this.value;
-
-		data.x = x;
-		data.y = y;
-
-	}
-
-	deserialize( data ) {
-
-		super.serialize( data );
-
-		const { x, y } = data;
-		const value = this.value;
-
-		value.x = x;
-		value.y = y;
-
-	}
-
-}
-
-Vector2Node.prototype.isVector2Node = true;
-
-export default Vector2Node;

+ 0 - 43
examples/jsm/nodes/inputs/Vector3Node.js

@@ -1,43 +0,0 @@
-import InputNode from '../core/InputNode.js';
-import { Vector3 } from 'three';
-
-class Vector3Node extends InputNode {
-
-	constructor( value = new Vector3() ) {
-
-		super( 'vec3' );
-
-		this.value = value;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		const { x, y, z } = this.value;
-
-		data.x = x;
-		data.y = y;
-		data.z = z;
-
-	}
-
-	deserialize( data ) {
-
-		super.serialize( data );
-
-		const { x, y, z } = data;
-		const value = this.value;
-
-		value.x = x;
-		value.y = y;
-		value.z = z;
-
-	}
-
-}
-
-Vector3Node.prototype.isVector3Node = true;
-
-export default Vector3Node;

+ 0 - 45
examples/jsm/nodes/inputs/Vector4Node.js

@@ -1,45 +0,0 @@
-import InputNode from '../core/InputNode.js';
-import { Vector4 } from 'three';
-
-class Vector4Node extends InputNode {
-
-	constructor( value = new Vector4() ) {
-
-		super( 'vec4' );
-
-		this.value = value;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		const { x, y, z, w } = this.value;
-
-		data.x = x;
-		data.y = y;
-		data.z = z;
-		data.w = w;
-
-	}
-
-	deserialize( data ) {
-
-		super.serialize( data );
-
-		const { x, y, z, w } = data;
-		const value = this.value;
-
-		value.x = x;
-		value.y = y;
-		value.z = z;
-		value.w = w;
-
-	}
-
-}
-
-Vector4Node.prototype.isVector4Node = true;
-
-export default Vector4Node;

+ 4 - 3
examples/jsm/nodes/lights/LightContextNode.js

@@ -1,8 +1,9 @@
 import ContextNode from '../core/ContextNode.js';
 import VarNode from '../core/VarNode.js';
-import Vector3Node from '../inputs/Vector3Node.js';
+import UniformNode from '../core/UniformNode.js';
 import OperatorNode from '../math/OperatorNode.js';
 import { PhysicalLightingModel } from '../functions/BSDFs.js';
+import { Vector3 } from 'three';
 
 class LightContextNode extends ContextNode {
 
@@ -30,8 +31,8 @@ class LightContextNode extends ContextNode {
 
 		}
 
-		const directDiffuse = new VarNode( new Vector3Node(), 'DirectDiffuse', 'vec3' );
-		const directSpecular = new VarNode( new Vector3Node(), 'DirectSpecular', 'vec3' );
+		const directDiffuse = new VarNode( new UniformNode( new Vector3() ), 'DirectDiffuse', 'vec3' );
+		const directSpecular = new VarNode( new UniformNode( new Vector3() ), 'DirectSpecular', 'vec3' );
 
 		this.context.directDiffuse = directDiffuse;
 		this.context.directSpecular = directSpecular;

+ 4 - 5
examples/jsm/nodes/lights/LightNode.js

@@ -1,8 +1,7 @@
 import Node from '../core/Node.js';
 import Object3DNode from '../accessors/Object3DNode.js';
 import PositionNode from '../accessors/PositionNode.js';
-import ColorNode from '../inputs/ColorNode.js';
-import FloatNode from '../inputs/FloatNode.js';
+import UniformNode from '../core/UniformNode.js';
 import OperatorNode from '../math/OperatorNode.js';
 import MathNode from '../math/MathNode.js';
 import { NodeUpdateType } from '../core/constants.js';
@@ -20,10 +19,10 @@ class LightNode extends Node {
 
 		this.light = light;
 
-		this._colorNode = new ColorNode( new Color() );
+		this._colorNode = new UniformNode( new Color() );
 
-		this._lightCutoffDistanceNode = new FloatNode( 0 );
-		this._lightDecayExponentNode = new FloatNode( 0 );
+		this._lightCutoffDistanceNode = new UniformNode( 0 );
+		this._lightDecayExponentNode = new UniformNode( 0 );
 
 	}
 

+ 2 - 3
examples/jsm/nodes/procedural/CheckerNode.js

@@ -1,7 +1,6 @@
 import Node from '../core/Node.js';
-import UVNode from '../accessors/UVNode.js';
 
-import { ShaderNode, add, mul, floor, mod, sign } from '../ShaderNode.js';
+import { ShaderNode, uv, add, mul, floor, mod, sign } from '../ShaderNode.js';
 
 const checkerShaderNode = new ShaderNode( ( inputs ) => {
 
@@ -17,7 +16,7 @@ const checkerShaderNode = new ShaderNode( ( inputs ) => {
 
 class CheckerNode extends Node {
 
-	constructor( uvNode = new UVNode() ) {
+	constructor( uvNode = uv() ) {
 
 		super( 'float' );
 

+ 3 - 3
examples/jsm/nodes/utils/SpriteSheetUVNode.js

@@ -1,5 +1,5 @@
 import Node from '../core/Node.js';
-import FloatNode from '../inputs/FloatNode.js';
+import ConstNode from '../core/ConstNode.js';
 import UVNode from '../accessors/UVNode.js';
 import MathNode from '../math/MathNode.js';
 import OperatorNode from '../math/OperatorNode.js';
@@ -8,7 +8,7 @@ import JoinNode from '../utils/JoinNode.js';
 
 class SpriteSheetUVNode extends Node {
 
-	constructor( countNode, uvNode = new UVNode(), frameNode = new FloatNode( 0 ).setConst( true ) ) {
+	constructor( countNode, uvNode = new UVNode(), frameNode = new ConstNode( 0 ) ) {
 
 		super( 'vec2' );
 
@@ -24,7 +24,7 @@ class SpriteSheetUVNode extends Node {
 		const uv = this.uvNode;
 		const frame = this.frameNode;
 
-		const one = new FloatNode( 1 ).setConst( true );
+		const one = new ConstNode( 1 );
 
 		const width = new SplitNode( count, 'x' );
 		const height = new SplitNode( count, 'y' );

+ 3 - 3
examples/jsm/nodes/utils/TimerNode.js

@@ -1,7 +1,7 @@
-import FloatNode from '../inputs/FloatNode.js';
+import UniformNode from '../core/UniformNode.js';
 import { NodeUpdateType } from '../core/constants.js';
 
-class TimerNode extends FloatNode {
+class TimerNode extends UniformNode {
 
 	static LOCAL = 'local';
 	static GLOBAL = 'global';
@@ -9,7 +9,7 @@ class TimerNode extends FloatNode {
 
 	constructor( scope = TimerNode.LOCAL ) {
 
-		super();
+		super( 0 );
 
 		this.scope = scope;
 		this.scale = 1;

+ 20 - 1
examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js

@@ -1,11 +1,15 @@
 import NodeBuilder, { shaderStages } from 'three-nodes/core/NodeBuilder.js';
+import NodeFrame from 'three-nodes/core/NodeFrame.js';
 import SlotNode from './SlotNode.js';
 import GLSLNodeParser from 'three-nodes/parsers/GLSLNodeParser.js';
 import WebGLPhysicalContextNode from './WebGLPhysicalContextNode.js';
 
-import { ShaderChunk, ShaderLib, UniformsUtils, UniformsLib,
+import { PerspectiveCamera, ShaderChunk, ShaderLib, UniformsUtils, UniformsLib,
 	LinearEncoding, RGBAFormat, UnsignedByteType, sRGBEncoding } from 'three';
 
+const nodeFrame = new NodeFrame();
+nodeFrame.camera = new PerspectiveCamera();
+
 const nodeShaderLib = {
 	LineBasicNodeMaterial: ShaderLib.basic,
 	MeshBasicNodeMaterial: ShaderLib.basic,
@@ -368,6 +372,8 @@ ${this.shader[ getShaderStageProperty( shaderStage ) ]}
 		this._addSnippets();
 		this._addUniforms();
 
+		this._updateUniforms();
+
 		this.shader.vertexShader = this.vertexShader;
 		this.shader.fragmentShader = this.fragmentShader;
 
@@ -535,6 +541,19 @@ ${this.shader[ getShaderStageProperty( shaderStage ) ]}
 
 	}
 
+	_updateUniforms() {
+
+		nodeFrame.object = this.object;
+		nodeFrame.renderer = this.renderer;
+
+		for ( const node of this.updateNodes ) {
+
+			nodeFrame.updateNode( node );
+
+		}
+
+	}
+
 }
 
 export { WebGLNodeBuilder };

+ 2 - 2
examples/jsm/renderers/webgl/nodes/WebGLPhysicalContextNode.js

@@ -1,7 +1,7 @@
 import ContextNode from 'three-nodes/core/ContextNode.js';
 import NormalNode from 'three-nodes/accessors/NormalNode.js';
 import ExpressionNode from 'three-nodes/core/ExpressionNode.js';
-import FloatNode from 'three-nodes/inputs/FloatNode.js';
+import ConstNode from 'three-nodes/core/ConstNode.js';
 
 class WebGLPhysicalContextNode extends ContextNode {
 
@@ -28,7 +28,7 @@ class WebGLPhysicalContextNode extends ContextNode {
 
 		} else if ( scope === WebGLPhysicalContextNode.IRRADIANCE ) {
 
-			roughness = new FloatNode( 1.0 ).setConst( true );
+			roughness = new ConstNode( 1 );
 
 			this.context.uv = new NormalNode( NormalNode.WORLD );
 

+ 3 - 3
examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js

@@ -485,13 +485,13 @@ class WebGPUNodeBuilder extends NodeBuilder {
 
 				}
 
-				if ( node.isArrayInputNode === true ) {
+				if ( node.isArrayUniformNode === true ) {
 
 					uniformGPU = [];
 
-					for ( const inputNode of node.nodes ) {
+					for ( const uniformNode of node.nodes ) {
 
-						const uniformNodeGPU = this._getNodeUniform( inputNode, type );
+						const uniformNodeGPU = this._getNodeUniform( uniformNode, type );
 
 						// fit bounds to buffer
 						uniformNodeGPU.boundary = getVectorLength( uniformNodeGPU.itemSize );

+ 3 - 3
examples/webgl_materials_instance_uniform_nodes.html

@@ -41,7 +41,7 @@
 
 					this.updateType = Nodes.NodeUpdateType.Object;
 
-					this.inputNode = new Nodes.ColorNode();
+					this.uniformNode = new Nodes.UniformNode( new THREE.Color() );
 
 				}
 
@@ -52,7 +52,7 @@
 
 					const meshColor = mesh.color;
 
-					this.inputNode.value.copy( meshColor );
+					this.uniformNode.value.copy( meshColor );
 
 					// force refresh material uniforms
 					rendererState.useProgram( null );
@@ -61,7 +61,7 @@
 
 				generate( builder, output ) {
 
-					return this.inputNode.build( builder, output );
+					return this.uniformNode.build( builder, output );
 
 				}
 

+ 1 - 1
examples/webgl_materials_standard_nodes.html

@@ -99,7 +99,7 @@
 
 						const mpMapNode = new Nodes.TextureNode( rmMap );
 
-						material.colorNode = new Nodes.OperatorNode( '*', new Nodes.TextureNode( diffuseMap ), new Nodes.ColorNode( material.color ) );
+						material.colorNode = new Nodes.OperatorNode( '*', new Nodes.TextureNode( diffuseMap ), new Nodes.UniformNode( material.color ) );
 
 						// roughness is in G channel, metalness is in B channel
 						material.roughnessNode = new Nodes.SplitNode( mpMapNode, 'g' );

+ 2 - 2
examples/webgl_nodes_playground.html

@@ -131,7 +131,7 @@
 			loaderFBX.load( 'models/fbx/stanford-bunny.fbx', ( object ) => {
 
 				const defaultMaterial = new Nodes.MeshBasicNodeMaterial();
-				defaultMaterial.colorNode = new Nodes.FloatNode( 0 );
+				defaultMaterial.colorNode = new Nodes.UniformNode( 0 );
 
 				const sphere = new THREE.Mesh( new THREE.SphereGeometry( 200, 32, 16 ), defaultMaterial );
 				sphere.name = 'Sphere';
@@ -144,7 +144,7 @@
 				scene.add( box );
 
 				const defaultPointsMaterial = new Nodes.PointsNodeMaterial();
-				defaultPointsMaterial.colorNode = new Nodes.FloatNode( 0 );
+				defaultPointsMaterial.colorNode = new Nodes.UniformNode( 0 );
 
 				const torusKnot = new THREE.Points( new THREE.TorusKnotGeometry( 100, 30, 100, 16 ), defaultPointsMaterial );
 				torusKnot.name = 'Torus Knot ( Points )';

+ 2 - 2
examples/webgl_points_nodes.html

@@ -102,7 +102,7 @@
 
 				const time = new Nodes.TimerNode();
 
-				const spriteSheetCount = new Nodes.Vector2Node( new THREE.Vector2( 6, 6 ) ).setConst( true );
+				const spriteSheetCount = new Nodes.ConstNode( new THREE.Vector2( 6, 6 ) );
 
 				const fireUV = new Nodes.SpriteSheetUVNode(
 					spriteSheetCount, // count
@@ -113,7 +113,7 @@
 				const fireSprite = new Nodes.TextureNode( fireMap, fireUV );
 				const fire = new Nodes.OperatorNode( '*', fireSprite, particleIntensity );
 
-				const lerpPosition = new Nodes.FloatNode( 0 );
+				const lerpPosition = new Nodes.UniformNode( 0 );
 
 				const positionNode = new Nodes.MathNode( Nodes.MathNode.MIX, new Nodes.PositionNode( Nodes.PositionNode.LOCAL ), targetPosition, lerpPosition );
 

+ 1 - 1
examples/webgpu_compute.html

@@ -219,7 +219,7 @@
 				);
 
 				const pointsMaterial = new Nodes.PointsNodeMaterial();
-				pointsMaterial.colorNode = new Nodes.OperatorNode( '+', new Nodes.PositionNode(), new Nodes.ColorNode( new THREE.Color( 0xFFFFFF ) ) );
+				pointsMaterial.colorNode = new Nodes.OperatorNode( '+', new Nodes.PositionNode(), new Nodes.UniformNode( new THREE.Color( 0xFFFFFF ) ) );
 
 				const mesh = new THREE.Points( pointsGeometry, pointsMaterial );
 				scene.add( mesh );

+ 5 - 3
examples/webgpu_instance_uniform.html

@@ -44,7 +44,7 @@
 
 					this.updateType = Nodes.NodeUpdateType.Object;
 
-					this.inputNode = new Nodes.ColorNode();
+					this.uniformNode = new Nodes.UniformNode( new THREE.Color() );
 
 				}
 
@@ -52,13 +52,15 @@
 
 					const mesh = frame.object;
 
-					this.inputNode.value.copy( mesh.color );
+					const meshColor = mesh.color;
+
+					this.uniformNode.value.copy( meshColor );
 
 				}
 
 				generate( builder, output ) {
 
-					return this.inputNode.build( builder, output );
+					return this.uniformNode.build( builder, output );
 
 				}
 

+ 2 - 2
examples/webgpu_materials.html

@@ -116,7 +116,7 @@
 
 				// Opacity
 				material = new Nodes.MeshBasicNodeMaterial();
-				material.colorNode = new Nodes.ColorNode( new THREE.Color( 0x0099FF ) );
+				material.colorNode = new Nodes.UniformNode( new THREE.Color( 0x0099FF ) );
 				material.opacityNode = new Nodes.TextureNode( texture );
 				material.transparent = true;
 				materials.push( material );
@@ -125,7 +125,7 @@
 				material = new Nodes.MeshBasicNodeMaterial();
 				material.colorNode = new Nodes.TextureNode( texture );
 				material.opacityNode = new Nodes.TextureNode( opacityTexture );
-				material.alphaTestNode = new Nodes.FloatNode( 0.5 );
+				material.alphaTestNode = new Nodes.UniformNode( 0.5 );
 				materials.push( material );
 
 				//

+ 2 - 2
examples/webgpu_nodes_playground.html

@@ -165,7 +165,7 @@
 				loaderFBX.load( 'models/fbx/stanford-bunny.fbx', ( object ) => {
 
 					const defaultMaterial = new Nodes.MeshBasicNodeMaterial();
-					defaultMaterial.colorNode = new Nodes.FloatNode( 0 );
+					defaultMaterial.colorNode = new Nodes.UniformNode( 0 );
 
 					const sphere = new THREE.Mesh( new THREE.SphereGeometry( 200, 32, 16 ), defaultMaterial );
 					sphere.name = 'Sphere';
@@ -178,7 +178,7 @@
 					scene.add( box );
 
 					const defaultPointsMaterial = new Nodes.PointsNodeMaterial();
-					defaultPointsMaterial.colorNode = new Nodes.FloatNode( 0 );
+					defaultPointsMaterial.colorNode = new Nodes.UniformNode( 0 );
 
 					const torusKnot = new THREE.Points( new THREE.TorusKnotGeometry( 100, 30, 100, 16 ), defaultPointsMaterial );
 					torusKnot.name = 'Torus Knot ( Points )';

+ 1 - 1
examples/webgpu_rtt.html

@@ -95,7 +95,7 @@
 
 				// modulate the final color based on the mouse position
 
-				const screenFXNode = new Nodes.OperatorNode( '+', new Nodes.Vector2Node( mouse ), new Nodes.Vector2Node( new THREE.Vector2( 0.5, 0.5 ) ).setConst( true ) );
+				const screenFXNode = new Nodes.OperatorNode( '+', new Nodes.UniformNode( mouse ), new Nodes.ConstNode( new THREE.Vector2( 0.5, 0.5 ) ) );
 
 				const materialFX = new Nodes.MeshBasicNodeMaterial();
 				materialFX.colorNode = new Nodes.OperatorNode( '*', new Nodes.TextureNode( textureRenderer.getTexture() ), screenFXNode );

+ 6 - 6
examples/webgpu_sandbox.html

@@ -80,12 +80,12 @@
 				const timerNode = new Nodes.TimerNode();
 
 				// birection speed
-				const timerScaleNode = new Nodes.OperatorNode( '*', timerNode, new Nodes.Vector2Node( new THREE.Vector2( - 0.5, 0.1 ) ).setConst( true ) );
+				const timerScaleNode = new Nodes.OperatorNode( '*', timerNode, new Nodes.ConstNode( new THREE.Vector2( - 0.5, 0.1 ) ) );
 				const animateUV = new Nodes.OperatorNode( '+', new Nodes.UVNode(), timerScaleNode );
 
 				const textureNode = new Nodes.TextureNode( texture, animateUV );
 
-				materialBox.colorNode = new Nodes.MathNode( 'mix', textureNode, new Nodes.CheckerNode( animateUV ), new Nodes.FloatNode( .5 ) );
+				materialBox.colorNode = new Nodes.MathNode( 'mix', textureNode, new Nodes.CheckerNode( animateUV ), new Nodes.UniformNode( .5 ) );
 
 				// test uv 2
 				//geometryBox.setAttribute( 'uv2', geometryBox.getAttribute( 'uv' ) );
@@ -101,7 +101,7 @@
 				const materialSphere = new Nodes.MeshBasicNodeMaterial();
 
 				const displaceAnimated = new Nodes.SplitNode( new Nodes.TextureNode( textureDisplace ), 'x' );
-				const displaceY = new Nodes.OperatorNode( '*', displaceAnimated, new Nodes.FloatNode( .25 ).setConst( true ) );
+				const displaceY = new Nodes.OperatorNode( '*', displaceAnimated, new Nodes.ConstNode( .25 ) );
 
 				const displace = new Nodes.OperatorNode( '*', new Nodes.NormalNode( Nodes.NormalNode.LOCAL ), displaceY );
 
@@ -116,7 +116,7 @@
 
 				const geometryPlane = new THREE.PlaneGeometry();
 				const materialPlane = new Nodes.MeshBasicNodeMaterial();
-				materialPlane.colorNode = new Nodes.OperatorNode( '+', new Nodes.TextureNode( createDataTexture() ), new Nodes.ColorNode( new THREE.Color( 0x0000FF ) ) );
+				materialPlane.colorNode = new Nodes.OperatorNode( '+', new Nodes.TextureNode( createDataTexture() ), new Nodes.UniformNode( new THREE.Color( 0x0000FF ) ) );
 				materialPlane.opacityNode = new Nodes.SplitNode( new Nodes.TextureNode( dxt5Texture ), 'a' );
 				materialPlane.transparent = true;
 
@@ -128,7 +128,7 @@
 
 				const materialCompressed = new Nodes.MeshBasicNodeMaterial();
 				materialCompressed.colorNode = new Nodes.TextureNode( dxt5Texture );
-				materialCompressed.emissiveNode = new Nodes.ColorNode( new THREE.Color( 0x663300 ) );
+				materialCompressed.emissiveNode = new Nodes.UniformNode( new THREE.Color( 0x663300 ) );
 				materialCompressed.alphaTestNode = new Nodes.OscNode();
 				materialCompressed.transparent = true;
 
@@ -150,7 +150,7 @@
 				const geometryPoints = new THREE.BufferGeometry().setFromPoints( points );
 				const materialPoints = new Nodes.PointsNodeMaterial();
 
-				materialPoints.colorNode = new Nodes.OperatorNode( '*', new Nodes.PositionNode(), new Nodes.FloatNode( 3 ).setConst( true ) );
+				materialPoints.colorNode = new Nodes.OperatorNode( '*', new Nodes.PositionNode(), new Nodes.ConstNode( 3 ) );
 
 				const pointCloud = new THREE.Points( geometryPoints, materialPoints );
 				pointCloud.position.set( 2, - 1, 0 );

+ 1 - 1
examples/webgpu_skinning_points.html

@@ -74,7 +74,7 @@
 							child.visible = false;
 
 							const materialPoints = new Nodes.PointsNodeMaterial();
-							materialPoints.colorNode = new Nodes.ColorNode();
+							materialPoints.colorNode = new Nodes.UniformNode( new THREE.Color() );
 							materialPoints.positionNode = new Nodes.SkinningNode( child );
 
 							const pointCloud = new THREE.Points( child.geometry, materialPoints );