feat: add slider element
This commit is contained in:
parent
c3691e7169
commit
815152d23c
@ -111,8 +111,6 @@ 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, string | boolean | number> = {};
|
const results: Record<string, string | boolean | number> = {};
|
||||||
|
|
||||||
console.log(this.cache);
|
|
||||||
|
|
||||||
for (const node of sortedNodes) {
|
for (const node of sortedNodes) {
|
||||||
|
|
||||||
const node_type = this.typeMap.get(node.type)!;
|
const node_type = this.typeMap.get(node.type)!;
|
||||||
@ -142,8 +140,8 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
console.log(" ");
|
// console.log(" ");
|
||||||
console.log("--> EXECUTING NODE " + node_type.id, node.id);
|
// console.log("--> EXECUTING NODE " + node_type.id, node.id);
|
||||||
|
|
||||||
|
|
||||||
// execute the node and store the result
|
// execute the node and store the result
|
||||||
@ -156,7 +154,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
}))}`;
|
}))}`;
|
||||||
|
|
||||||
const a1 = performance.now();
|
const a1 = performance.now();
|
||||||
console.log(`${a1 - a0}ms hashed inputs: ${node.id} -> ${cacheKey}`);
|
// console.log(`${a1 - a0}ms hashed inputs: ${node.id} -> ${cacheKey}`);
|
||||||
|
|
||||||
if (false && this.cache[cacheKey] && this.cache[cacheKey].eol > Date.now()) {
|
if (false && this.cache[cacheKey] && this.cache[cacheKey].eol > Date.now()) {
|
||||||
results[node.id] = this.cache[cacheKey].value;
|
results[node.id] = this.cache[cacheKey].value;
|
||||||
@ -183,7 +181,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
|
|
||||||
const a2 = performance.now();
|
const a2 = performance.now();
|
||||||
|
|
||||||
console.log(`${a2 - a1}ms TRANSFORMED_INPUTS`);
|
// console.log(`${a2 - a1}ms TRANSFORMED_INPUTS`);
|
||||||
|
|
||||||
const _inputs = concat_encoded(transformed_inputs);
|
const _inputs = concat_encoded(transformed_inputs);
|
||||||
const a3 = performance.now();
|
const a3 = performance.now();
|
||||||
@ -191,11 +189,11 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
const duration = performance.now() - a3;
|
const duration = performance.now() - a3;
|
||||||
if (duration > 5) {
|
if (duration > 5) {
|
||||||
this.cache[cacheKey] = { eol: Date.now() + 10_000, value: results[node.id] };
|
this.cache[cacheKey] = { eol: Date.now() + 10_000, value: results[node.id] };
|
||||||
console.log(`Caching for 10 seconds`);
|
// console.log(`Caching for 10 seconds`);
|
||||||
}
|
}
|
||||||
console.log(`${duration}ms Executed`);
|
// console.log(`${duration}ms Executed`);
|
||||||
const a4 = performance.now();
|
const a4 = performance.now();
|
||||||
console.log(`${a4 - a0}ms e2e duration`);
|
// console.log(`${a4 - a0}ms e2e duration`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Error executing node ${node_type.id || node.id}`, e);
|
console.error(`Error executing node ${node_type.id || node.id}`, e);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ pub fn execute(input: Vec<i32>) -> Vec<i32> {
|
|||||||
|
|
||||||
if arg[2] == 0 {
|
if arg[2] == 0 {
|
||||||
let _arg = &arg[3..];
|
let _arg = &arg[3..];
|
||||||
let geometry = extrude_path(_arg, 8);
|
let geometry = extrude_path(_arg, 16);
|
||||||
output.push(geometry);
|
output.push(geometry);
|
||||||
}else if arg[2] == 1 {
|
}else if arg[2] == 1 {
|
||||||
output.push(arg.to_vec());
|
output.push(arg.to_vec());
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
},
|
},
|
||||||
"thickness": {
|
"thickness": {
|
||||||
"type": "float",
|
"type": "float",
|
||||||
|
"element": "slider",
|
||||||
"value": 2
|
"value": 2
|
||||||
},
|
},
|
||||||
"resolution": {
|
"resolution": {
|
||||||
|
@ -12,7 +12,7 @@ pub fn execute(input: &[i32]) -> Vec<i32> {
|
|||||||
|
|
||||||
let length = decode_float(evaluate_args(args[0])[0]);
|
let length = decode_float(evaluate_args(args[0])[0]);
|
||||||
let thickness = decode_float(evaluate_args(args[1])[0]);
|
let thickness = decode_float(evaluate_args(args[1])[0]);
|
||||||
let resolution = 64; //evaluate_args(args[2]);
|
let resolution = 512; //evaluate_args(args[2]);
|
||||||
|
|
||||||
let mut path: Vec<i32> = vec![0; resolution * 4 + 1];
|
let mut path: Vec<i32> = vec![0; resolution * 4 + 1];
|
||||||
path.resize(resolution * 4 + 1, 0);
|
path.resize(resolution * 4 + 1, 0);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
type NodeInputFloat = {
|
type NodeInputFloat = {
|
||||||
type: "float";
|
type: "float";
|
||||||
|
element?: "slider";
|
||||||
value?: number;
|
value?: number;
|
||||||
min?: number;
|
min?: number;
|
||||||
max?: number;
|
max?: number;
|
||||||
@ -8,6 +9,7 @@ type NodeInputFloat = {
|
|||||||
|
|
||||||
type NodeInputInteger = {
|
type NodeInputInteger = {
|
||||||
type: "integer";
|
type: "integer";
|
||||||
|
element?: "slider";
|
||||||
value?: number;
|
value?: number;
|
||||||
min?: number;
|
min?: number;
|
||||||
max?: number;
|
max?: number;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
import Select from "$lib/elements/Select.svelte";
|
import Select from "$lib/elements/Select.svelte";
|
||||||
|
|
||||||
import type { NodeInput } from "@nodes/types";
|
import type { NodeInput } from "@nodes/types";
|
||||||
|
import Slider from "./elements/Slider.svelte";
|
||||||
|
|
||||||
export let input: NodeInput;
|
export let input: NodeInput;
|
||||||
export let value: any;
|
export let value: any;
|
||||||
@ -12,7 +13,11 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if input.type === "float"}
|
{#if input.type === "float"}
|
||||||
|
{#if input?.element === "slider"}
|
||||||
|
<Slider {id} bind:value />
|
||||||
|
{:else}
|
||||||
<Float {id} bind:value />
|
<Float {id} bind:value />
|
||||||
|
{/if}
|
||||||
{:else if input.type === "integer"}
|
{:else if input.type === "integer"}
|
||||||
<Integer {id} bind:value />
|
<Integer {id} bind:value />
|
||||||
{:else if input.type === "boolean"}
|
{:else if input.type === "boolean"}
|
||||||
|
9
packages/ui/src/lib/elements/Slider.svelte
Normal file
9
packages/ui/src/lib/elements/Slider.svelte
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let value: number = 0;
|
||||||
|
export let min = 0;
|
||||||
|
export let max = 10;
|
||||||
|
export let step = 0.1;
|
||||||
|
export let id: string;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input type="range" {id} bind:value {min} {max} {step} />
|
Loading…
Reference in New Issue
Block a user