|
@@ -2,6 +2,11 @@ import InputNode from './InputNode.js';
|
|
|
import { objectGroup } from './UniformGroupNode.js';
|
|
import { objectGroup } from './UniformGroupNode.js';
|
|
|
import { nodeObject, getConstNodeType } from '../tsl/TSLCore.js';
|
|
import { nodeObject, getConstNodeType } from '../tsl/TSLCore.js';
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Class for representing a uniform.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @augments InputNode
|
|
|
|
|
+ */
|
|
|
class UniformNode extends InputNode {
|
|
class UniformNode extends InputNode {
|
|
|
|
|
|
|
|
static get type() {
|
|
static get type() {
|
|
@@ -10,17 +15,50 @@ class UniformNode extends InputNode {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Constructs a new uniform node.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {Any} value - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture).
|
|
|
|
|
+ * @param {String?} nodeType - The node type. If no explicit type is defined, the node tries to derive the type from its value.
|
|
|
|
|
+ */
|
|
|
constructor( value, nodeType = null ) {
|
|
constructor( value, nodeType = null ) {
|
|
|
|
|
|
|
|
super( value, nodeType );
|
|
super( value, nodeType );
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * This flag can be used for type testing.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @type {Boolean}
|
|
|
|
|
+ * @readonly
|
|
|
|
|
+ * @default true
|
|
|
|
|
+ */
|
|
|
this.isUniformNode = true;
|
|
this.isUniformNode = true;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * The name or label of the uniform.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @type {String}
|
|
|
|
|
+ * @default ''
|
|
|
|
|
+ */
|
|
|
this.name = '';
|
|
this.name = '';
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * The uniform group of this uniform. By default, uniforms are
|
|
|
|
|
+ * managed per object but they might belong to a shared group
|
|
|
|
|
+ * which is updated per frame or render call.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @type {UniformGroupNode}
|
|
|
|
|
+ */
|
|
|
this.groupNode = objectGroup;
|
|
this.groupNode = objectGroup;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Sets the {@link UniformNode#name} property.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {String} name - The name of the uniform.
|
|
|
|
|
+ * @return {UniformNode} A reference to this node.
|
|
|
|
|
+ */
|
|
|
label( name ) {
|
|
label( name ) {
|
|
|
|
|
|
|
|
this.name = name;
|
|
this.name = name;
|
|
@@ -29,6 +67,12 @@ class UniformNode extends InputNode {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Sets the {@link UniformNode#groupNode} property.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {UniformGroupNode} group - The uniform group.
|
|
|
|
|
+ * @return {UniformNode} A reference to this node.
|
|
|
|
|
+ */
|
|
|
setGroup( group ) {
|
|
setGroup( group ) {
|
|
|
|
|
|
|
|
this.groupNode = group;
|
|
this.groupNode = group;
|
|
@@ -37,12 +81,24 @@ class UniformNode extends InputNode {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Returns the {@link UniformNode#groupNode}.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return {UniformGroupNode} The uniform group.
|
|
|
|
|
+ */
|
|
|
getGroup() {
|
|
getGroup() {
|
|
|
|
|
|
|
|
return this.groupNode;
|
|
return this.groupNode;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * By default, this method returns the result of {@link Node#getHash} but derived
|
|
|
|
|
+ * classes might overwrite this method with a different implementation.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param {NodeBuilder} builder - The current node builder.
|
|
|
|
|
+ * @return {String} The uniform hash.
|
|
|
|
|
+ */
|
|
|
getUniformHash( builder ) {
|
|
getUniformHash( builder ) {
|
|
|
|
|
|
|
|
return this.getHash( builder );
|
|
return this.getHash( builder );
|