diff --git a/src/index/Canvas.tsx b/src/index/Canvas.tsx index 12fb6ec..98f7f51 100644 --- a/src/index/Canvas.tsx +++ b/src/index/Canvas.tsx @@ -1,20 +1,23 @@ import {motion} from "framer-motion"; import "./canvas.scss"; import {Canvas as ThreeCanvas, useFrame} from "@react-three/fiber"; -import {useMemo, useRef} from "react"; -import {Mesh} from "three"; +import React, {useMemo, useRef} from "react"; +import {Mesh, Vector3} from "three"; import {Moon} from "./Moon"; +type Coordinate = [number, number, number]; export default function Canvas() { + return (
- + + - + Welcome to my blog @@ -23,6 +26,21 @@ export default function Canvas() { ) } +function Frame() { + useFrame(state => { + const { x, y } = state.pointer + + // Smoothly interpolate the camera position + // We multiply by a factor (e.g., 5) to increase the range of movement + state.camera.position.lerp(new Vector3(x * 10, y * 10, 5), 0.1) + + // Always keep the camera looking at the center + state.camera.lookAt(0, 0, 0) + }) + + return <> +} + function Sphere() { const meshRef = useRef(null); @@ -42,7 +60,6 @@ function Sphere() { const RADIUS = 20; const COUNT = 100; -type Coordinate = [number, number, number]; function Stars() { const positions = useMemo(() => { const positions: Coordinate[] = []; diff --git a/src/index/canvas.scss b/src/index/canvas.scss index 413182b..48e34fc 100644 --- a/src/index/canvas.scss +++ b/src/index/canvas.scss @@ -6,17 +6,11 @@ main { align-items: center; background: black; color: white; - position: absolute; - top: 0; z-index: -999; } .welcome { text-align: center; - z-index: 99; position: absolute; top: 50%; -} - -.canvas { } \ No newline at end of file diff --git a/src/nav/nav.scss b/src/nav/nav.scss index c9e39f5..526e702 100644 --- a/src/nav/nav.scss +++ b/src/nav/nav.scss @@ -41,10 +41,7 @@ $menu: #282c34; flex-grow: 1; } .wave { - position: absolute; - z-index: 999; user-select: none; pointer-events: none; - left: -10%; - width: 110%; + position: absolute; } \ No newline at end of file