Inheritance: EventDispatcher → Node →
This type of node allows to implement nodes with custom scripts. The script section is represented as an instance of CodeNode written with JavaScript. The script itself must adhere to a specific structure.
node.needsUpdate is set.ScriptableNodeResources.set( 'TSL', TSL );
const scriptableNode = scriptable( js( `
layout = {
outputType: 'node',
elements: [
{ name: 'source', inputType: 'node' },
]
};
const { mul, oscSine } = TSL;
function main() {
const source = parameters.get( 'source' ) || float();
return mul( source, oscSine() ) );
}
` ) );
scriptableNode.setParameter( 'source', color( 1, 0, 0 ) );
const material = new THREE.MeshBasicNodeMaterial();
material.colorNode = scriptableNode;
Constructs a new scriptable node.
codeNode
The code node.
Default is null.
parameters
The parameters definition.
Default is {}.
The code node.
Default is null.
This flag can be used for type testing.
Default is true.
The parameters definition.
Default is {}.
The source code of the scriptable node.
Calls a function from the script.
name
The function name.
params
A list of parameters.
Returns: The result of the function call.
Asynchronously calls a function from the script.
name
The function name.
params
A list of parameters.
Returns: The result of the function call.
Deletes all parameters from the script.
Returns: A reference to this node.
Deletes a parameter from the script.
name
The parameter to remove.
Returns: A reference to this node.
Frees all internal resources.
Overrides: Node#dispose
Returns default output of the script.
Returns: The default output.
Returns default node output of the script.
Returns: The default node output.
Returns an input from the layout with the given id/name.
id
The id/name of the input.
Returns: The element entry.
Returns the layout of the script.
Returns: The script's layout.
Gets the value of a local script variable.
name
The variable name.
Returns: The value.
Returns a function created from the node's script.
Returns: The function representing the node's code.
Overwritten since the node types is inferred from the script's output.
builder
The current node builder
Overrides: Node#getNodeType
Returns: The node type.
Returns an object representation of the script.
Returns: The result object.
Returns a script output for the given name.
name
The name of the output.
Returns: The node value.
Returns an output from the layout with the given id/name.
id
The id/name of the output.
Returns: The element entry.
Returns a parameter for the given name
name
The name of the parameter.
Returns: The node value.
Returns the value of this node which is the value of the default output.
Returns: The value.
Event listener for the refresh event.
Refreshes the script node.
output
An optional output.
Default is null.
Sets the reference of a local script variable.
name
The variable name.
value
The reference to set.
Returns: The resource map
Defines a script output for the given name and value.
name
The name of the output.
value
The node value.
Returns: A reference to this node.
Sets a value for the given parameter name.
name
The parameter name.
value
The parameter value.
Returns: A reference to this node.