-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deps): add react three fiber, and three.js
- Loading branch information
1 parent
d5738c5
commit d8c8a34
Showing
3 changed files
with
218 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,47 @@ | ||
/* import { SplineComponent } from '@website/shared/ui/spline/spline-component'; */ | ||
import { WELCOME_CONSTANTS } from '../constants/welcome.constants'; | ||
import { Welcome } from './welcome'; | ||
/* eslint-disable unused-imports/no-unused-vars */ | ||
import type { ThreeElements } from '@react-three/fiber' | ||
import type * as THREE from 'three' | ||
import { Canvas, useFrame } from '@react-three/fiber' | ||
import React, { useRef, useState } from 'react' | ||
import { WELCOME_CONSTATNTS } from '../constants/welcome.constants' | ||
import { Welcome } from './welcome' | ||
|
||
function Box(props: ThreeElements['mesh']) { | ||
const meshRef = useRef<THREE.Mesh>(null!) | ||
const [hovered, setHover] = useState(false) | ||
const [active, setActive] = useState(false) | ||
useFrame((state, delta) => (meshRef.current.rotation.x += delta)) | ||
return ( | ||
<mesh | ||
{...props} | ||
ref={meshRef} | ||
scale={active ? 1.5 : 1} | ||
onClick={event => setActive(!active)} | ||
onPointerOver={event => setHover(true)} | ||
onPointerOut={event => setHover(false)} | ||
> | ||
<boxGeometry args={[1, 1, 1]} /> | ||
<meshStandardMaterial color={hovered ? 'hotpink' : '#2f74c0'} /> | ||
</mesh> | ||
) | ||
} | ||
|
||
export function WelcomeSection() { | ||
return ( | ||
<section className="relative flex justify-center w-full mx-auto lg:mx-0"> | ||
{/* <SplineComponent | ||
className="absolute -bottom-16 lg:left-0 lg:top-0 lg:scale-[1.2]" | ||
link="https://prod.spline.design/nnjZJFW1wThAacUS/scene.splinecode" | ||
/> */} | ||
<div className="w-full h-screen max-w-screen-xl px-5 py-5 lg:px-20 lg:py-14"> | ||
<section className="w-full lg:w-3/5"> | ||
<Welcome socials={WELCOME_CONSTANTS.SOCIALS} /> | ||
</section> | ||
</div> | ||
return ( | ||
<section className="relative flex justify-center w-full mx-auto lg:mx-0"> | ||
<Canvas> | ||
<ambientLight intensity={Math.PI / 2} /> | ||
<spotLight position={[10, 10, 10]} angle={0.15} penumbra={1} decay={0} intensity={Math.PI} /> | ||
<pointLight position={[-10, -10, -10]} decay={0} intensity={Math.PI} /> | ||
<Box position={[-1.2, 0, 0]} /> | ||
<Box position={[1.2, 0, 0]} /> | ||
</Canvas> | ||
|
||
<div className="w-full h-screen max-w-screen-xl px-5 py-5 lg:px-20 lg:py-14"> | ||
<section className="w-full lg:w-3/5"> | ||
<Welcome socials={WELCOME_CONSTATNTS.SOCIALS} /> | ||
</section> | ||
); | ||
</div> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.