feat: some shit
This commit is contained in:
@@ -217,11 +217,22 @@ export type Pointer = {
|
|||||||
(a, b) => (b.state?.depth || 0) - (a.state?.depth || 0)
|
(a, b) => (b.state?.depth || 0) - (a.state?.depth || 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log({ settings });
|
||||||
|
|
||||||
|
this.printMemory();
|
||||||
|
const seedPtr = this.writeToMemory(this.seed, 'seed');
|
||||||
|
|
||||||
|
const settingPtrs = new Map<string, Pointer>(
|
||||||
|
Object.entries(settings).map((
|
||||||
|
[key, value]
|
||||||
|
) => [key as string, this.writeToMemory(value as number, `setting.${key}`)])
|
||||||
|
);
|
||||||
|
|
||||||
for (const node of sortedNodes) {
|
for (const node of sortedNodes) {
|
||||||
const node_type = this.nodes.get(node.type)!;
|
const node_type = this.nodes.get(node.type)!;
|
||||||
|
|
||||||
console.log('---------------');
|
console.log('---------------');
|
||||||
console.log('STARTING NODE EXECUTION', node_type.definition.id);
|
console.log('STARTING NODE EXECUTION', node_type.definition.id + '/' + node.id);
|
||||||
this.printMemory();
|
this.printMemory();
|
||||||
|
|
||||||
// console.log(node_type.definition.inputs);
|
// console.log(node_type.definition.inputs);
|
||||||
@@ -229,23 +240,24 @@ export type Pointer = {
|
|||||||
([key, input]) => {
|
([key, input]) => {
|
||||||
// We should probably initially write this to memory
|
// We should probably initially write this to memory
|
||||||
if (input.type === 'seed') {
|
if (input.type === 'seed') {
|
||||||
return this.writeToMemory(this.seed);
|
return seedPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = `${node.id}.${key}`;
|
const title = `${node.id}.${key}`;
|
||||||
|
|
||||||
// We should probably initially write this to memory
|
// We should probably initially write this to memory
|
||||||
// If the input is linked to a setting, we use that value
|
// If the input is linked to a setting, we use that value
|
||||||
// if (input.setting) {
|
// TODO: handle nodes which reference undefined settings
|
||||||
// return getValue(input, settings[input.setting]);
|
if (input.setting) {
|
||||||
// }
|
return settingPtrs.get(input.setting)!;
|
||||||
|
}
|
||||||
|
|
||||||
// check if the input is connected to another node
|
// check if the input is connected to another node
|
||||||
const inputNode = node.state.inputNodes[key];
|
const inputNode = node.state.inputNodes[key];
|
||||||
if (inputNode) {
|
if (inputNode) {
|
||||||
if (this.results[inputNode.id] === undefined) {
|
if (this.results[inputNode.id] === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Node ${node.type} is missing input from node ${inputNode.type}`
|
`Node ${node.type}/${node.id} is missing input from node ${inputNode.type}/${inputNode.id}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return this.results[inputNode.id];
|
return this.results[inputNode.id];
|
||||||
|
|||||||
@@ -71,7 +71,11 @@
|
|||||||
<Grid.Cell>
|
<Grid.Cell>
|
||||||
{#if visibleRows?.length}
|
{#if visibleRows?.length}
|
||||||
<table
|
<table
|
||||||
class="min-w-full select-none overflow-hidden text-left text-sm flex-1"
|
class="min-w-full select-none overflow-auto text-left text-sm flex-1"
|
||||||
|
onscroll={(e) => {
|
||||||
|
const scrollTop = e.currentTarget.scrollTop;
|
||||||
|
start.value = Math.floor(scrollTop / rowHeight);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<thead class="">
|
<thead class="">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -84,9 +88,14 @@
|
|||||||
<th class="px-4 py-2 border-b border-[var(--outline)]">Float</th>
|
<th class="px-4 py-2 border-b border-[var(--outline)]">Float</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody
|
||||||
|
onscroll={(e) => {
|
||||||
|
const scrollTop = e.currentTarget.scrollTop;
|
||||||
|
start.value = Math.floor(scrollTop / rowHeight);
|
||||||
|
}}
|
||||||
|
>
|
||||||
{#each visibleRows as r, i}
|
{#each visibleRows as r, i}
|
||||||
{@const index = i + start}
|
{@const index = i + start.value}
|
||||||
{@const ptr = ptrs[i]}
|
{@const ptr = ptrs[i]}
|
||||||
<tr class="h-[40px] odd:bg-[var(--layer-1)]">
|
<tr class="h-[40px] odd:bg-[var(--layer-1)]">
|
||||||
<td class="px-4 border-b border-[var(--outline)] w-8">{index}</td>
|
<td class="px-4 border-b border-[var(--outline)] w-8">{index}</td>
|
||||||
@@ -119,7 +128,7 @@
|
|||||||
</table>
|
</table>
|
||||||
<input
|
<input
|
||||||
class="absolute bottom-4 left-4 bg-white"
|
class="absolute bottom-4 left-4 bg-white"
|
||||||
bind:value={start}
|
bind:value={start.value}
|
||||||
min="0"
|
min="0"
|
||||||
type="number"
|
type="number"
|
||||||
step="1"
|
step="1"
|
||||||
@@ -133,6 +142,13 @@
|
|||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
|
|
||||||
<Sidebar>
|
<Sidebar>
|
||||||
|
<Panel id="general" title="General" icon="i-[tabler--settings]">
|
||||||
|
<NestedSettings
|
||||||
|
id="general"
|
||||||
|
bind:value={appSettings.value}
|
||||||
|
type={AppSettingTypes}
|
||||||
|
/>
|
||||||
|
</Panel>
|
||||||
<Panel
|
<Panel
|
||||||
id="node-store"
|
id="node-store"
|
||||||
classes="text-green-400"
|
classes="text-green-400"
|
||||||
|
|||||||
@@ -7,47 +7,68 @@
|
|||||||
{
|
{
|
||||||
"id": 9,
|
"id": 9,
|
||||||
"position": [
|
"position": [
|
||||||
220,
|
225,
|
||||||
80
|
65
|
||||||
],
|
],
|
||||||
"type": "max/plantarium/output",
|
"type": "max/plantarium/output",
|
||||||
"props": {}
|
"props": {
|
||||||
|
"out": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 10,
|
"id": 10,
|
||||||
"position": [
|
"position": [
|
||||||
195,
|
200,
|
||||||
80
|
60
|
||||||
],
|
],
|
||||||
"type": "max/plantarium/math",
|
"type": "max/plantarium/math",
|
||||||
"props": {
|
"props": {
|
||||||
"op_type": 0,
|
"op_type": 3,
|
||||||
"a": 2,
|
"a": 2,
|
||||||
"b": 2
|
"b": 0.38
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 11,
|
"id": 11,
|
||||||
"position": [
|
"position": [
|
||||||
170,
|
175,
|
||||||
80
|
60
|
||||||
],
|
],
|
||||||
"type": "max/plantarium/float",
|
"type": "max/plantarium/float",
|
||||||
"props": {
|
"props": {
|
||||||
"value": 0.1
|
"value": 0.66
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 12,
|
"id": 12,
|
||||||
"position": [
|
"position": [
|
||||||
170,
|
175,
|
||||||
100
|
80
|
||||||
],
|
],
|
||||||
"type": "max/plantarium/float",
|
"type": "max/plantarium/float",
|
||||||
"props": {
|
"props": {
|
||||||
"value": 0.1
|
"value": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"edges": []
|
"edges": [
|
||||||
|
[
|
||||||
|
11,
|
||||||
|
0,
|
||||||
|
10,
|
||||||
|
"a"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
12,
|
||||||
|
0,
|
||||||
|
10,
|
||||||
|
"b"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
10,
|
||||||
|
0,
|
||||||
|
9,
|
||||||
|
"out"
|
||||||
|
]
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::nodarium_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
use nodarium_macros::nodarium_execute;
|
||||||
use nodarium_utils::{ read_f32, encode_float };
|
use nodarium_utils::read_i32;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
nodarium_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[nodarium_execute]
|
||||||
pub fn execute(a: (i32, i32)) -> Vec<i32> {
|
pub fn execute(a: (i32, i32)) -> Vec<i32> {
|
||||||
let a_val = read_f32(a.0);
|
vec![read_i32(a.0)]
|
||||||
vec![encode_float(a_val)]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::nodarium_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
use nodarium_macros::nodarium_execute;
|
||||||
|
use nodarium_utils::encode_float;
|
||||||
|
use nodarium_utils::evaluate_float;
|
||||||
|
use nodarium_utils::evaluate_vec3;
|
||||||
use nodarium_utils::log;
|
use nodarium_utils::log;
|
||||||
use nodarium_utils::read_i32_slice;
|
use nodarium_utils::read_i32_slice;
|
||||||
|
|
||||||
@@ -7,8 +10,18 @@ nodarium_definition_file!("src/input.json");
|
|||||||
|
|
||||||
#[nodarium_execute]
|
#[nodarium_execute]
|
||||||
pub fn execute(input: (i32, i32), _res: (i32, i32)) -> Vec<i32> {
|
pub fn execute(input: (i32, i32), _res: (i32, i32)) -> Vec<i32> {
|
||||||
log!("HERE");
|
let inp = read_i32_slice(input);
|
||||||
let mut vecs = read_i32_slice(input);
|
let length = inp.len();
|
||||||
vecs.push(42);
|
if length == 1 {
|
||||||
vecs
|
let f = evaluate_float(inp.as_slice());
|
||||||
|
log!("out.float f={:?}", f);
|
||||||
|
return vec![encode_float(f)];
|
||||||
|
}
|
||||||
|
if length == 3 {
|
||||||
|
let f = evaluate_vec3(inp.as_slice());
|
||||||
|
log!("out.vec3 x={:?} y={:?} z={:?}", f[0], f[1], f[2]);
|
||||||
|
return vec![encode_float(f[0]), encode_float(f[1]), encode_float(f[2])];
|
||||||
|
}
|
||||||
|
|
||||||
|
return inp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::nodarium_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
use nodarium_macros::nodarium_execute;
|
||||||
use nodarium_utils::concat_arg_vecs;
|
use nodarium_utils::concat_args;
|
||||||
|
use nodarium_utils::log;
|
||||||
use nodarium_utils::read_i32_slice;
|
use nodarium_utils::read_i32_slice;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
nodarium_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[nodarium_execute]
|
||||||
pub fn execute(x: (i32, i32), y: (i32, i32), z: (i32, i32)) -> Vec<i32> {
|
pub fn execute(x: (i32, i32), y: (i32, i32), z: (i32, i32)) -> Vec<i32> {
|
||||||
concat_arg_vecs(vec![
|
log!("vec3 x: {:?}", x);
|
||||||
read_i32_slice(x),
|
concat_args(vec![
|
||||||
read_i32_slice(y),
|
read_i32_slice(x).as_slice(),
|
||||||
read_i32_slice(z),
|
read_i32_slice(y).as_slice(),
|
||||||
|
read_i32_slice(z).as_slice(),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ extern "C" {
|
|||||||
pub fn __nodarium_log(ptr: *const u8, len: usize);
|
pub fn __nodarium_log(ptr: *const u8, len: usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! log {
|
macro_rules! log {
|
||||||
($($t:tt)*) => {{
|
($($t:tt)*) => {{
|
||||||
@@ -25,13 +25,13 @@ macro_rules! log {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
// #[macro_export]
|
#[macro_export]
|
||||||
// macro_rules! log {
|
macro_rules! log {
|
||||||
// ($($arg:tt)*) => {{
|
($($arg:tt)*) => {{
|
||||||
// // This will expand to nothing in release builds
|
// This will expand to nothing in release builds
|
||||||
// }};
|
}};
|
||||||
// }
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
|
|||||||
Reference in New Issue
Block a user