refactor: move view logic inside graph.svelte

This commit is contained in:
2024-03-12 18:47:50 +01:00
parent af24b5cffe
commit 9241700ada
16 changed files with 465 additions and 384 deletions

View File

@@ -8,9 +8,7 @@
export let minZoom = 4;
export let maxZoom = 150;
export let cx = 0;
export let cy = 0;
export let cz = 30;
export let cameraPosition: [number, number, number] = [0, 1, 0];
export let width = globalThis?.innerWidth || 100;
export let height = globalThis?.innerHeight || 100;
@@ -19,12 +17,16 @@
let bh = 2;
$: if (width && height) {
bw = width / cz;
bh = height / cz;
bw = width / cameraPosition[2];
bh = height / cameraPosition[2];
}
</script>
<T.Group position.x={cx} position.z={cy} position.y={-1.0}>
<T.Group
position.x={cameraPosition[0]}
position.z={cameraPosition[1]}
position.y={-1.0}
>
<T.Mesh rotation.x={-Math.PI / 2} position.y={0.2} scale.x={bw} scale.y={bh}>
<T.PlaneGeometry args={[1, 1]} />
<T.ShaderMaterial
@@ -54,9 +56,9 @@
value: 100,
},
}}
uniforms.cx.value={cx}
uniforms.cy.value={cy}
uniforms.cz.value={cz}
uniforms.cx.value={cameraPosition[0]}
uniforms.cy.value={cameraPosition[1]}
uniforms.cz.value={cameraPosition[2]}
uniforms.width.value={width}
uniforms.height.value={height}
/>