mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 10:44:43 +08:00
Simplify arc calculation
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
import { html } from "lit"
|
||||
import Configuration from "../../Configuration.js"
|
||||
import ElementFactory from "../../element/ElementFactory.js"
|
||||
import KnotPinTemplate from "../pin/KnotPinTemplate.js"
|
||||
import NodeTemplate from "./NodeTemplate.js"
|
||||
|
||||
export default class KnotNodeTemplate extends NodeTemplate {
|
||||
|
||||
static #traversedPin = new Set()
|
||||
|
||||
/** @type {Boolean?} */
|
||||
#chainDirection = null // The node is part of a chain connected to an input or output pin
|
||||
#switchDirectionsVisually = false
|
||||
get switchDirectionsVisually() {
|
||||
return this.#switchDirectionsVisually
|
||||
}
|
||||
set switchDirectionsVisually(value) {
|
||||
if (this.#switchDirectionsVisually == value) {
|
||||
return
|
||||
}
|
||||
this.#switchDirectionsVisually = value
|
||||
this.element.acknowledgeReflow()
|
||||
}
|
||||
|
||||
/** @type {PinElement} */
|
||||
#inputPin
|
||||
@@ -29,21 +35,6 @@ export default class KnotNodeTemplate extends NodeTemplate {
|
||||
this.element.classList.add("ueb-node-style-minimal")
|
||||
}
|
||||
|
||||
/** @param {PinElement} startingPin */
|
||||
findDirectionaPin(startingPin) {
|
||||
if (startingPin.isKnot() || KnotNodeTemplate.#traversedPin.has(startingPin)) {
|
||||
KnotNodeTemplate.#traversedPin.clear()
|
||||
return true
|
||||
}
|
||||
KnotNodeTemplate.#traversedPin.add(startingPin)
|
||||
for (let pin of startingPin.getLinks().map(l => this.blueprint.getPin(l))) {
|
||||
if (this.findDirectionaPin(pin)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<div class="ueb-node-border"></div>
|
||||
|
||||
@@ -170,4 +170,11 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
}
|
||||
|
||||
linksChanged() { }
|
||||
|
||||
/** All the link connected to this node */
|
||||
getAllConnectedLinks() {
|
||||
const nodeTitle = this.element.nodeTitle
|
||||
const query = `ueb-link[data-origin-node="${nodeTitle}"],ueb-link[data-target-node="${nodeTitle}"]`
|
||||
return /** @type {LinkElement[]} */([...this.blueprint.querySelectorAll(query)])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user