Flow Node - IRobot1/three-flow-ts GitHub Wiki
Introduction
FlowNode
extends Mesh
and is designed to represent a node within a flow diagram.
Constructors
- FlowNode(diagram: FlowDiagram, node: FlowNodeParameters)
- Description: Initializes a new instance of
FlowNode
with the specified diagram and node parameters. - Parameters:
diagram
(FlowDiagram): The flow diagram to which this node belongs.node
(FlowNodeParameters): Configuration parameters for the node.
- Example:
const flowDiagram = new FlowDiagram(); const nodeParams = { id: 'node1', material: {color: 'red'}, width: 100, height: 50 }; const flowNode = new FlowNode(flowDiagram, nodeParams);
- Description: Initializes a new instance of
Properties
- width
- Type:
number
- Description: Gets or sets the width of the node. The value is clamped between
minwidth
andmaxwidth
. FiresFlowEventType.WIDTH_CHANGED
event
- Type:
- height
- Type:
number
- Description: Gets or sets the height of the node. The value is clamped between
minheight
andmaxheight
. FiresFlowEventType.HEIGHT_CHANGED
event
- Type:
- lockaspectratio
- Type:
boolean
- Description: When true, resizing objects with same width and height (like circles and squares) works correctly. color
- Type:
ColorRepresentation
- Description: Gets or sets the color of the node.
- Type:
- resizable
- Type:
boolean
- Description: Indicates whether the node is resizable. Fires
FlowEventType.RESIZABLE_CHANGED
event
- Type:
- draggable
- Type:
boolean
- Description: Indicates whether the node is draggable. Fires
FlowEventType.DRAGGABLE_CHANGED
event
- Type:
- scalable
- Type:
boolean
- Description: Indicates whether the node is scalable. Fires
FlowEventType.SCALABLE_CHANGED
event
- Type:
- scalar
- Type:
number
- Description: Gets or sets the scale factor of the node. Fires
FlowEventType.SCALE_CHANGED
event
- Type:
- hidden
- Type:
boolean
- Description: Gets or sets the visibility of the node. Fires
FlowEventType.HIDDEN_CHANGED
event
- Type:
Public Methods
- getConnector(id?: string): Object3D
- Description: Retrieves a connector object for this node. This can be used for linking nodes with edges.
- Parameters:
id
(string, optional): The identifier of the connector.
- Returns: Object3D
- Usage:
const connector = flowNode.getConnector('connectorId');
Override Methods
-
createGeometry(parameters: FlowNodeParameters): BufferGeometry
- Description: Creates the geometry for the node. This method can be overridden to customize the node's shape.
- Parameters:
parameters
(FlowNodeParameters): The parameters for the node.
- Returns: BufferGeometry
- Usage:
class CustomFlowNode extends FlowNode { override createGeometry(params:CustomFlowNodeParameters) { return new CustomGeometry(params.width, params.height); } } // or node.createGeometry = (parameters: CustomFlowNodeParameters): BufferGeometry => { return new CustomGeometry(this.width, this.height) }
-
resizeGeometry()
- Description: Called by the base class when geometry is resized. Allows derived classes to resize based on new width and height.
- Returns:
void
- Usage:
this.resizeGeometry = () => { mesh.geometry = this.bannerGeometry(bannerheight, bannerdentsize) mesh.position.set(0, (-this.height + bannerheight) / 2, 0.001) if (subtitle.wrapwidth != this.width - 0.2) { subtitle.wrapwidth = this.width - 0.2 subtitle.updateLabel() } }
-
dispose()
- Description: Disposes of the node, freeing up resources and Fires
FlowEventType.DISPOSE
event - Returns:
void
- Usage:
flowNode.dispose();
- Description: Disposes of the node, freeing up resources and Fires
Events
- FlowEventType.WIDTH_CHANGED
- Description: Fired when the node's width changes.
- FlowEventType.HEIGHT_CHANGED
- Description: Fired when the node's height changes.
- FlowEventType.RESIZABLE_CHANGED
- Description: Fired when the
resizable
property changes.
- Description: Fired when the
- FlowEventType.DRAGGABLE_CHANGED
- Description: Fired when the
draggable
property changes.
- Description: Fired when the
- FlowEventType.SCALABLE_CHANGED
- Description: Fired when the
scalable
property changes.
- Description: Fired when the
- FlowEventType.SCALE_CHANGED
- Description: Fired when the
scalar
property changes.
- Description: Fired when the
- FlowEventType.HIDDEN_CHANGED
- Description: Fired when the
hidden
property changes.
- Description: Fired when the
- FlowEventType.DISPOSE
- Description: Fired when the node is disposed.