diff --git a/app/src/lib/graph-interface/graph-manager.ts b/app/src/lib/graph-interface/graph-manager.ts
index c7f63aa..c962126 100644
--- a/app/src/lib/graph-interface/graph-manager.ts
+++ b/app/src/lib/graph-interface/graph-manager.ts
@@ -1,6 +1,6 @@
import type { Edge, Graph, Node, NodeInput, NodeRegistry, Socket, } from "@nodes/types";
import { fastHashString } from "@nodes/utils";
-import { get, writable, type Writable } from "svelte/store";
+import { writable, type Writable } from "svelte/store";
import EventEmitter from "./helpers/EventEmitter.js";
import { createLogger } from "./helpers/index.js";
import throttle from "./helpers/throttle.js";
@@ -42,7 +42,6 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any, "
history: HistoryManager = new HistoryManager();
execute = throttle(() => {
- console.log("Props", get(this.nodes).values().find(n => n.type === "max/plantarium/gravity")?.props);
if (this.loaded === false) return;
this.emit("result", this.serialize());
}, 10);
diff --git a/app/src/lib/graph-interface/graph/Wrapper.svelte b/app/src/lib/graph-interface/graph/Wrapper.svelte
index a724814..062e540 100644
--- a/app/src/lib/graph-interface/graph/Wrapper.svelte
+++ b/app/src/lib/graph-interface/graph/Wrapper.svelte
@@ -48,7 +48,7 @@
$effect(() => {
if (graphState.activeNodeId !== -1) {
activeNode = manager.getNode(graphState.activeNodeId);
- } else {
+ } else if (activeNode) {
activeNode = undefined;
}
});
@@ -64,7 +64,7 @@
});
manager.on("settings", (_settings) => {
- settingTypes = _settings.types;
+ settingTypes = { ...settingTypes, ..._settings.types };
settings = _settings.values;
});
diff --git a/app/src/lib/graph-interface/node/NodeInput.svelte b/app/src/lib/graph-interface/node/NodeInput.svelte
index c60d8b0..2e67d0d 100644
--- a/app/src/lib/graph-interface/node/NodeInput.svelte
+++ b/app/src/lib/graph-interface/node/NodeInput.svelte
@@ -31,7 +31,7 @@
}
let value = $state(getDefaultValue());
- $inspect({ nodeId: node.type, id, value });
+
$effect(() => {
if (value !== undefined && node?.props?.[id] !== value) {
node.props = { ...node.props, [id]: value };
diff --git a/app/src/lib/settings/NestedSettings.svelte b/app/src/lib/settings/NestedSettings.svelte
new file mode 100644
index 0000000..aa9141a
--- /dev/null
+++ b/app/src/lib/settings/NestedSettings.svelte
@@ -0,0 +1,177 @@
+
+
+
+
+{#if key && isNodeInput(type?.[key])}
+
+ {#if type[key].type === "button"}
+
+ {:else}
+
+
+ {/if}
+
+{:else if depth === 0}
+ {#each Object.keys(type ?? {}).filter((key) => key !== "title") as childKey}
+
+ {/each}
+
+{:else if key && type?.[key]}
+ {#if depth > 0}
+
+ {/if}
+
+ {type[key]?.title || key}
+
+ {#each Object.keys(type[key]).filter((key) => key !== "title") as childKey}
+
+ {/each}
+
+
+{/if}
+
+
diff --git a/app/src/lib/settings/app-settings.svelte.ts b/app/src/lib/settings/app-settings.svelte.ts
index 85e9e54..2244136 100644
--- a/app/src/lib/settings/app-settings.svelte.ts
+++ b/app/src/lib/settings/app-settings.svelte.ts
@@ -105,16 +105,26 @@ export const AppSettingTypes = {
}
},
}
-} as const
+} as const;
type IsInputDefinition = T extends NodeInput ? T : never;
type HasTitle = { title: string };
+
+type Widen = T extends boolean
+ ? boolean
+ : T extends number
+ ? number
+ : T extends string
+ ? string
+ : T;
+
+
type ExtractSettingsValues = {
- [K in keyof T]: T[K] extends HasTitle
+ -readonly [K in keyof T]: T[K] extends HasTitle
? ExtractSettingsValues>
: T[K] extends IsInputDefinition
- ? T[K] extends { value: any }
- ? T[K]['value']
+ ? T[K] extends { value: infer V }
+ ? Widen
: never
: T[K] extends Record
? ExtractSettingsValues
diff --git a/app/src/lib/settings/index.ts b/app/src/lib/settings/index.ts
new file mode 100644
index 0000000..7f1959b
--- /dev/null
+++ b/app/src/lib/settings/index.ts
@@ -0,0 +1,13 @@
+import type { NodeInput } from "@nodes/types";
+
+type Button = { type: "button"; label?: string };
+
+type InputType = NodeInput | Button;
+
+export interface SettingsType {
+ [key: string]: (SettingsType & { title?: string }) | InputType;
+}
+
+export type SettingsStore = {
+ [key: string]: SettingsStore | string | number | boolean
+};
diff --git a/app/src/lib/settings/panels/GraphSettings.svelte b/app/src/lib/settings/panels/GraphSettings.svelte
deleted file mode 100644
index 1bc2ce5..0000000
--- a/app/src/lib/settings/panels/GraphSettings.svelte
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-{#key settings}
-
-{/key}
diff --git a/app/src/lib/settings/panels/NestedSettings.svelte b/app/src/lib/settings/panels/NestedSettings.svelte
deleted file mode 100644
index 74acbbe..0000000
--- a/app/src/lib/settings/panels/NestedSettings.svelte
+++ /dev/null
@@ -1,157 +0,0 @@
-
-
-
-
-{#if key && isNodeInput(type?.[key]) }
-
- {#if type[key].type === "button"}
-
- {:else}
-
-
- {/if}
-
-{:else}
- {#if depth === 0}
- {#each Object.keys(type).filter((key) => key !== "title") as childKey}
-
- {/each}
-
- {:else if key && type?.[key]}
- {#if depth > 0}
-
- {/if}
-
- {type[key]?.title||key}
-
- {#each Object.keys(type[key]).filter((key) => key !== "title") as childKey}
-
- {/each}
-
-
-
-
- {/if}
-
-{/if}
-
-
diff --git a/app/src/lib/settings/Panel.svelte b/app/src/lib/sidebar/Panel.svelte
similarity index 100%
rename from app/src/lib/settings/Panel.svelte
rename to app/src/lib/sidebar/Panel.svelte
diff --git a/app/src/lib/settings/Settings.svelte b/app/src/lib/sidebar/Sidebar.svelte
similarity index 100%
rename from app/src/lib/settings/Settings.svelte
rename to app/src/lib/sidebar/Sidebar.svelte
diff --git a/app/src/lib/settings/panels/ActiveNodeSelected.svelte b/app/src/lib/sidebar/panels/ActiveNodeSelected.svelte
similarity index 80%
rename from app/src/lib/settings/panels/ActiveNodeSelected.svelte
rename to app/src/lib/sidebar/panels/ActiveNodeSelected.svelte
index 8143bfc..dff3cd6 100644
--- a/app/src/lib/settings/panels/ActiveNodeSelected.svelte
+++ b/app/src/lib/sidebar/panels/ActiveNodeSelected.svelte
@@ -1,6 +1,6 @@
-{#if node}
- {#key node.id}
- {#if nodeDefinition && store && Object.keys(nodeDefinition).length > 0}
-
- {:else}
- Active Node has no Settings
- {/if}
- {/key}
-{:else}
- No active node
-{/if}
+
diff --git a/app/src/lib/settings/panels/ActiveNodeSettings.svelte b/app/src/lib/sidebar/panels/ActiveNodeSettings.svelte
similarity index 100%
rename from app/src/lib/settings/panels/ActiveNodeSettings.svelte
rename to app/src/lib/sidebar/panels/ActiveNodeSettings.svelte
diff --git a/app/src/lib/settings/panels/BenchmarkPanel.svelte b/app/src/lib/sidebar/panels/BenchmarkPanel.svelte
similarity index 100%
rename from app/src/lib/settings/panels/BenchmarkPanel.svelte
rename to app/src/lib/sidebar/panels/BenchmarkPanel.svelte
diff --git a/app/src/lib/settings/panels/ExportSettings.svelte b/app/src/lib/sidebar/panels/ExportSettings.svelte
similarity index 96%
rename from app/src/lib/settings/panels/ExportSettings.svelte
rename to app/src/lib/sidebar/panels/ExportSettings.svelte
index 00597cc..13ffaad 100644
--- a/app/src/lib/settings/panels/ExportSettings.svelte
+++ b/app/src/lib/sidebar/panels/ExportSettings.svelte
@@ -3,7 +3,6 @@
import type { OBJExporter } from "three/addons/exporters/OBJExporter.js";
import type { GLTFExporter } from "three/addons/exporters/GLTFExporter.js";
import FileSaver from "file-saver";
- import { appSettings } from "../app-settings.svelte";
// Download
const download = (
@@ -52,8 +51,6 @@
// download .obj file
download(result, "plant", "text/plain", "obj");
}
-
-
diff --git a/app/src/lib/settings/panels/Keymap.svelte b/app/src/lib/sidebar/panels/Keymap.svelte
similarity index 100%
rename from app/src/lib/settings/panels/Keymap.svelte
rename to app/src/lib/sidebar/panels/Keymap.svelte
diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte
index 00d3885..74e157e 100644
--- a/app/src/routes/+page.svelte
+++ b/app/src/routes/+page.svelte
@@ -4,21 +4,20 @@
import * as templates from "$lib/graph-templates";
import type { Graph, Node } from "@nodes/types";
import Viewer from "$lib/result-viewer/Viewer.svelte";
- import Settings from "$lib/settings/Settings.svelte";
+ import Sidebar from "$lib/sidebar/Sidebar.svelte";
import {
appSettings,
AppSettingTypes,
} from "$lib/settings/app-settings.svelte";
- import Keymap from "$lib/settings/panels/Keymap.svelte";
+ import Keymap from "$lib/sidebar/panels/Keymap.svelte";
import { createKeyMap } from "$lib/helpers/createKeyMap";
import NodeStore from "$lib/node-store/NodeStore.svelte";
- import ActiveNodeSettings from "$lib/settings/panels/ActiveNodeSettings.svelte";
+ import ActiveNodeSettings from "$lib/sidebar/panels/ActiveNodeSettings.svelte";
import PerformanceViewer from "$lib/performance/PerformanceViewer.svelte";
- import Panel from "$lib/settings/Panel.svelte";
- import GraphSettings from "$lib/settings/panels/GraphSettings.svelte";
- import NestedSettings from "$lib/settings/panels/NestedSettings.svelte";
+ import Panel from "$lib/sidebar/Panel.svelte";
+ import NestedSettings from "$lib/settings/NestedSettings.svelte";
import type { Group } from "three";
- import ExportSettings from "$lib/settings/panels/ExportSettings.svelte";
+ import ExportSettings from "$lib/sidebar/panels/ExportSettings.svelte";
import {
MemoryRuntimeCache,
WorkerRuntimeExecutor,
@@ -26,7 +25,7 @@
} from "$lib/runtime";
import { IndexDBCache, RemoteNodeRegistry } from "@nodes/registry";
import { createPerformanceStore } from "@nodes/utils";
- import BenchmarkPanel from "$lib/settings/panels/BenchmarkPanel.svelte";
+ import BenchmarkPanel from "$lib/sidebar/panels/BenchmarkPanel.svelte";
import { debounceAsyncFunction } from "$lib/helpers";
import { onMount } from "svelte";
@@ -71,7 +70,9 @@
},
]);
let graphSettings = $state
>({});
- let graphSettingTypes = $state({});
+ let graphSettingTypes = $state({
+ randomSeed: { type: "boolean", value: false },
+ });
const handleUpdate = debounceAsyncFunction(
async (g: Graph, s: Record = graphSettings) => {
@@ -162,7 +163,7 @@
onresult={(result) => handleUpdate(result)}
onsave={(graph) => handleSave(graph)}
/>
-
+
- {#if Object.keys(graphSettingTypes).length > 0}
-
- {/if}
+
-
+
{/key}