hacking nodes
This commit is contained in:
1 parent
649c1fbdeb
commit
730c804c22
1 file changed
+28
-7
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Bbox,
|
Bbox,
|
||||||
|
DAGDims,
|
||||||
ElementMaker,
|
ElementMaker,
|
||||||
ElementMakerBaseProps,
|
ElementMakerBaseProps,
|
||||||
ElementMakerOutput,
|
ElementMakerOutput,
|
||||||
@@ -21,41 +22,60 @@ export const makeAutomationNodes = (
|
|||||||
automation: AutomationActionData,
|
automation: AutomationActionData,
|
||||||
args: ElementMakerBaseProps
|
args: ElementMakerBaseProps
|
||||||
) => {
|
) => {
|
||||||
|
const dims: DAGDims = {
|
||||||
|
...args.dims,
|
||||||
|
// think of a better to do this
|
||||||
|
// condition: args.dims.flipped
|
||||||
|
// ? args.dims.condition
|
||||||
|
// : {
|
||||||
|
// height: args.dims.condition.width,
|
||||||
|
// width: args.dims.condition.height,
|
||||||
|
// },
|
||||||
|
// trigger: args.dims.flipped
|
||||||
|
// ? args.dims.trigger
|
||||||
|
// : {
|
||||||
|
// height: args.dims.trigger.width,
|
||||||
|
// width: args.dims.trigger.height,
|
||||||
|
// },
|
||||||
|
};
|
||||||
let state: ElementMakerOutput = makeTriggerNodes(automation.trigger, {
|
let state: ElementMakerOutput = makeTriggerNodes(automation.trigger, {
|
||||||
...args,
|
...args,
|
||||||
|
dims,
|
||||||
elementData: {
|
elementData: {
|
||||||
nodes: [],
|
nodes: [],
|
||||||
edges: [],
|
edges: [],
|
||||||
},
|
},
|
||||||
position: args.dims.position,
|
position: dims.position,
|
||||||
nodeId: `${args.dims.flipped}-trigger`,
|
nodeId: `${dims.flipped}-trigger`,
|
||||||
nodeIndex: 0,
|
nodeIndex: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
state = makeConditionNodes(automation.condition, {
|
state = makeConditionNodes(automation.condition, {
|
||||||
...args,
|
...args,
|
||||||
|
dims,
|
||||||
elementData: state.elementData,
|
elementData: state.elementData,
|
||||||
position: distance.moveFromTo(
|
position: distance.moveFromTo(
|
||||||
"trigger",
|
"trigger",
|
||||||
"condition",
|
"condition",
|
||||||
state.lastNode.pos,
|
state.lastNode.pos,
|
||||||
args.dims
|
dims
|
||||||
),
|
),
|
||||||
nodeId: `${args.dims.flipped}-condition`,
|
nodeId: `${dims.flipped}-condition`,
|
||||||
nodeIndex: 1,
|
nodeIndex: 1,
|
||||||
lastNodeId: state.lastNode.nodeId,
|
lastNodeId: state.lastNode.nodeId,
|
||||||
});
|
});
|
||||||
|
|
||||||
state = makeSequenceNodes(automation.sequence, {
|
state = makeSequenceNodes(automation.sequence, {
|
||||||
...args,
|
...args,
|
||||||
|
dims,
|
||||||
elementData: state.elementData,
|
elementData: state.elementData,
|
||||||
position: distance.moveFromTo(
|
position: distance.moveFromTo(
|
||||||
"condition",
|
"condition",
|
||||||
"node",
|
"node",
|
||||||
state.lastNode.pos,
|
state.lastNode.pos,
|
||||||
args.dims
|
dims
|
||||||
),
|
),
|
||||||
nodeId: `${args.dims.flipped}-sequence`,
|
nodeId: `${dims.flipped}-sequence`,
|
||||||
nodeIndex: 2,
|
nodeIndex: 2,
|
||||||
lastNodeId: state.lastNode.nodeId,
|
lastNodeId: state.lastNode.nodeId,
|
||||||
});
|
});
|
||||||
@@ -138,7 +158,8 @@ export const makeSequenceNodes: ElementMaker<AutomationSequenceNode> = (
|
|||||||
nodes.forEach((node, nodeIndex) => {
|
nodes.forEach((node, nodeIndex) => {
|
||||||
const element = SequenceNodeMaker.makeElement(
|
const element = SequenceNodeMaker.makeElement(
|
||||||
{
|
{
|
||||||
id: `${nodeId}-${nodeIndex}`,
|
// the JSON.stringify is hack to make the edges render nicely
|
||||||
|
id: `${nodeId}-${nodeIndex}-${JSON.stringify(node)}`,
|
||||||
position: distance.moveAlong("node", position, nodeIndex, dims),
|
position: distance.moveAlong("node", position, nodeIndex, dims),
|
||||||
},
|
},
|
||||||
dims,
|
dims,
|
||||||
|
|||||||
Reference in new issue
Block a user