fix: correctly show hide geometries in geometrypool
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m4s
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m4s
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
inView: boolean;
|
||||
z: number;
|
||||
};
|
||||
let { node, inView, z }: Props = $props();
|
||||
let { node = $bindable(), inView, z }: Props = $props();
|
||||
|
||||
const isActive = $derived(graphState.activeNodeId === node.id);
|
||||
const isSelected = $derived(graphState.selectedNodes.has(node.id));
|
||||
@@ -67,4 +67,4 @@
|
||||
/>
|
||||
</T.Mesh>
|
||||
|
||||
<NodeHtml {node} {inView} {isActive} {isSelected} {z} />
|
||||
<NodeHtml bind:node {inView} {isActive} {isSelected} {z} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { NodeInstance, SerializedNode } from "@nodarium/types";
|
||||
import type { NodeInstance } from "@nodarium/types";
|
||||
import NodeHeader from "./NodeHeader.svelte";
|
||||
import NodeParameter from "./NodeParameter.svelte";
|
||||
import { getGraphState } from "../graph/state.svelte";
|
||||
@@ -9,7 +9,7 @@
|
||||
const graphState = getGraphState();
|
||||
|
||||
type Props = {
|
||||
node: SerializedNode | NodeInstance;
|
||||
node: NodeInstance;
|
||||
position?: "absolute" | "fixed" | "relative";
|
||||
isActive?: boolean;
|
||||
isSelected?: boolean;
|
||||
@@ -30,15 +30,10 @@
|
||||
const zOffset = Math.random() - 0.5;
|
||||
const zLimit = 2 - zOffset;
|
||||
|
||||
const parameters =
|
||||
"state" in node
|
||||
? Object.entries(node.state?.type?.inputs || {}).filter(
|
||||
(p) =>
|
||||
p[1].type !== "seed" &&
|
||||
!("setting" in p[1]) &&
|
||||
p[1]?.hidden !== true,
|
||||
)
|
||||
: [];
|
||||
const parameters = Object.entries(node.state?.type?.inputs || {}).filter(
|
||||
(p) =>
|
||||
p[1].type !== "seed" && !("setting" in p[1]) && p[1]?.hidden !== true,
|
||||
);
|
||||
|
||||
$effect(() => {
|
||||
if ("state" in node && !node.state.ref) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { getGraphState } from "../graph/state.svelte.js";
|
||||
import { createNodePath } from "../helpers/index.js";
|
||||
import type { NodeInstance, SerializedNode } from "@nodarium/types";
|
||||
import type { NodeInstance } from "@nodarium/types";
|
||||
|
||||
const graphState = getGraphState();
|
||||
|
||||
const { node }: { node: NodeInstance | SerializedNode } = $props();
|
||||
const { node }: { node: NodeInstance } = $props();
|
||||
|
||||
function handleMouseDown(event: MouseEvent) {
|
||||
event.stopPropagation();
|
||||
@@ -20,8 +20,7 @@
|
||||
}
|
||||
|
||||
const cornerTop = 10;
|
||||
const rightBump =
|
||||
"state" in node ? !!node?.state?.type?.outputs?.length : false;
|
||||
const rightBump = !!node?.state?.type?.outputs?.length;
|
||||
const aspectRatio = 0.25;
|
||||
|
||||
const path = createNodePath({
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
<script lang="ts">
|
||||
import type {
|
||||
NodeInput as NodeInputType,
|
||||
NodeInstance,
|
||||
SerializedNode,
|
||||
} from "@nodarium/types";
|
||||
import type { NodeInput, NodeInstance } from "@nodarium/types";
|
||||
import { createNodePath } from "../helpers/index.js";
|
||||
import NodeInput from "./NodeInput.svelte";
|
||||
import NodeInputEl from "./NodeInput.svelte";
|
||||
import { getGraphManager, getGraphState } from "../graph/state.svelte.js";
|
||||
|
||||
type Props = {
|
||||
node: NodeInstance | SerializedNode;
|
||||
input: NodeInputType;
|
||||
node: NodeInstance;
|
||||
input: NodeInput;
|
||||
id: string;
|
||||
isLast?: boolean;
|
||||
};
|
||||
@@ -80,7 +76,7 @@
|
||||
<label for={elementId}>{input.label || id}</label>
|
||||
{/if}
|
||||
{#if inputType.external !== true}
|
||||
<NodeInput {graph} {elementId} bind:node {input} {id} />
|
||||
<NodeInputEl {graph} {elementId} bind:node {input} {id} />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ export function humanizeDuration(durationInMilliseconds: number) {
|
||||
}
|
||||
|
||||
if (millis > 0 || durationString === '') {
|
||||
durationString += millis + 'ms';
|
||||
durationString += Math.floor(millis) + 'ms';
|
||||
}
|
||||
|
||||
return durationString.trim();
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<script lang="ts">
|
||||
import NodeHtml from "$lib/graph-interface/node/NodeHTML.svelte";
|
||||
import type { SerializedNode } from "@nodarium/types";
|
||||
import type { NodeDefinition, NodeId, NodeInstance } from "@nodarium/types";
|
||||
|
||||
const { node }: { node: SerializedNode } = $props();
|
||||
const { node }: { node: NodeDefinition } = $props();
|
||||
|
||||
let dragging = $state(false);
|
||||
|
||||
let nodeData = $state({
|
||||
let nodeData = $state<NodeInstance>({
|
||||
id: 0,
|
||||
type: node?.id,
|
||||
type: node.id as unknown as NodeId,
|
||||
position: [0, 0] as [number, number],
|
||||
props: {},
|
||||
tmp: {
|
||||
state: {
|
||||
type: node,
|
||||
},
|
||||
});
|
||||
@@ -46,7 +46,7 @@
|
||||
tabindex="0"
|
||||
ondragstart={handleDragStart}
|
||||
>
|
||||
<NodeHtml inView={true} position={"relative"} z={5} bind:node={nodeData} />
|
||||
<NodeHtml bind:node={nodeData} inView={true} position={"relative"} z={5} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { humanizeDuration, humanizeNumber } from "$lib/helpers";
|
||||
import localStore from "$lib/helpers/localStore";
|
||||
import { localState } from "$lib/helpers/localState.svelte";
|
||||
import SmallGraph from "./SmallGraph.svelte";
|
||||
import type { PerformanceData, PerformanceStore } from "@nodarium/utils";
|
||||
|
||||
export let store: PerformanceStore;
|
||||
const { store, fps }: { store: PerformanceStore; fps: number[] } = $props();
|
||||
|
||||
const open = localStore("node.performance.small.open", {
|
||||
const open = localState("node.performance.small.open", {
|
||||
runtime: false,
|
||||
fps: false,
|
||||
});
|
||||
|
||||
$: vertices = $store?.at(-1)?.["total-vertices"]?.[0] || 0;
|
||||
$: faces = $store?.at(-1)?.["total-faces"]?.[0] || 0;
|
||||
$: runtime = $store?.at(-1)?.["runtime"]?.[0] || 0;
|
||||
const vertices = $derived($store?.at(-1)?.["total-vertices"]?.[0] || 0);
|
||||
const faces = $derived($store?.at(-1)?.["total-faces"]?.[0] || 0);
|
||||
const runtime = $derived($store?.at(-1)?.["runtime"]?.[0] || 0);
|
||||
|
||||
function getPoints(data: PerformanceData, key: string) {
|
||||
return data?.map((run) => run[key]?.[0] || 0) || [];
|
||||
}
|
||||
|
||||
export let fps: number[] = [];
|
||||
</script>
|
||||
|
||||
<div class="wrapper">
|
||||
@@ -27,12 +25,12 @@
|
||||
<tbody>
|
||||
<tr
|
||||
style="cursor:pointer;"
|
||||
on:click={() => ($open.runtime = !$open.runtime)}
|
||||
onclick={() => (open.value.runtime = !open.value.runtime)}
|
||||
>
|
||||
<td>{$open.runtime ? "-" : "+"} runtime </td>
|
||||
<td>{open.value.runtime ? "-" : "+"} runtime </td>
|
||||
<td>{humanizeDuration(runtime || 1000)}</td>
|
||||
</tr>
|
||||
{#if $open.runtime}
|
||||
{#if open.value.runtime}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<SmallGraph points={getPoints($store, "runtime")} />
|
||||
@@ -40,13 +38,16 @@
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
<tr style="cursor:pointer;" on:click={() => ($open.fps = !$open.fps)}>
|
||||
<td>{$open.fps ? "-" : "+"} fps </td>
|
||||
<tr
|
||||
style="cursor:pointer;"
|
||||
onclick={() => (open.value.fps = !open.value.fps)}
|
||||
>
|
||||
<td>{open.value.fps ? "-" : "+"} fps </td>
|
||||
<td>
|
||||
{Math.floor(fps[fps.length - 1])}fps
|
||||
</td>
|
||||
</tr>
|
||||
{#if $open.fps}
|
||||
{#if open.value.fps}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<SmallGraph points={fps} />
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from "three";
|
||||
|
||||
function fastArrayHash(arr: Int32Array) {
|
||||
const sampleDistance = Math.max(Math.floor(arr.length / 100), 1);
|
||||
const sampleDistance = Math.max(Math.floor(arr.length / 1000), 1);
|
||||
const sampleCount = Math.floor(arr.length / sampleDistance);
|
||||
|
||||
let hash = new Int32Array(sampleCount);
|
||||
@@ -40,6 +40,9 @@ export function createGeometryPool(parentScene: Group, material: Material) {
|
||||
let hash = fastArrayHash(data);
|
||||
|
||||
let geometry = existingMesh ? existingMesh.geometry : new BufferGeometry();
|
||||
if (existingMesh) {
|
||||
existingMesh.visible = true;
|
||||
}
|
||||
|
||||
// Extract data from the encoded array
|
||||
// const geometryType = encodedData[index++];
|
||||
@@ -121,7 +124,6 @@ export function createGeometryPool(parentScene: Group, material: Material) {
|
||||
updateSingleGeometry(input, existingMesh || null);
|
||||
} else if (existingMesh) {
|
||||
existingMesh.visible = false;
|
||||
scene.remove(existingMesh);
|
||||
}
|
||||
}
|
||||
return { totalVertices, totalFaces };
|
||||
@@ -258,7 +260,6 @@ export function createInstancedGeometryPool(
|
||||
updateSingleInstance(input, existingMesh || null);
|
||||
} else if (existingMesh) {
|
||||
existingMesh.visible = false;
|
||||
scene.remove(existingMesh);
|
||||
}
|
||||
}
|
||||
return { totalVertices, totalFaces };
|
||||
|
||||
@@ -1,19 +1,33 @@
|
||||
import { type SyncCache } from "@nodarium/types";
|
||||
|
||||
export class MemoryRuntimeCache implements SyncCache {
|
||||
private map = new Map<string, unknown>();
|
||||
size: number;
|
||||
|
||||
private cache: [string, unknown][] = [];
|
||||
size = 50;
|
||||
constructor(size = 50) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
get<T>(key: string): T | undefined {
|
||||
return this.cache.find(([k]) => k === key)?.[1] as T;
|
||||
}
|
||||
set<T>(key: string, value: T): void {
|
||||
this.cache.push([key, value]);
|
||||
this.cache = this.cache.slice(-this.size);
|
||||
}
|
||||
clear(): void {
|
||||
this.cache = [];
|
||||
if (!this.map.has(key)) return undefined;
|
||||
const value = this.map.get(key) as T;
|
||||
this.map.delete(key);
|
||||
this.map.set(key, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
set<T>(key: string, value: T): void {
|
||||
if (this.map.has(key)) {
|
||||
this.map.delete(key);
|
||||
}
|
||||
this.map.set(key, value);
|
||||
while (this.map.size > this.size) {
|
||||
const oldestKey = this.map.keys().next().value as string;
|
||||
this.map.delete(oldestKey);
|
||||
}
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.map.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ import { MemoryRuntimeExecutor } from "./runtime-executor";
|
||||
import { RemoteNodeRegistry, IndexDBCache } from "@nodarium/registry";
|
||||
import type { Graph } from "@nodarium/types";
|
||||
import { createPerformanceStore } from "@nodarium/utils";
|
||||
import { MemoryRuntimeCache } from "./runtime-executor-cache";
|
||||
|
||||
const indexDbCache = new IndexDBCache("node-registry");
|
||||
const nodeRegistry = new RemoteNodeRegistry("", indexDbCache);
|
||||
|
||||
const executor = new MemoryRuntimeExecutor(nodeRegistry);
|
||||
const cache = new MemoryRuntimeCache()
|
||||
const executor = new MemoryRuntimeExecutor(nodeRegistry, cache);
|
||||
|
||||
const performanceStore = createPerformanceStore();
|
||||
executor.perf = performanceStore;
|
||||
|
||||
@@ -88,13 +88,10 @@
|
||||
randomSeed: { type: "boolean", value: false },
|
||||
});
|
||||
|
||||
let runIndex = 0;
|
||||
|
||||
async function update(
|
||||
g: Graph,
|
||||
s: Record<string, any> = $state.snapshot(graphSettings),
|
||||
) {
|
||||
runIndex++;
|
||||
performanceStore.startRun();
|
||||
try {
|
||||
let a = performance.now();
|
||||
|
||||
Reference in New Issue
Block a user