Skip to content

Commit 5a6ba2c

Browse files
committed
Fix Spring and Tween usage
1 parent 13f378c commit 5a6ba2c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Site/src/routes/(legal)/about/Cube.svelte

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
}: { i: number; j: number; onmoved: () => void; onclicked: () => void } =
1212
$props()
1313
14-
const opacity = new Spring(Math.random() + (-j - i / 2 - 5) / 12)
14+
const opacity = new Spring(0)
15+
$effect(() => {
16+
opacity.set(Math.random() + (-j - i / 2 - 5) / 12)
17+
})
1518
const clicked = new Map<string, "hovered" | "clicked">()
1619
const scale = new Spring(0, {
1720
stiffness: 0.1,
@@ -33,7 +36,7 @@
3336
</script>
3437

3538
<T.Mesh
36-
position={[i, j + $scale, -i - j]}
39+
position={[i, j + scale.current, -i - j]}
3740
on:pointerenter={() => {
3841
if (!clickable || clicked.get(`${i},${j}`)) return
3942
clicked.set(`${i},${j}`, "hovered")
@@ -56,11 +59,11 @@
5659
}}>
5760
<T.BoxGeometry />
5861
<T.MeshStandardMaterial
59-
color={$colour}
62+
color={colour.current}
6063
args={[
6164
{
6265
transparent: true,
63-
opacity: $opacity
66+
opacity: opacity.current
6467
}
6568
]} />
6669
</T.Mesh>

0 commit comments

Comments
 (0)