feat(editor): animate the canvas in step with the simulation
A simulation store owns one run and one playhead, so the chart and the canvas read off the same instant. While the panel is open, Stocks show a live value and a fill gauge, Flows and Converters their current value; a play/pause + scrubber drives the playhead (a wall-clock-paced clock in usePlayback), and a marker tracks it on the chart.
This commit is contained in:
@@ -11,6 +11,8 @@ import { computed } from "vue"
|
||||
import { useNodeLoopRing } from "@/composables/useLoopHighlight"
|
||||
import { HANDLE_IN, HANDLE_OUT, type NodeData } from "@/model/projection"
|
||||
import type { FlowNode } from "@/model/types"
|
||||
import { useSimulationStore } from "@/store/simulation"
|
||||
import { formatValue } from "./format"
|
||||
import NodeLabel from "./NodeLabel.vue"
|
||||
|
||||
const props = defineProps<NodeProps<NodeData>>()
|
||||
@@ -18,6 +20,9 @@ const props = defineProps<NodeProps<NodeData>>()
|
||||
// The projection guarantees a flow-typed node here.
|
||||
const flow = computed(() => props.data.node as FlowNode)
|
||||
const loopRing = useNodeLoopRing(props.id)
|
||||
|
||||
const sim = useSimulationStore()
|
||||
const value = computed(() => sim.valueAt(props.id))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -40,5 +45,8 @@ const loopRing = useNodeLoopRing(props.id)
|
||||
<Handle :id="HANDLE_OUT" type="source" :position="Position.Right" />
|
||||
</div>
|
||||
<NodeLabel :node-id="props.id" :name="flow.name" />
|
||||
<div v-if="value !== null" class="font-mono text-xs tabular-nums text-base-content/70">
|
||||
{{ formatValue(value) }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user