GraphNode

Base class for graph nodes.

When declaring a new node class, be sure to define .type static member to declare its type name string, otherwise it won't be auto registered.

Constructor

new L3D.GraphNode(o, skipInitialize)

Parameters
o Object

Configure options.

skipInitialize bool

If true, initialize will not be called. This lets sub-classes defer calling initalize until they've done their own constructor.

Extends

Properties

Standard data types for node inputs and outputs.

bypass bool

If the node is set as bypass, it will not be computed but instead will return data from the first compatible input.

disabled bool

If the node is disabled, it will not be computed.

enabled bool

If the node is enabled, it will be computed normally.

graph Graph

The graph this node belongs to.

Overrides:
id String

The unique identifier of the object. Changing a node's ID can have unintended consequences.

inputs Array

The list of inputs for the node.

isPlaying bool

Is the engine currently playing the scene?

Overrides:
name String

The name of the object.

nodePositionX number

The node's x position in the graph.

nodePositionY number

The node's y position in the graph.

nodeType String

The type of the node, as registered in the GraphManager.

numInputs number

The number of inputs for the node.

numOutputs number

The number of outputs for the node.

Overrides:
onModified Signal

Fired when the object has been modified.

Overrides:
onNameChanged Signal

Fired when the object's name changes.

outputs Array

The list of outputs for the node.

scene Scene

The scene this node is contained in.

state Object

Flags and other data for the node.

timeDependent bool

If true, the node will be invalidated before every update, forcing the nodes outputs to be recomputed.

title String

The title of the node

Methods

addInput(name, defaultValue, type, options) → nullable NodeInput

Add an input property to the node.

Parameters
name *

String name, or NodeInput to directly add.

defaultValue *
type *

If type is an Object, then it is the options, and the type is implied from the default value. If type is null, it is implied from the default value. Otherwise, if type is a string, it is an explicit declaration of the input's type.

options Object

Optional configuration for the input. Possible options are: {bool} isColor The Editor should tread this property as a color. {bool} noLabel The Editor should not display the label for this property. {String} label The label the Editor should use instead of the name. {bool} noConnections The property does not allow connections. It will not be displayed on the node graph node. {bool} isInt The number property should be treated as an integer. {number} min The minimum value of the property. {number} max The maximum value of the property. {number} precision The number of decimal places the Editor shows. {number} step The increment value to use for the number spinner in the Editor. {bool} disabled The Editor control should be shown as disabled. {Map,Array} enum The property should be treated as an enum by the Editor, and these are the strings (and associated values, if a Map) to allow the user to choose from.

Returns
NodeInput

addOutput(name, type, options) → nullable NodeOutput

Add an output to the node.

Parameters
name String

The name of the output. This must be unique within the node.

type String

The data type of the output. If type is null, it is dynamic. If type is an Object, it is the options and type is considered dynamic.

options Object

Optional configuration for the output. Possible options are: {bool} noLabel Don't display the label for the output. {bool} noConnections Don't display a label or a connector for this output.

Returns
NodeOutput

clearError()

Remove any error messages from the node.

clone(options) → Object

Overrides:

Creates a clone of this object.

Parameters
options Object

Options for the clone method.

Returns
Object

collapse(force)

Collapse the node to make it smaller on the canvas.

Parameters
force bool

configure(info)

Overrides:

Configure the node from a JSON object.

Parameters
info Object

connectionChanged()

Called when an input has been connected or disconnected.

getDynamicType(out) → String

Get the type of a dynamic output.

Parameters
out NodeOutput
Returns
String

getInput(name) → nullable NodeInput

Find the input with the given name.

Parameters
name String
Returns
NodeInput

getOutput(name) → nullable NodeOutput

Fidn the output with the given name.

Parameters
name String
Returns
NodeOutput

getPropertyInfo(path) → Object

Overrides:

Get information about a particular property of this object.

Parameters
path String
Returns
Object

getTypeFromData(data) → String

Get the implicit property type for a given data.

Parameters
data *
Returns
String

initialize(options)

Called by the constructor for the node implementation to add any inputs, outputs, and other initialization it wants to do.

Parameters
options Object

initializeAudioNode(options)

Configure the node as an AudioNode, using object MixIns instead of class inheritance.

Parameters
options Object

initializeBehaviorNode(options)

Configure the node as an BehaviorNode, using object MixIns instead of class inheritance.

Parameters
options Object

initializeConstraintNode(options)

Configure the node as a ConstraintNode, using object MixIns instead of class inheritance.

Parameters
options Object

initializeGeometryNode(options)

Configure the node as a GeometryNode, using object MixIns instead of class inheritance.

Parameters
options Object

initializeImageCompositeNode(options)

Configure the node as an ImageFilterNode, using object MixIns instead of class inheritance.

Parameters
options Object

initializeImageFilterNode(options)

Configure the node as an ImageFilterNode, using object MixIns instead of class inheritance.

Parameters
options Object

initializeImageNode(options)

Configure the node as an ImageNode, using object MixIns instead of class inheritance.

Parameters
options Object

initializeParticleNode(options)

Configure the node as an ParticleNode, using object MixIns instead of class inheritance.

Parameters
options Object

initializeSceneNode(options)

Configure the node as a SceneNode, using object MixIns instead of class inheritance.

Parameters
options Object

initializeTransformNode(options)

Configure the node with transformation properties.

Parameters
options Object

removeOutput(name)

Remove an output from the node.

Parameters
name String

renameInput(input, newName)

Rename an input property.

Parameters
input NodeInput
newName String

renameOutput(output, newName)

Rename an output property.

Parameters
output NodeOutput
newName String

serialize() → Object

Overrides:

Save the node to a JSON object.

Returns
Object

setDependency(input, output)

Define an explicit dependency between an input and an output, so that when an input is changed, it only dirties specific outputs in the case when the node has multiple outputs.

Parameters
input NodeInput | NodeOutput

Can be a NodeInput or NodeOutput

output NodeOutput

setDirty(from, fromShaderUniform)

Mark the node as dirty.

Parameters
from NodeInput

The input that caused the node to be dirty.

fromShaderUniform bool

If the dirty propagation was originated from a shader uniform output. This is used by Material nodes to avoid invalidating shader data unnecessarily causing shaders to be regenerated when a uniform value changes.

setError(message)

Set an error message for the node.

Parameters
message String

setModified()

Overrides:

Fires the objects onModified signal.

setNodePosition(x, y)

Set the node's position in the graph.

Parameters
x number
y number

timeChanged()

Called before an update when timeDependent is true.

toJSON() → Object

Overrides:

Serialize the object to a JSON structure

Returns
Object

The serialized version of the object.

updateMaterial(material)

Called to allow shader nodes to update uniform values for the material

Parameters
material Material

validateInputs()

Called to ensure the node has valid input connections.