feat: init

This commit is contained in:
2026-01-19 16:25:29 +01:00
parent 450262b4ae
commit 2904c13c41
2 changed files with 37 additions and 3 deletions

View File

@@ -1,8 +1,8 @@
import type { NodeInstance, Socket } from "@nodarium/types";
import { getContext, setContext } from "svelte";
import { SvelteSet } from "svelte/reactivity";
import { SvelteMap, SvelteSet } from "svelte/reactivity";
import type { GraphManager } from "./graph-manager.svelte";
import type { OrthographicCamera } from "three";
import type { Mesh, OrthographicCamera, Vector3 } from "three";
const graphStateKey = Symbol("graph-state");
@@ -46,6 +46,8 @@ export class GraphState {
width = $state(100);
height = $state(100);
edgeGeometries = new SvelteMap<string, { geo: Mesh, points: Vector3[] }>();
wrapper = $state<HTMLDivElement>(null!);
rect: DOMRect = $derived(
(this.wrapper && this.width && this.height) ? this.wrapper.getBoundingClientRect() : new DOMRect(0, 0, 0, 0),
@@ -97,6 +99,14 @@ export class GraphState {
isBodyFocused = () => document?.activeElement?.nodeName !== "INPUT";
setEdgeGeometry(edgeId: string, edgeGeometry: { geo: Mesh, points: Vector3[] }) {
this.edgeGeometries.set(edgeId, edgeGeometry);
}
removeEdgeGeometry(edgeId: string) {
this.edgeGeometries.delete(edgeId);
}
updateNodePosition(node: NodeInstance) {
if (
node.state.x === node.position[0] &&