# new LGraphNode(title)
Base Class for all the node type classes
Parameters:
Name | Type | Description |
---|---|---|
title |
String | a name for the node |
- Source:
Methods
# (static) addConnection(name, type, pos, direction)
add an special connection to this node (used for special kinds of graphs)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
type |
string | string defining the input type ("vec3","number",...) |
pos |
Array.<number> | position of the connection inside the node |
direction |
string | if is input or output |
- Source:
# (static) addInput(name, type, extra_info)
add a new input slot to use in this node
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
type |
string | string defining the input type ("vec3","number",...), it its a generic one use 0 |
extra_info |
Object | this can be used to have special properties of an input (label, color, position, etc) |
- Source:
# (static) addInputs(array)
add several new input slots in this node
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | of triplets like [[name,type,extra_info],[...]] |
- Source:
# (static) addNodeMethod(func)
Adds this method to all nodetypes, existing and to be created
(You can add it to LGraphNode.prototype but then existing node types wont have it)
Parameters:
Name | Type | Description |
---|---|---|
func |
function |
- Source:
# (static) addOutput(name, type, extra_info)
add a new output slot to use in this node
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
type |
string | string defining the output type ("vec3","number",...) |
extra_info |
Object | this can be used to have special properties of an output (label, special color, position, etc) |
- Source:
# (static) addOutputs(array)
add a new output slot to use in this node
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | of triplets like [[name,type,extra_info],[...]] |
- Source:
# (static) addProperty(name, default_value, type, extra_info)
add a new property to this node
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
default_value |
* | |
type |
string | string defining the output type ("vec3","number",...) |
extra_info |
Object | this can be used to have special properties of the property (like values, etc) |
- Source:
# (static) addWidget(type, name, value, callback, options) → {Object}
Defines a widget inside the node, it will be rendered on top of the node, you can control
lots of properties
Parameters:
Name | Type | Description |
---|---|---|
type |
String | the widget type (could be "number","string","combo" |
name |
String | the text to show on the widget |
value |
String | the default value |
callback |
function | String | function to call when it changes (optionally, it can be the name of the property to modify) |
options |
Object | the object that contains special properties of this widget |
- Source:
Returns:
the created widget object
- Type
- Object
# (static) clearTriggeredSlot(slot, link_id)
clears the trigger slot animation
Parameters:
Name | Type | Description |
---|---|---|
slot |
Number | the index of the output slot |
link_id |
Number | [optional] in case you want to trigger and specific output link in a slot |
- Source:
# (static) collapse()
Collapse the node to make it smaller on the canvas
- Source:
# (static) computeSize(minHeight) → {number}
computes the minimum size of a node according to its inputs and output slots
Parameters:
Name | Type | Description |
---|---|---|
minHeight |
number |
- Source:
Returns:
the total size
- Type
- number
# (static) configure()
configure a node from an object containing the serialized info
- Source:
# (static) connect(slot, node, target_slot) → {Object}
connect this node output to the input of another node
Parameters:
Name | Type | Description |
---|---|---|
slot |
number_or_string | (could be the number of the slot or the string with the name of the slot) |
node |
LGraphNode | the target node |
target_slot |
number_or_string | the input slot of the target node (could be the number of the slot or the string with the name of the slot, or -1 to connect a trigger) |
- Source:
Returns:
the link_info is created, otherwise null
- Type
- Object
# (static) createNode(type, name, options)
Create a node of a given type with a name. The node is not attached to any graph yet.
Parameters:
Name | Type | Description |
---|---|---|
type |
String | full name of the node class. p.e. "math/sin" |
name |
String | a name to distinguish from other nodes |
options |
Object | to set options |
- Source:
# (static) disconnectInput(slot) → {boolean}
disconnect one input
Parameters:
Name | Type | Description |
---|---|---|
slot |
number_or_string | (could be the number of the slot or the string with the name of the slot) |
- Source:
Returns:
if it was disconnected successfully
- Type
- boolean
# (static) disconnectOutput(slot, target_node) → {boolean}
disconnect one output to an specific node
Parameters:
Name | Type | Description |
---|---|---|
slot |
number_or_string | (could be the number of the slot or the string with the name of the slot) |
target_node |
LGraphNode | the target node to which this slot is connected [Optional, if not target_node is specified all nodes will be disconnected] |
- Source:
Returns:
if it was disconnected successfully
- Type
- boolean
# (static) findInputSlot(name) → {number}
returns the input slot with a given name (used for dynamic slots), -1 if not found
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the slot |
- Source:
Returns:
the slot (-1 if not found)
- Type
- number
# (static) findOutputSlot(name) → {number}
returns the output slot with a given name (used for dynamic slots), -1 if not found
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the slot |
- Source:
Returns:
the slot (-1 if not found)
- Type
- number
# (static) getBounding() → {Float32Array}
returns the bounding of the object, used for rendering purposes
bounding is: [topleft_cornerx, topleft_cornery, width, height]
- Source:
Returns:
the total size
- Type
- Float32Array
# (static) getConnectionPos(is_input, slot, out) → {Array.<number>}
returns the center of a connection point in canvas coords
Parameters:
Name | Type | Description |
---|---|---|
is_input |
boolean | true if if a input slot, false if it is an output |
slot |
number_or_string | (could be the number of the slot or the string with the name of the slot) |
out |
vec2 | [optional] a place to store the output, to free garbage |
- Source:
Returns:
the position
- Type
- Array.<number>
# (static) getInputData(slot, forceUpdate) → {*}
Retrieves the input data (data traveling through the connection) from one slot
Parameters:
Name | Type | Description |
---|---|---|
slot |
number | |
forceUpdate |
boolean | if set to true it will force the connected node of this slot to output data into this link |
- Source:
Returns:
data or if it is not connected returns undefined
- Type
- *
# (static) getInputDataByName(slot_name, force_update) → {*}
Retrieves the input data from one slot using its name instead of slot number
Parameters:
Name | Type | Description |
---|---|---|
slot_name |
String | |
force_update |
boolean | if set to true it will force the connected node of this slot to output data into this link |
- Source:
Returns:
data or if it is not connected returns null
- Type
- *
# (static) getInputDataType(slot) → {String}
Retrieves the input data type (in case this supports multiple input types)
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
Returns:
datatype in string format
- Type
- String
# (static) getInputInfo(slot) → {Object}
tells you info about an input connection (which node, type, etc)
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
Returns:
object or null { link: id, name: string, type: string or 0 }
- Type
- Object
# (static) getInputLink(slot) → {LLink}
Returns the link info in the connection of an input slot
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
Returns:
object or null
- Type
- LLink
# (static) getInputNode(slot) → {LGraphNode}
returns the node connected in the input slot
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
Returns:
node or null
- Type
- LGraphNode
# (static) getInputOrProperty(name) → {*}
returns the value of an input with this name, otherwise checks if there is a property with
that name
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
- Source:
Returns:
value
- Type
- *
# (static) getOutputData(slot) → {Object}
tells you the last output data that went in that slot
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
Returns:
object or null
- Type
- Object
# (static) getOutputInfo(slot) → {Object}
tells you info about an output connection (which node, type, etc)
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
Returns:
object or null { name: string, type: string, links: [ ids of links in
number ] }
- Type
- Object
# (static) getOutputNodes(slot) → {array}
retrieves all the nodes connected to this output slot
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
Returns:
- Type
- array
# (static) getPropertyInfo(property) → {Object}
returns all the info available about a property of this node.
Parameters:
Name | Type | Description |
---|---|---|
property |
String | name of the property |
- Source:
Returns:
the object with all the available info
- Type
- Object
# (static) getSlotInPosition(x, y) → {Object}
checks if a point is inside a node slot, and returns info about which slot
Parameters:
Name | Type | Description |
---|---|---|
x |
number | |
y |
number |
- Source:
Returns:
if found the object contains { input|output: slot object, slot: number,
link_pos: [x,y] }
- Type
- Object
# (static) getTitle()
get the title string
- Source:
# (static) isAnyOutputConnected() → {boolean}
tells you if there is any connection in the output slots
- Source:
Returns:
- Type
- boolean
# (static) isInputConnected(slot) → {boolean}
tells you if there is a connection in one input slot
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
Returns:
- Type
- boolean
# (static) isOutputConnected(slot) → {boolean}
tells you if there is a connection in one output slot
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
Returns:
- Type
- boolean
# (static) isPointInside(x, y) → {boolean}
checks if a point is inside the shape of a node
Parameters:
Name | Type | Description |
---|---|---|
x |
number | |
y |
number |
- Source:
Returns:
- Type
- boolean
# (static) pin()
Forces the node to do not move or realign on Z
- Source:
# (static) removeInput(slot)
remove an existing input slot
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
# (static) removeOutput(slot)
remove an existing output slot
Parameters:
Name | Type | Description |
---|---|---|
slot |
number |
- Source:
# (static) serialize()
serialize the content
- Source:
# (static) setOutputData(slot, data)
sets the output data
Parameters:
Name | Type | Description |
---|---|---|
slot |
number | |
data |
* |
- Source:
# (static) setOutputDataType(slot, datatype)
sets the output data type, useful when you want to be able to overwrite the data type
Parameters:
Name | Type | Description |
---|---|---|
slot |
number | |
datatype |
String |
- Source:
# (static) setProperty(name, value)
sets the value of a property
Parameters:
Name | Type | Description |
---|---|---|
name |
String | |
value |
* |
- Source:
# (static) setSize(size)
changes node size and triggers callback
Parameters:
Name | Type | Description |
---|---|---|
size |
vec2 |
- Source:
# (static) toString()
serialize and stringify
- Source:
# (static) trigger(event, param)
Triggers an event in this node, this will trigger any output with the same name
Parameters:
Name | Type | Description |
---|---|---|
event |
String | name ( "on_play", ... ) if action is equivalent to false then the event is send to all |
param |
* |
- Source:
# (static) triggerSlot(slot, param, link_id)
Triggers an slot event in this node
Parameters:
Name | Type | Description |
---|---|---|
slot |
Number | the index of the output slot |
param |
* | |
link_id |
Number | [optional] in case you want to trigger and specific output link in a slot |
- Source: