feat: yaaay first stem
This commit is contained in:
@ -5,8 +5,7 @@
|
||||
import { RemoteNodeRegistry } from "$lib/node-registry";
|
||||
import * as templates from "$lib/graph-templates";
|
||||
import type { Graph } from "@nodes/types";
|
||||
import { decode, encode } from "$lib/helpers/flat_tree";
|
||||
import { decodeFloat, encodeFloat } from "$lib/helpers/encode";
|
||||
import { decode, encode, decodeFloat, encodeFloat } from "@nodes/utils";
|
||||
import Viewer from "$lib/viewer/Viewer.svelte";
|
||||
|
||||
globalThis.decode = decode;
|
||||
@ -14,6 +13,41 @@
|
||||
globalThis.df = decodeFloat;
|
||||
globalThis.en = encodeFloat;
|
||||
|
||||
globalThis.ci = function createIndeces(resX: number, stemLength = 1) {
|
||||
const index = new Uint16Array(resX * (Math.max(stemLength, 1) - 1) * 6);
|
||||
|
||||
for (let i = 0; i < stemLength; i++) {
|
||||
const indexOffset = i * resX * 6;
|
||||
const positionOffset = i * resX;
|
||||
for (let j = 0; j < resX; j++) {
|
||||
const _indexOffset = indexOffset + j * 6;
|
||||
const _positionOffset = positionOffset + j;
|
||||
|
||||
console.log(`iio: ${_indexOffset} pio: ${_positionOffset} j: ${j}`);
|
||||
|
||||
if (j === resX - 1) {
|
||||
index[_indexOffset + 0] = _positionOffset + 1;
|
||||
index[_indexOffset + 1] = _positionOffset - resX + 1;
|
||||
index[_indexOffset + 2] = _positionOffset;
|
||||
|
||||
index[_indexOffset + 3] = _positionOffset;
|
||||
index[_indexOffset + 4] = _positionOffset + resX;
|
||||
index[_indexOffset + 5] = _positionOffset + 1;
|
||||
} else {
|
||||
index[_indexOffset + 0] = _positionOffset + resX + 1;
|
||||
index[_indexOffset + 1] = _positionOffset + 1;
|
||||
index[_indexOffset + 2] = _positionOffset;
|
||||
|
||||
index[_indexOffset + 3] = _positionOffset;
|
||||
index[_indexOffset + 4] = _positionOffset + resX;
|
||||
index[_indexOffset + 5] = _positionOffset + resX + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
};
|
||||
|
||||
const nodeRegistry = new RemoteNodeRegistry("http://localhost:3001");
|
||||
const runtimeExecutor = new MemoryRuntimeExecutor(nodeRegistry);
|
||||
|
||||
@ -28,7 +62,7 @@
|
||||
let a = performance.now();
|
||||
res = runtimeExecutor.execute(event.detail);
|
||||
time = performance.now() - a;
|
||||
console.log(res);
|
||||
console.log({ res, time });
|
||||
}
|
||||
|
||||
function handleSave(event: CustomEvent<Graph>) {
|
||||
|
Reference in New Issue
Block a user