diff --git a/pages/index.tsx b/pages/index.tsx index 8d47833..77ce5eb 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -4,13 +4,15 @@ import Image from 'next/future/image'; import Head from 'next/head'; import { useEffect, useRef, useState } from 'react'; import { InitFn, THREE, useThree } from 'rua-three'; -import style from 'styles/index/index.module.css'; +import styles from 'styles/index/index.module.css'; import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; import type { NextPageWithLayout } from 'types'; const MainLayout = dynamic(() => import('layouts/MainLayout')); +const Loading = dynamic(() => import('components/RUA/loading/RUALoading')); -const gltfLoader = new GLTFLoader(); +const manager = new THREE.LoadingManager(); +const gltfLoader = new GLTFLoader(manager); const Home: NextPageWithLayout = () => { const wrapper = useRef(null); @@ -19,6 +21,15 @@ const Home: NextPageWithLayout = () => { height: 300, }); + const [loading, setLoading] = useState(true); + const [showLoading, setShowLoading] = useState(true); + manager.onLoad = () => { + setLoading(false); + setTimeout(() => { + setShowLoading(false); + }, 300); + }; + const setCanvasSize = () => { if (!wrapper.current) return; const width = wrapper.current.clientWidth; @@ -87,7 +98,7 @@ const Home: NextPageWithLayout = () => {
{/*

Hi there 👋, I'm Arthur.

*/}

- + Hi there @@ -100,8 +111,24 @@ const Home: NextPageWithLayout = () => {

-
+
+ {showLoading && ( +
+ +
+ )}
{/*

I'm a Front-end developer. Yes, that's mean