2024-03-06 14:01:07 +01:00
|
|
|
<script lang="ts">
|
2024-03-06 18:31:06 +01:00
|
|
|
import { Canvas } from "@threlte/core";
|
|
|
|
import { GraphManager } from "$lib/graph-manager";
|
2024-03-11 19:37:58 +01:00
|
|
|
import Graph from "$lib/components/graph/Graph.svelte";
|
2024-03-19 16:41:15 +01:00
|
|
|
import { MemoryRuntimeExecutor } from "$lib/runtime-executor";
|
2024-04-05 18:03:23 +02:00
|
|
|
import { MemoryNodeRegistry, RemoteNodeRegistry } from "$lib/node-registry";
|
2024-03-20 01:40:42 +01:00
|
|
|
import { LinearSRGBColorSpace } from "three";
|
2024-04-04 19:17:27 +02:00
|
|
|
import Details from "$lib/components/Details.svelte";
|
2024-03-20 02:17:58 +01:00
|
|
|
import { JsonView } from "@zerodevx/svelte-json-view";
|
2024-03-06 18:31:06 +01:00
|
|
|
|
2024-04-05 18:03:23 +02:00
|
|
|
const memNodeRegistry = new MemoryNodeRegistry();
|
|
|
|
const nodeRegistry = new RemoteNodeRegistry("http://localhost:5174");
|
|
|
|
|
2024-03-19 16:41:15 +01:00
|
|
|
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
|
|
|
|
|
|
|
|
const graphManager = new GraphManager(nodeRegistry, runtimeExecutor);
|
2024-03-19 16:56:42 +01:00
|
|
|
|
|
|
|
let graph = localStorage.getItem("graph");
|
|
|
|
if (graph) {
|
|
|
|
graphManager.load(JSON.parse(graph));
|
|
|
|
} else {
|
2024-03-20 01:40:42 +01:00
|
|
|
graphManager.load(graphManager.createTemplate("tree", 5));
|
2024-03-19 16:56:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
graphManager.on("save", (graph) => {
|
|
|
|
localStorage.setItem("graph", JSON.stringify(graph));
|
|
|
|
});
|
2024-03-06 18:31:06 +01:00
|
|
|
|
2024-03-13 14:30:30 +01:00
|
|
|
let debug: undefined;
|
2024-03-06 14:01:07 +01:00
|
|
|
</script>
|
|
|
|
|
2024-03-20 02:17:58 +01:00
|
|
|
<div class="wrapper">
|
|
|
|
<Details>
|
|
|
|
<button
|
|
|
|
on:click={() => graphManager.load(graphManager.createTemplate("tree", 5))}
|
|
|
|
>load tree</button
|
|
|
|
>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<button
|
|
|
|
on:click={() =>
|
2024-04-05 19:38:10 +02:00
|
|
|
graphManager.load(graphManager.createTemplate("grid", 10, 10))}
|
2024-03-20 02:17:58 +01:00
|
|
|
>load grid</button
|
|
|
|
>
|
2024-04-05 19:38:10 +02:00
|
|
|
<button
|
|
|
|
on:click={() =>
|
|
|
|
graphManager.load(graphManager.createTemplate("grid", 2, 2))}
|
|
|
|
>load small grid</button
|
|
|
|
>
|
2024-03-20 02:17:58 +01:00
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<JsonView json={debug} />
|
|
|
|
</Details>
|
|
|
|
</div>
|
2024-03-13 14:30:30 +01:00
|
|
|
|
2024-03-19 16:41:15 +01:00
|
|
|
<div id="canvas-wrapper">
|
2024-03-20 01:40:42 +01:00
|
|
|
<Canvas
|
|
|
|
shadows={false}
|
|
|
|
renderMode="on-demand"
|
|
|
|
colorManagementEnabled={false}
|
|
|
|
colorSpace={LinearSRGBColorSpace}
|
|
|
|
>
|
2024-03-12 18:47:50 +01:00
|
|
|
<!-- <PerfMonitor /> -->
|
2024-03-19 16:41:15 +01:00
|
|
|
<Graph graph={graphManager} bind:debug />
|
2024-03-06 18:31:06 +01:00
|
|
|
</Canvas>
|
2024-03-06 14:01:07 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
2024-03-19 16:41:15 +01:00
|
|
|
#canvas-wrapper {
|
2024-03-06 14:01:07 +01:00
|
|
|
height: 100vh;
|
|
|
|
}
|
|
|
|
|
2024-03-20 02:17:58 +01:00
|
|
|
.wrapper {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 100;
|
|
|
|
top: 10px;
|
|
|
|
left: 10px;
|
|
|
|
}
|
|
|
|
|
2024-03-06 14:01:07 +01:00
|
|
|
:global(html) {
|
|
|
|
background: rgb(13, 19, 32);
|
|
|
|
background: linear-gradient(
|
|
|
|
180deg,
|
|
|
|
rgba(13, 19, 32, 1) 0%,
|
|
|
|
rgba(8, 12, 21, 1) 100%
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
:global(body) {
|
|
|
|
margin: 0;
|
|
|
|
position: relative;
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
}
|
|
|
|
</style>
|