From 98cf2e83697d460d82eb90cba5f62ddcaa7e21b3 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Tue, 23 Apr 2024 03:41:28 +0200 Subject: [PATCH] feat: improve get_args functions --- app/src/lib/graph-interface/graph-manager.ts | 2 +- app/src/lib/result-viewer/Scene.svelte | 20 ++- app/src/lib/result-viewer/Viewer.svelte | 33 ++++- app/src/lib/runtime-executor.ts | 16 ++- app/src/lib/settings/Keymap.svelte | 9 +- app/src/lib/settings/NestedSettings.svelte | 29 ++++- app/src/lib/settings/Settings.svelte | 2 + app/src/lib/settings/app-settings.ts | 32 ++--- app/src/routes/+page.svelte | 21 +-- nodes/max/plantarium/math/src/lib.rs | 14 +- nodes/max/plantarium/output/src/lib.rs | 19 ++- nodes/max/plantarium/stem/src/lib.rs | 25 +++- nodes/max/plantarium/vec3/src/lib.rs | 6 +- packages/types/src/inputs.ts | 2 +- packages/utils/src/flatTree.test.ts | 12 ++ packages/utils/src/flatTree.ts | 13 +- packages/utils/src/geometry/extrude_path.rs | 2 - packages/utils/src/geometry/geometry.rs | 13 +- packages/utils/src/main.rs | 18 +++ packages/utils/src/tree.rs | 129 ++++++++++--------- 20 files changed, 270 insertions(+), 147 deletions(-) create mode 100644 packages/utils/src/main.rs diff --git a/app/src/lib/graph-interface/graph-manager.ts b/app/src/lib/graph-interface/graph-manager.ts index 8ec6f40..92befcf 100644 --- a/app/src/lib/graph-interface/graph-manager.ts +++ b/app/src/lib/graph-interface/graph-manager.ts @@ -241,7 +241,7 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any, " let settingId = nodeType.inputs[key].setting; if (settingId) { settingTypes[settingId] = nodeType.inputs[key]; - if (settingValues[settingId] === undefined && "value" in type.inputs[key]) { + if (settingValues[settingId] === undefined && "value" in nodeType.inputs[key]) { settingValues[settingId] = nodeType.inputs[key].value; } } diff --git a/app/src/lib/result-viewer/Scene.svelte b/app/src/lib/result-viewer/Scene.svelte index d210b6e..59bd45f 100644 --- a/app/src/lib/result-viewer/Scene.svelte +++ b/app/src/lib/result-viewer/Scene.svelte @@ -1,11 +1,13 @@ - + diff --git a/app/src/lib/runtime-executor.ts b/app/src/lib/runtime-executor.ts index 6470a1a..c6dcee4 100644 --- a/app/src/lib/runtime-executor.ts +++ b/app/src/lib/runtime-executor.ts @@ -150,7 +150,12 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor { } // if the input is not connected to another node, we use the value from the node itself - inputs[key] = node.props?.[key] ?? input?.value; + let value = node.props?.[key] ?? input?.value; + if (Array.isArray(value)) { + inputs[key] = [0, value.length + 1, ...value, 1, 1]; + } else { + inputs[key] = value; + } } @@ -191,10 +196,6 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor { return encodeFloat(value as number); } - if (Array.isArray(value)) { - return encodeNestedArray(value); - } - return value; }); @@ -204,13 +205,14 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor { // console.log(`${a2 - a1}ms TRANSFORMED_INPUTS`); - const encoded_inputs = encodeNestedArray(transformed_inputs); + const encoded_inputs = concatEncodedArrays(transformed_inputs); const a3 = performance.now(); console.groupCollapsed(`executing ${node_type.id || node.id}`); console.log(`Inputs:`, transformed_inputs); console.log(`Encoded Inputs:`, encoded_inputs); results[node.id] = node_type.execute(encoded_inputs); - console.log("Result:", decodeNestedArray(results[node.id])); + console.log("Result:", results[node.id]); + console.log("Result (decoded):", decodeNestedArray(results[node.id])); console.groupEnd(); const duration = performance.now() - a3; if (duration > 5) { diff --git a/app/src/lib/settings/Keymap.svelte b/app/src/lib/settings/Keymap.svelte index 95b22de..af0e2e4 100644 --- a/app/src/lib/settings/Keymap.svelte +++ b/app/src/lib/settings/Keymap.svelte @@ -14,7 +14,7 @@
{#if key.ctrl} - Ctrl + + Ctrl {/if} {#if key.shift} Shift @@ -22,7 +22,7 @@ {#if key.alt} Alt {/if} - {key.key} + {key.key}

{key.description}

@@ -69,4 +69,9 @@ display: flex; align-items: center; } + + span::after { + content: " +"; + opacity: 0.5; + } diff --git a/app/src/lib/settings/NestedSettings.svelte b/app/src/lib/settings/NestedSettings.svelte index 3026784..486b091 100644 --- a/app/src/lib/settings/NestedSettings.svelte +++ b/app/src/lib/settings/NestedSettings.svelte @@ -1,4 +1,5 @@