fix: better handle randomGeneration
This commit is contained in:
@@ -58,7 +58,7 @@ function getValue(input: NodeInput, value?: unknown) {
|
|||||||
export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
||||||
private definitionMap: Map<string, NodeDefinition> = new Map();
|
private definitionMap: Map<string, NodeDefinition> = new Map();
|
||||||
|
|
||||||
private randomSeed = Math.floor(Math.random() * 100000000);
|
private seed = Math.floor(Math.random() * 100000000);
|
||||||
|
|
||||||
perf?: PerformanceStore;
|
perf?: PerformanceStore;
|
||||||
|
|
||||||
@@ -181,6 +181,10 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
// here we store the intermediate results of the nodes
|
// here we store the intermediate results of the nodes
|
||||||
const results: Record<string, Int32Array> = {};
|
const results: Record<string, Int32Array> = {};
|
||||||
|
|
||||||
|
if (settings["randomSeed"]) {
|
||||||
|
this.seed = Math.floor(Math.random() * 100000000);
|
||||||
|
}
|
||||||
|
|
||||||
for (const node of sortedNodes) {
|
for (const node of sortedNodes) {
|
||||||
const node_type = this.definitionMap.get(node.type)!;
|
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(
|
const inputs = Object.entries(node_type.inputs || {}).map(
|
||||||
([key, input]) => {
|
([key, input]) => {
|
||||||
if (input.type === "seed") {
|
if (input.type === "seed") {
|
||||||
if (settings["randomSeed"] === true) {
|
return this.seed;
|
||||||
this.randomSeed = Math.floor(Math.random() * 100000000);
|
|
||||||
}
|
|
||||||
return this.randomSeed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the input is linked to a setting, we use that value
|
// If the input is linked to a setting, we use that value
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
{
|
{
|
||||||
key: "r",
|
key: "r",
|
||||||
description: "Regenerate the plant model",
|
description: "Regenerate the plant model",
|
||||||
callback: randomGenerate,
|
callback: () => randomGenerate(),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
let graphSettings = $state<Record<string, any>>({});
|
let graphSettings = $state<Record<string, any>>({});
|
||||||
|
|||||||
Reference in New Issue
Block a user