From 60752528a10757b968d174ffb0b16a043273c51c Mon Sep 17 00:00:00 2001 From: syui Date: Fri, 2 Aug 2024 10:08:21 +0900 Subject: [PATCH] fix custom --- galaxy-react/src/pages/galaxy.tsx | 44 ++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/galaxy-react/src/pages/galaxy.tsx b/galaxy-react/src/pages/galaxy.tsx index 88304ed..dabecc3 100644 --- a/galaxy-react/src/pages/galaxy.tsx +++ b/galaxy-react/src/pages/galaxy.tsx @@ -1,5 +1,5 @@ import * as THREE from 'three' -import { Points, useGLTF } from '@react-three/drei' +import { Points, useGLTF, OrbitControls, ScrollControls, Scroll } from '@react-three/drei' import { GLTF } from 'three-stdlib' import { useFrame, Canvas } from '@react-three/fiber' import { useMemo, useRef } from 'react' @@ -38,11 +38,11 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) { const normalizedDistanceToCenter = distanceToCenter / 100 // make colors closer to 0,0,0 be more reddish and colors further away be more blueish (do not use hsl) - // color.setHSL( - // (0.15 * (0.21 + Math.cos(distanceToCenter * 0.02))) / 2, - // 0.75, - // 0.6 - // ) + color.setHSL( + (0.15 * (0.21 + Math.cos(distanceToCenter * 0.02))) / 2, + 0.75, + 0.6 + ) color.setRGB( Math.cos(normalizedDistanceToCenter), THREE.MathUtils.randFloat(0, 0.8), @@ -57,7 +57,7 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) { // slowly rotate the galaxy useFrame(({ clock }) => { - ref.current.rotation.z = clock.getElapsedTime() / 5 + ref.current.rotation.z = clock.getElapsedTime() / 2 // zoom in and out ref.current.scale.setScalar(Math.sin(clock.getElapsedTime() / 2) + 1.5) }) @@ -84,8 +84,8 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) { @@ -97,11 +97,23 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) { useGLTF.preload('./models/galaxy.glb') export const ThreeFiberGalaxy = () => { - return ( - - - - - - ) + return ( + + + + + + + + + + + ) }