diff --git a/Cargo.lock b/Cargo.lock index 1f819b0..adf7ed0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,6 +16,20 @@ dependencies = [ "web-sys", ] +[[package]] +name = "box" +version = "0.1.0" +dependencies = [ + "console_error_panic_hook", + "macros", + "serde", + "serde-wasm-bindgen", + "utils", + "wasm-bindgen", + "wasm-bindgen-test", + "web-sys", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -329,11 +343,13 @@ name = "triangle" version = "0.1.0" dependencies = [ "console_error_panic_hook", + "macros", "serde", "serde-wasm-bindgen", "utils", "wasm-bindgen", "wasm-bindgen-test", + "web-sys", ] [[package]] diff --git a/app/src/lib/graph-interface/graph-manager.ts b/app/src/lib/graph-interface/graph-manager.ts index 5bfb41c..e098f92 100644 --- a/app/src/lib/graph-interface/graph-manager.ts +++ b/app/src/lib/graph-interface/graph-manager.ts @@ -8,6 +8,13 @@ import type { NodeInput } from "@nodes/types"; const logger = createLogger("graph-manager"); +function areSocketsCompatible(output: string | undefined, inputs: string | string[] | undefined) { + if (Array.isArray(inputs) && output) { + return inputs.includes(output); + } + return inputs === output; +} + export class GraphManager extends EventEmitter<{ "save": Graph, "result": any }> { status: Writable<"loading" | "idle" | "error"> = writable("loading"); @@ -177,7 +184,6 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any }> } } } - console.log(settings); this.history.reset(); this._init(this.graph); @@ -353,7 +359,7 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any }> const fromSocketType = from.tmp?.type?.outputs?.[fromSocket]; const toSocketType = to.tmp?.type?.inputs?.[toSocket]?.type; - if (fromSocketType !== toSocketType) { + if (!areSocketsCompatible(fromSocketType, toSocketType)) { logger.error(`Socket types do not match: ${fromSocketType} !== ${toSocketType}`); return; } @@ -441,8 +447,8 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any }> const nodeType = node?.tmp?.type; if (!nodeType) return []; - const sockets: [Node, string | number][] = [] + // if index is a string, we are an input looking for outputs if (typeof index === "string") { @@ -479,7 +485,7 @@ export class GraphManager extends EventEmitter<{ "save": Graph, "result": any }> const inputs = node?.tmp?.type?.inputs; if (!inputs) continue; for (const key in inputs) { - if (inputs[key].type === ownType && edges.get(node.id) !== key) { + if (areSocketsCompatible(ownType, inputs[key].type) && edges.get(node.id) !== key) { sockets.push([node, key]); } } diff --git a/app/src/lib/node-registry.ts b/app/src/lib/node-registry.ts index c979ff6..9d259a5 100644 --- a/app/src/lib/node-registry.ts +++ b/app/src/lib/node-registry.ts @@ -72,10 +72,13 @@ export class RemoteNodeRegistry implements NodeRegistry { nodeIds.push("max/plantarium/random"); nodeIds.push("max/plantarium/float"); + nodeIds.push("max/plantarium/triangle"); nodeIds.push("max/plantarium/output"); nodeIds.push("max/plantarium/array"); nodeIds.push("max/plantarium/sum"); nodeIds.push("max/plantarium/stem"); + nodeIds.push("max/plantarium/box"); + nodeIds.push("max/plantarium/math"); const nodes = await Promise.all(nodeIds.map(id => this.loadNode(id))); diff --git a/app/src/lib/viewer/Scene.svelte b/app/src/lib/viewer/Scene.svelte index 83950c6..ed66fc0 100644 --- a/app/src/lib/viewer/Scene.svelte +++ b/app/src/lib/viewer/Scene.svelte @@ -1,18 +1,38 @@ - + {#each geometry as geo} + {#each geo.attributes.position.array as attr, i} + {#if i % 3 === 0} + + {/if} + {/each} + + + + + diff --git a/app/src/lib/viewer/Viewer.svelte b/app/src/lib/viewer/Viewer.svelte index ddeda81..c950ed3 100644 --- a/app/src/lib/viewer/Viewer.svelte +++ b/app/src/lib/viewer/Viewer.svelte @@ -1,7 +1,11 @@