chore: cleanup edge and node code
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m8s
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m8s
This commit is contained in:
@@ -45,18 +45,17 @@
|
|||||||
|
|
||||||
let mesh = $state<Mesh>();
|
let mesh = $state<Mesh>();
|
||||||
|
|
||||||
let lastId: number | null = null;
|
let lastId: string | null = null;
|
||||||
|
|
||||||
const primeA = 31;
|
|
||||||
const primeB = 37;
|
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
const new_x = to.x - from.x;
|
const new_x = to.x - from.x;
|
||||||
const new_y = to.y - from.y;
|
const new_y = to.y - from.y;
|
||||||
const curveId = new_x * primeA + new_y * primeB;
|
const curveId = `${from.x}-${from.y}-${to.x}-${to.y}`;
|
||||||
|
|
||||||
if (lastId === curveId) {
|
if (lastId === curveId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
lastId = curveId;
|
||||||
|
|
||||||
const length = Math.floor(
|
const length = Math.floor(
|
||||||
Math.sqrt(Math.pow(new_x, 2) + Math.pow(new_y, 2)) / 4,
|
Math.sqrt(Math.pow(new_x, 2) + Math.pow(new_y, 2)) / 4,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
import { colors } from "../graph/colors.svelte";
|
import { colors } from "../graph/colors.svelte";
|
||||||
import { appSettings } from "$lib/settings/app-settings.svelte";
|
import { appSettings } from "$lib/settings/app-settings.svelte";
|
||||||
|
|
||||||
const graph = getGraphManager();
|
|
||||||
const graphState = getGraphState();
|
const graphState = getGraphState();
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -37,14 +36,11 @@
|
|||||||
const height = graphState.getNodeHeight(node.type);
|
const height = graphState.getNodeHeight(node.type);
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (!node?.tmp) node.tmp = {};
|
|
||||||
node.tmp.mesh = meshRef;
|
|
||||||
});
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
if (!node.tmp) node.tmp = {};
|
if (!node.tmp) node.tmp = {};
|
||||||
node.tmp.mesh = meshRef;
|
if (meshRef && !node.tmp?.mesh) {
|
||||||
graphState.updateNodePosition(node);
|
node.tmp.mesh = meshRef;
|
||||||
|
graphState.updateNodePosition(node);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user