canvas space theme

This commit is contained in:
2026-03-04 17:32:19 -06:00
parent d872610b0b
commit 0b66096fc2
3 changed files with 71 additions and 65 deletions

28
src/index/Moon.tsx Normal file
View File

@@ -0,0 +1,28 @@
import {useMemo, useRef, useState} from "react";
import {Mesh} from "three";
import {useFrame} from "@react-three/fiber";
export function Moon(props: {radius: number, color: string, step: number}) {
const {radius, color, step} = props;
const moonRef = useRef<Mesh>(null);
const [theta, setTheta] = useState(0);
useFrame(() => {
if(!moonRef.current) return;
moonRef.current.position.set(
radius * Math.sin(theta),
0,
radius * Math.cos(theta),
)
setTheta(theta + step);
})
return (
<mesh ref={moonRef} position={[0,0,0]}>
<sphereGeometry args={[.5]} />
<meshPhysicalMaterial color={color} iridescence={0.2} />
</mesh>
)
}