feat: some shit
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import { getGraphState } from "../graph-state.svelte";
|
import { getGraphState } from "../graph-state.svelte";
|
||||||
import { createNodePath } from "../helpers/index.js";
|
import { createNodePath } from "../helpers/index.js";
|
||||||
import type { NodeInstance } from "@nodarium/types";
|
import type { NodeInstance } from "@nodarium/types";
|
||||||
|
import { appSettings } from "$lib/settings/app-settings.svelte";
|
||||||
|
|
||||||
const graphState = getGraphState();
|
const graphState = getGraphState();
|
||||||
|
|
||||||
@@ -43,7 +44,12 @@
|
|||||||
|
|
||||||
<div class="wrapper" data-node-id={node.id} data-node-type={node.type}>
|
<div class="wrapper" data-node-id={node.id} data-node-type={node.type}>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{node.type.split("/").pop()} ({node.id})
|
{#if appSettings.value.nodeInterface.showNodeIds}
|
||||||
|
<span class="bg-white text-black! mr-2 px-1 rounded-sm opacity-30"
|
||||||
|
>{node.id}</span
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
{node.type.split("/").pop()}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="click-target"
|
class="click-target"
|
||||||
|
|||||||
@@ -87,8 +87,9 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
|
|
||||||
results: Record<number, Pointer> = {};
|
results: Record<number, Pointer> = {};
|
||||||
inputPtrs: Record<number, Pointer[]> = {};
|
inputPtrs: Record<number, Pointer[]> = {};
|
||||||
|
allPtrs: Pointer[] = [];
|
||||||
|
|
||||||
seed = 123123;
|
seed = 42424242;
|
||||||
|
|
||||||
perf?: PerformanceStore;
|
perf?: PerformanceStore;
|
||||||
|
|
||||||
@@ -202,11 +203,13 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
|
|
||||||
this.offset += length;
|
this.offset += length;
|
||||||
|
|
||||||
return {
|
const ptr = {
|
||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
_title: title
|
_title: title
|
||||||
};
|
};
|
||||||
|
this.allPtrs.push(ptr);
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private printMemory() {
|
private printMemory() {
|
||||||
@@ -214,10 +217,13 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
console.log('MEMORY', this.memoryView.slice(0, 10));
|
console.log('MEMORY', this.memoryView.slice(0, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(graph: Graph, _settings: Record<string, unknown>) {
|
async execute(graph: Graph, settings: Record<string, unknown>) {
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
this.inputPtrs = {};
|
this.inputPtrs = {};
|
||||||
|
this.seed = this.seed += 2;
|
||||||
this.results = {};
|
this.results = {};
|
||||||
|
this.allPtrs = [];
|
||||||
|
|
||||||
if (this.isRunning) return undefined as unknown as Int32Array;
|
if (this.isRunning) return undefined as unknown as Int32Array;
|
||||||
this.isRunning = true;
|
this.isRunning = true;
|
||||||
|
|
||||||
@@ -240,11 +246,22 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
(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);
|
||||||
@@ -252,23 +269,24 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
([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];
|
||||||
@@ -317,6 +335,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
end: args[1],
|
end: args[1],
|
||||||
_title: `${node.id} ->`
|
_title: `${node.id} ->`
|
||||||
};
|
};
|
||||||
|
this.allPtrs.push(this.results[node.id]);
|
||||||
} else {
|
} else {
|
||||||
this.results[node.id] = {
|
this.results[node.id] = {
|
||||||
start: this.offset,
|
start: this.offset,
|
||||||
@@ -324,6 +343,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
_title: `${node.id} ->`
|
_title: `${node.id} ->`
|
||||||
};
|
};
|
||||||
this.offset += bytesWritten / 4;
|
this.offset += bytesWritten / 4;
|
||||||
|
this.allPtrs.push(this.results[node.id]);
|
||||||
}
|
}
|
||||||
console.log('FINISHED EXECUTION', {
|
console.log('FINISHED EXECUTION', {
|
||||||
bytesWritten,
|
bytesWritten,
|
||||||
|
|||||||
@@ -1,148 +1,147 @@
|
|||||||
import { localState } from "$lib/helpers/localState.svelte";
|
import { localState } from '$lib/helpers/localState.svelte';
|
||||||
|
|
||||||
const themes = [
|
const themes = [
|
||||||
"dark",
|
'dark',
|
||||||
"light",
|
'light',
|
||||||
"catppuccin",
|
'catppuccin',
|
||||||
"solarized",
|
'solarized',
|
||||||
"high-contrast",
|
'high-contrast',
|
||||||
"nord",
|
'nord',
|
||||||
"dracula",
|
'dracula'
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export const AppSettingTypes = {
|
export const AppSettingTypes = {
|
||||||
theme: {
|
theme: {
|
||||||
type: "select",
|
type: 'select',
|
||||||
options: themes,
|
options: themes,
|
||||||
label: "Theme",
|
label: 'Theme',
|
||||||
value: themes[0],
|
value: themes[0]
|
||||||
},
|
},
|
||||||
showGrid: {
|
showGrid: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Show Grid",
|
label: 'Show Grid',
|
||||||
value: true,
|
value: true
|
||||||
},
|
},
|
||||||
centerCamera: {
|
centerCamera: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Center Camera",
|
label: 'Center Camera',
|
||||||
value: true,
|
value: true
|
||||||
},
|
},
|
||||||
nodeInterface: {
|
nodeInterface: {
|
||||||
title: "Node Interface",
|
title: 'Node Interface',
|
||||||
showNodeGrid: {
|
showNodeGrid: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Show Grid",
|
label: 'Show Grid',
|
||||||
value: true,
|
value: true
|
||||||
},
|
},
|
||||||
snapToGrid: {
|
snapToGrid: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Snap to Grid",
|
label: 'Snap to Grid',
|
||||||
value: true,
|
value: true
|
||||||
},
|
},
|
||||||
showHelp: {
|
showHelp: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Show Help",
|
label: 'Show Help',
|
||||||
value: false,
|
value: false
|
||||||
},
|
},
|
||||||
|
showNodeIds: {
|
||||||
|
type: 'boolean',
|
||||||
|
label: 'Show Node Ids',
|
||||||
|
value: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
debug: {
|
debug: {
|
||||||
title: "Debug",
|
title: 'Debug',
|
||||||
wireframe: {
|
wireframe: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Wireframe",
|
label: 'Wireframe',
|
||||||
value: false,
|
value: false
|
||||||
},
|
},
|
||||||
useWorker: {
|
useWorker: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Execute in WebWorker",
|
label: 'Execute in WebWorker',
|
||||||
value: true,
|
value: true
|
||||||
},
|
},
|
||||||
showIndices: {
|
showIndices: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Show Indices",
|
label: 'Show Indices',
|
||||||
value: false,
|
value: false
|
||||||
},
|
},
|
||||||
showPerformancePanel: {
|
showPerformancePanel: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Show Performance Panel",
|
label: 'Show Performance Panel',
|
||||||
value: false,
|
value: false
|
||||||
},
|
},
|
||||||
showBenchmarkPanel: {
|
showBenchmarkPanel: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Show Benchmark Panel",
|
label: 'Show Benchmark Panel',
|
||||||
value: false,
|
value: false
|
||||||
},
|
},
|
||||||
showVertices: {
|
showVertices: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Show Vertices",
|
label: 'Show Vertices',
|
||||||
value: false,
|
value: false
|
||||||
},
|
},
|
||||||
showStemLines: {
|
showStemLines: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Show Stem Lines",
|
label: 'Show Stem Lines',
|
||||||
value: false,
|
value: false
|
||||||
},
|
},
|
||||||
showGraphJson: {
|
showGraphJson: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Show Graph Source",
|
label: 'Show Graph Source',
|
||||||
value: false,
|
value: false
|
||||||
},
|
},
|
||||||
cache: {
|
cache: {
|
||||||
title: "Cache",
|
title: 'Cache',
|
||||||
useRuntimeCache: {
|
useRuntimeCache: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Node Results",
|
label: 'Node Results',
|
||||||
value: true,
|
value: true
|
||||||
},
|
},
|
||||||
useRegistryCache: {
|
useRegistryCache: {
|
||||||
type: "boolean",
|
type: 'boolean',
|
||||||
label: "Node Source",
|
label: 'Node Source',
|
||||||
value: true,
|
value: true
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
stressTest: {
|
stressTest: {
|
||||||
title: "Stress Test",
|
title: 'Stress Test',
|
||||||
amount: {
|
amount: {
|
||||||
type: "integer",
|
type: 'integer',
|
||||||
min: 2,
|
min: 2,
|
||||||
max: 15,
|
max: 15,
|
||||||
value: 4,
|
value: 4
|
||||||
},
|
},
|
||||||
loadGrid: {
|
loadGrid: {
|
||||||
type: "button",
|
type: 'button',
|
||||||
label: "Load Grid",
|
label: 'Load Grid'
|
||||||
},
|
},
|
||||||
loadTree: {
|
loadTree: {
|
||||||
type: "button",
|
type: 'button',
|
||||||
label: "Load Tree",
|
label: 'Load Tree'
|
||||||
},
|
},
|
||||||
lottaFaces: {
|
lottaFaces: {
|
||||||
type: "button",
|
type: 'button',
|
||||||
label: "Load 'lots of faces'",
|
label: "Load 'lots of faces'"
|
||||||
},
|
},
|
||||||
lottaNodes: {
|
lottaNodes: {
|
||||||
type: "button",
|
type: 'button',
|
||||||
label: "Load 'lots of nodes'",
|
label: "Load 'lots of nodes'"
|
||||||
},
|
},
|
||||||
lottaNodesAndFaces: {
|
lottaNodesAndFaces: {
|
||||||
type: "button",
|
type: 'button',
|
||||||
label: "Load 'lots of nodes and faces'",
|
label: "Load 'lots of nodes and faces'"
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
type SettingsToStore<T> =
|
type SettingsToStore<T> = T extends { value: infer V } ? V extends readonly string[] ? V[number]
|
||||||
T extends { value: infer V }
|
|
||||||
? V extends readonly string[]
|
|
||||||
? V[number]
|
|
||||||
: V
|
: V
|
||||||
: T extends any[]
|
: T extends any[] ? {}
|
||||||
? {}
|
: T extends object ? {
|
||||||
: T extends object
|
[K in keyof T as T[K] extends object ? K : never]: SettingsToStore<T[K]>;
|
||||||
? {
|
|
||||||
[K in keyof T as T[K] extends object ? K : never]:
|
|
||||||
SettingsToStore<T[K]>
|
|
||||||
}
|
}
|
||||||
: never;
|
: never;
|
||||||
|
|
||||||
@@ -150,8 +149,8 @@ export function settingsToStore<T>(settings: T): SettingsToStore<T> {
|
|||||||
const result = {} as any;
|
const result = {} as any;
|
||||||
for (const key in settings) {
|
for (const key in settings) {
|
||||||
const value = settings[key];
|
const value = settings[key];
|
||||||
if (value && typeof value === "object") {
|
if (value && typeof value === 'object') {
|
||||||
if ("value" in value) {
|
if ('value' in value) {
|
||||||
result[key] = value.value;
|
result[key] = value.value;
|
||||||
} else {
|
} else {
|
||||||
result[key] = settingsToStore(value);
|
result[key] = settingsToStore(value);
|
||||||
@@ -162,8 +161,8 @@ export function settingsToStore<T>(settings: T): SettingsToStore<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export let appSettings = localState(
|
export let appSettings = localState(
|
||||||
"app-settings",
|
'app-settings',
|
||||||
settingsToStore(AppSettingTypes),
|
settingsToStore(AppSettingTypes)
|
||||||
);
|
);
|
||||||
|
|
||||||
$effect.root(() => {
|
$effect.root(() => {
|
||||||
@@ -173,7 +172,7 @@ $effect.root(() => {
|
|||||||
const newClassName = `theme-${theme}`;
|
const newClassName = `theme-${theme}`;
|
||||||
if (classes) {
|
if (classes) {
|
||||||
for (const className of classes) {
|
for (const className of classes) {
|
||||||
if (className.startsWith("theme-") && className !== newClassName) {
|
if (className.startsWith('theme-') && className !== newClassName) {
|
||||||
classes.remove(className);
|
classes.remove(className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,14 @@
|
|||||||
import { type Graph, type NodeInstance } from "@nodarium/types";
|
import { type Graph, type NodeInstance } from "@nodarium/types";
|
||||||
import Grid from "$lib/grid";
|
import Grid from "$lib/grid";
|
||||||
import { MemoryRuntimeExecutor, type Pointer } from "$lib/runtime";
|
import { MemoryRuntimeExecutor, type Pointer } from "$lib/runtime";
|
||||||
import devPlant from "./dev-graph.json";
|
|
||||||
import { decodeFloat } from "@nodarium/utils";
|
import { decodeFloat } from "@nodarium/utils";
|
||||||
import { localState } from "$lib/helpers/localState.svelte";
|
import { localState } from "$lib/helpers/localState.svelte";
|
||||||
|
import * as templates from "$lib/graph-templates";
|
||||||
|
import NestedSettings from "$lib/settings/NestedSettings.svelte";
|
||||||
|
import {
|
||||||
|
appSettings,
|
||||||
|
AppSettingTypes,
|
||||||
|
} from "$lib/settings/app-settings.svelte";
|
||||||
|
|
||||||
const nodeRegistry = new RemoteNodeRegistry("");
|
const nodeRegistry = new RemoteNodeRegistry("");
|
||||||
nodeRegistry.overwriteNode("max/plantarium/output", {
|
nodeRegistry.overwriteNode("max/plantarium/output", {
|
||||||
@@ -23,29 +28,30 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
execute(outputPos: number, args: number[]) {
|
execute(outputPos: number, args: number[]) {
|
||||||
|
console.log({ outputPos, args });
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
|
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
|
||||||
|
|
||||||
let inputPtrs: Record<number, Pointer[]>;
|
let allPtrs = $state<Pointer[]>([]);
|
||||||
let activeNode = $state<NodeInstance>();
|
let activeNode = $state<NodeInstance>();
|
||||||
let isCalculating = $state<boolean>(false);
|
let isCalculating = $state<boolean>(false);
|
||||||
let windowHeight = $state(500);
|
let windowHeight = $state(500);
|
||||||
let start = $state(0);
|
const start = localState("nodes.dev.scroll", 0);
|
||||||
|
|
||||||
const rowHeight = 40;
|
const rowHeight = 40;
|
||||||
const numRows = $derived(Math.floor(windowHeight / rowHeight));
|
const numRows = $derived(Math.floor(windowHeight / rowHeight));
|
||||||
|
|
||||||
let memory = $state<Int32Array>();
|
let memory = $state<Int32Array>();
|
||||||
const visibleRows = $derived(memory?.slice(start, start + numRows));
|
const visibleRows = $derived(
|
||||||
|
memory?.slice(start.value, start.value + numRows),
|
||||||
|
);
|
||||||
|
|
||||||
const ptrs = $derived.by(() => {
|
const sortedPtrs = $derived.by(() => {
|
||||||
if (!inputPtrs) return [];
|
|
||||||
const seen = new Set();
|
const seen = new Set();
|
||||||
const ptrs = [...Object.values(inputPtrs)]
|
const _ptrs = [...allPtrs]
|
||||||
.flat()
|
|
||||||
.sort((a, b) => (a.start > b.start ? 1 : -1))
|
.sort((a, b) => (a.start > b.start ? 1 : -1))
|
||||||
.filter((ptr) => {
|
.filter((ptr) => {
|
||||||
const id = `${ptr.start}-${ptr.end}`;
|
const id = `${ptr.start}-${ptr.end}`;
|
||||||
@@ -53,12 +59,15 @@
|
|||||||
seen.add(id);
|
seen.add(id);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (!ptrs) return [];
|
if (!_ptrs) return [];
|
||||||
|
return _ptrs;
|
||||||
|
});
|
||||||
|
|
||||||
|
const ptrs = $derived.by(() => {
|
||||||
let out = [];
|
let out = [];
|
||||||
for (let i = 0; i < numRows; i++) {
|
for (let i = 0; i < numRows; i++) {
|
||||||
let rowIndex = start + i;
|
let rowIndex = start.value + i;
|
||||||
const activePtr = ptrs.find(
|
const activePtr = sortedPtrs.find(
|
||||||
(ptr) => ptr.start < rowIndex && ptr.end >= rowIndex,
|
(ptr) => ptr.start < rowIndex && ptr.end >= rowIndex,
|
||||||
);
|
);
|
||||||
if (activePtr) {
|
if (activePtr) {
|
||||||
@@ -75,7 +84,7 @@
|
|||||||
let graph = $state(
|
let graph = $state(
|
||||||
localStorage.getItem("nodes.dev.graph")
|
localStorage.getItem("nodes.dev.graph")
|
||||||
? JSON.parse(localStorage.getItem("nodes.dev.graph")!)
|
? JSON.parse(localStorage.getItem("nodes.dev.graph")!)
|
||||||
: devPlant,
|
: templates.defaultPlant,
|
||||||
);
|
);
|
||||||
function handleSave(g: Graph) {
|
function handleSave(g: Graph) {
|
||||||
localStorage.setItem("nodes.dev.graph", JSON.stringify(g));
|
localStorage.setItem("nodes.dev.graph", JSON.stringify(g));
|
||||||
@@ -92,12 +101,16 @@
|
|||||||
isCalculating = true;
|
isCalculating = true;
|
||||||
if (res) handleSave(res);
|
if (res) handleSave(res);
|
||||||
try {
|
try {
|
||||||
await runtimeExecutor.execute(res || graph, graphSettings);
|
await runtimeExecutor.execute(
|
||||||
|
res || graph,
|
||||||
|
$state.snapshot(graphSettings),
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
memory = runtimeExecutor.getMemory();
|
memory = runtimeExecutor.getMemory();
|
||||||
inputPtrs = runtimeExecutor.inputPtrs;
|
allPtrs = runtimeExecutor.allPtrs;
|
||||||
|
|
||||||
clearTimeout(calcTimeout);
|
clearTimeout(calcTimeout);
|
||||||
calcTimeout = setTimeout(() => {
|
calcTimeout = setTimeout(() => {
|
||||||
isCalculating = false;
|
isCalculating = false;
|
||||||
@@ -120,7 +133,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>
|
||||||
@@ -133,9 +150,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>
|
||||||
@@ -168,7 +190,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"
|
||||||
@@ -201,6 +223,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(),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"build:story": "pnpm -r --filter 'ui' story:build",
|
"build:story": "pnpm -r --filter 'ui' story:build",
|
||||||
"build:app": "BASE_PATH=/ui pnpm -r --filter 'ui' build && pnpm -r --filter 'app' build",
|
"build:app": "BASE_PATH=/ui pnpm -r --filter 'ui' build && pnpm -r --filter 'app' build",
|
||||||
"build:nodes": "cargo build --workspace --target wasm32-unknown-unknown --release && rm -rf ./app/static/nodes/max/plantarium/ && mkdir -p ./app/static/nodes/max/plantarium/ && cp -R ./target/wasm32-unknown-unknown/release/*.wasm ./app/static/nodes/max/plantarium/",
|
"build:nodes": "cargo build --workspace --target wasm32-unknown-unknown --release && rm -rf ./app/static/nodes/max/plantarium/ && mkdir -p ./app/static/nodes/max/plantarium/ && cp -R ./target/wasm32-unknown-unknown/release/*.wasm ./app/static/nodes/max/plantarium/",
|
||||||
|
"build:nodes:debug": "cargo build --workspace --target wasm32-unknown-unknown && rm -rf ./app/static/nodes/max/plantarium/ && mkdir -p ./app/static/nodes/max/plantarium/ && cp -R ./target/wasm32-unknown-unknown/release/*.wasm ./app/static/nodes/max/plantarium/",
|
||||||
"build:node": "cargo build --package float --package output --package math --package nodarium_macros --package nodarium_utils --target wasm32-unknown-unknown --release && rm -rf ./app/static/nodes/max/plantarium/ && mkdir -p ./app/static/nodes/max/plantarium/ && cp -R ./target/wasm32-unknown-unknown/release/*.wasm ./app/static/nodes/max/plantarium/",
|
"build:node": "cargo build --package float --package output --package math --package nodarium_macros --package nodarium_utils --target wasm32-unknown-unknown --release && rm -rf ./app/static/nodes/max/plantarium/ && mkdir -p ./app/static/nodes/max/plantarium/ && cp -R ./target/wasm32-unknown-unknown/release/*.wasm ./app/static/nodes/max/plantarium/",
|
||||||
"build:deploy": "pnpm build",
|
"build:deploy": "pnpm build",
|
||||||
"dev:nodes": "chokidar './nodes/**' --initial -i '/pkg/' -c 'pnpm build:nodes'",
|
"dev:nodes": "chokidar './nodes/**' --initial -i '/pkg/' -c 'pnpm build:nodes'",
|
||||||
|
|||||||
@@ -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