Random with SEEED
This commit is contained in:
@@ -18,29 +18,9 @@ export const ProducingGraph = <T extends Dict<unknown>,>({nodes, inputs, outputs
|
||||
const [[rows, nodeMap], setGraph] = useState<[string[][], Dict<GraphNodeWithIds<T|AdditionalNode>>]>([[], {}])
|
||||
useEffect(() => {
|
||||
setGraph(graphUntangled(nodes, inputs, outputs ?? []))
|
||||
setTimeout(() => setGraph(graphUntangled(nodes, inputs, outputs ?? [], 5000)), 0)
|
||||
setTimeout(() => setGraph(graphUntangled(nodes, inputs, outputs ?? [], 3000)), 0)
|
||||
}, [inputs, nodes, outputs])
|
||||
|
||||
/*const rowsWithInOut: (GraphNode<T>|AdditionalNode)[][] = useMemo(() => {
|
||||
const addedInputs = new Set<string>()
|
||||
const res: (GraphNode<T>|AdditionalNode)[][] = deepcopy([[], ...rows, []])
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const rowOutputs = uniquify(rows[i].flatMap(row => row.outputs))
|
||||
for (let rowOutput of rowOutputs) {
|
||||
outputs?.includes(rowOutput) && res[i+2].push({___type: 'o', value: rowOutput})
|
||||
}
|
||||
const rowInputs = uniquify(rows[i].flatMap(row => row.inputs))
|
||||
for (let rowInput of rowInputs) {
|
||||
if (addedInputs.has(rowInput))
|
||||
!res[i].some(node => isAdditionalNode(node) && node.value === rowInput) && res[i].push({___type: 'h', value: rowInput})
|
||||
else if (inputs.includes(rowInput))
|
||||
res[i].push({___type: 'i', value: rowInput})
|
||||
addedInputs.add(rowInput)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}, [rows, inputs, outputs])*/
|
||||
|
||||
useEffect(() => {
|
||||
if (!planeRef.current) return
|
||||
const plane = planeRef.current
|
||||
@@ -61,22 +41,22 @@ export const ProducingGraph = <T extends Dict<unknown>,>({nodes, inputs, outputs
|
||||
svg.setAttributeNS(null, 'viewBox', `0 0 ${width} ${height}`)
|
||||
svg.replaceChildren()
|
||||
|
||||
let paths: string[] = []
|
||||
plane.querySelectorAll('[data-outputs]').forEach(startNode => {
|
||||
if (!(startNode instanceof HTMLElement)) return
|
||||
(startNode.dataset.outputs?.split(' ') ?? []).forEach(output => {
|
||||
const endNode = plane.querySelector(`[data-name="${output}"]`)
|
||||
if (!(endNode instanceof HTMLElement)) return
|
||||
const path = document.createElementNS('http://www.w3.org/2000/svg',"path")
|
||||
path.setAttributeNS(null, 'd', createPath(plane.getBoundingClientRect(), startNode.getBoundingClientRect(), endNode.getBoundingClientRect()))
|
||||
svg.appendChild(path)
|
||||
paths.push(createPath(plane.getBoundingClientRect(), startNode.getBoundingClientRect(), endNode.getBoundingClientRect()))
|
||||
})
|
||||
})
|
||||
plane.querySelectorAll('[data-hidden][data-outputs]').forEach(elem => {
|
||||
plane.querySelectorAll('[data-hidden="true"][data-outputs]').forEach(elem => {
|
||||
if (!(elem instanceof HTMLElement)) return
|
||||
const path = document.createElementNS('http://www.w3.org/2000/svg',"path")
|
||||
path.setAttributeNS(null, 'd', drawLine(plane.getBoundingClientRect(), elem.getBoundingClientRect()))
|
||||
svg.appendChild(path)
|
||||
paths.push(drawLine(plane.getBoundingClientRect(), elem.getBoundingClientRect()))
|
||||
})
|
||||
const path = document.createElementNS('http://www.w3.org/2000/svg',"path")
|
||||
path.setAttributeNS(null, 'd', paths.join(' '))
|
||||
svg.appendChild(path)
|
||||
})
|
||||
|
||||
return <div className={styles.plane} ref={planeRef}>
|
||||
@@ -87,14 +67,17 @@ export const ProducingGraph = <T extends Dict<unknown>,>({nodes, inputs, outputs
|
||||
const node = nodeMap[uid]
|
||||
return (
|
||||
!isAdditionalNode(node)
|
||||
? <ChildType
|
||||
? <span
|
||||
data-name={node.___uid}
|
||||
data-inputs={node.___uidInputs.join(' ')}
|
||||
data-outputs={node.___uidOutputs.join(' ')}
|
||||
className={styles.node}
|
||||
key={node.name}
|
||||
node={node}
|
||||
/>
|
||||
key={node.___uid}
|
||||
data-hidden={node.___uidOutputs.length > 0}>
|
||||
<ChildType
|
||||
className={styles.node}
|
||||
node={node}
|
||||
/>
|
||||
</span>
|
||||
: node.___type === 'h'
|
||||
? <span
|
||||
className={styles.hidden}
|
||||
@@ -105,7 +88,6 @@ export const ProducingGraph = <T extends Dict<unknown>,>({nodes, inputs, outputs
|
||||
data-hidden={true}></span>
|
||||
: node.___type === 'i'
|
||||
? <span
|
||||
className={styles.input}
|
||||
key={node.___uid}
|
||||
data-name={node.___uid}
|
||||
data-outputs={node.___uidOutputs.join(' ')}
|
||||
@@ -113,7 +95,6 @@ export const ProducingGraph = <T extends Dict<unknown>,>({nodes, inputs, outputs
|
||||
<EntityIcon value={node.name}/>
|
||||
</span>
|
||||
: <EntityIcon
|
||||
className={styles.input}
|
||||
key={node.___uid}
|
||||
value={node.name}
|
||||
data-name={node.___uid}
|
||||
|
||||
Reference in New Issue
Block a user