diff --git a/app/src/lib/runtime/runtime-executor.ts b/app/src/lib/runtime/runtime-executor.ts index adfcd79..b539613 100644 --- a/app/src/lib/runtime/runtime-executor.ts +++ b/app/src/lib/runtime/runtime-executor.ts @@ -58,7 +58,7 @@ function getValue(input: NodeInput, value?: unknown) { export class MemoryRuntimeExecutor implements RuntimeExecutor { private definitionMap: Map = new Map(); - private randomSeed = Math.floor(Math.random() * 100000000); + private seed = Math.floor(Math.random() * 100000000); perf?: PerformanceStore; @@ -181,6 +181,10 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor { // here we store the intermediate results of the nodes const results: Record = {}; + if (settings["randomSeed"]) { + this.seed = Math.floor(Math.random() * 100000000); + } + for (const node of sortedNodes) { const node_type = this.definitionMap.get(node.type)!; @@ -195,10 +199,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor { const inputs = Object.entries(node_type.inputs || {}).map( ([key, input]) => { if (input.type === "seed") { - if (settings["randomSeed"] === true) { - this.randomSeed = Math.floor(Math.random() * 100000000); - } - return this.randomSeed; + return this.seed; } // If the input is linked to a setting, we use that value diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte index 9665db6..4772c6d 100644 --- a/app/src/routes/+page.svelte +++ b/app/src/routes/+page.svelte @@ -69,7 +69,7 @@ { key: "r", description: "Regenerate the plant model", - callback: randomGenerate, + callback: () => randomGenerate(), }, ]); let graphSettings = $state>({});