1
0
This commit is contained in:
syui 2024-08-02 11:49:10 +09:00
parent 61f516f3ce
commit 462e851aab
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56

View File

@ -53,13 +53,13 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) {
return [positions, colors]
}, [nodes])
//const starTexture = useLoader(THREE.TextureLoader, '/star.png')
// slowly rotate the galaxy
useFrame(({ clock }) => {
ref.current.rotation.z = clock.getElapsedTime() / 2
// zoom in and out
ref.current.scale.setScalar(Math.sin(clock.getElapsedTime() / 2) + 1.5)
ref.current.scale.setScalar(Math.sin(clock.getElapsedTime() / 2) + 1.2)
})
// make particles glow
@ -90,6 +90,7 @@ export function Galaxy(props: JSX.IntrinsicElements['group']) {
lights={[galaxyCenterLightRef]}
/>
</EffectComposer>
<ambientLight intensity={1} />
</group>
)
}
@ -100,11 +101,10 @@ export const ThreeFiberGalaxy = () => {
return (
<Canvas camera={{ position: [0, 12, 0], fov: 75 }}>
<OrbitControls enableZoom={true} enablePan={true} enableRotate={true} zoomSpeed={2} panSpeed={2} rotateSpeed={0.5} />
<ambientLight />
<pointLight position={[10, 10, 10]} />
<ScrollControls pages={5}>
<Scroll>
<Galaxy position={[0, 0, 0]} />
<Galaxy position={[0, 9, 0]} />
</Scroll>
</ScrollControls>
</Canvas>