diff --git a/app/page.tsx b/app/page.tsx index 96b996e..cb47d5b 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -3,7 +3,7 @@ import Image from 'next/image'; import styles from 'styles/index/index.module.css'; import dynamic from 'next/dynamic'; -const HomeModel = dynamic(() => import('./home-modle')); +const HomeModel = dynamic(() => import('../components/models/home-model')); export const metadata = { title: 'RUA - Home', @@ -12,7 +12,7 @@ export const metadata = { export default function Page() { return (
-
+

Hi there @@ -27,7 +27,7 @@ export default function Page() {

-
+
diff --git a/app/home-modle.tsx b/components/models/cat-model.tsx similarity index 72% rename from app/home-modle.tsx rename to components/models/cat-model.tsx index ab6bacd..ed59a14 100644 --- a/app/home-modle.tsx +++ b/components/models/cat-model.tsx @@ -1,18 +1,13 @@ -'use client'; - -import { Stats } from '@react-three/drei'; -import { Canvas, useFrame, useLoader, useThree } from '@react-three/fiber'; +import { useThree, useLoader, useFrame } from '@react-three/fiber'; import { getMousePosition } from 'lib/utils'; -import { useEffect, useRef } from 'react'; -import useStore from 'store'; +import { useRef, useEffect } from 'react'; import * as THREE from 'three'; import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'; import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; +import useStore from 'store'; +import { rotationX, rotationY } from './home-model'; -const rotationY = 0.4; -const rotationX = 0.18; - -const Model = () => { +const CatModel = () => { const mixer = useRef(null); const toggleLoading = useStore((state) => state.toggleLoading); @@ -34,7 +29,7 @@ const Model = () => { }); camera.position.x = -5.66648088408735e-8; camera.position.y = 0.3; - camera.position.z = 1.3; + camera.position.z = 1.5; toggleLoading(false); const halfWidth = Math.floor(window.innerWidth / 2); @@ -84,30 +79,4 @@ const Model = () => { ); }; -const HomeModel = () => { - const modelLoading = useStore((state) => state.modelLoading); - - return ( - <> - - - - - - {/*
- -
*/} - - ); -}; - -export default HomeModel; +export default CatModel; diff --git a/components/models/home-model.tsx b/components/models/home-model.tsx new file mode 100644 index 0000000..3c18412 --- /dev/null +++ b/components/models/home-model.tsx @@ -0,0 +1,43 @@ +'use client'; + +import { Stats } from '@react-three/drei'; +import { Canvas } from '@react-three/fiber'; +import clsx from 'clsx'; +import Loading from 'components/rua/loading/rua-loading'; +import { Suspense, lazy } from 'react'; +import useStore from 'store'; + +const CatModel = lazy(() => import('components/models/cat-model')); + +export const rotationY = 0.4; +export const rotationX = 0.18; + +const HomeModel = () => { + const modelLoading = useStore((state) => state.modelLoading); + + return ( + <> + + + }> + + + + +
+ +
+ + ); +}; + +export default HomeModel; diff --git a/components/rua/loading/rua-loading.tsx b/components/rua/loading/rua-loading.tsx index f3c514d..a3b893f 100644 --- a/components/rua/loading/rua-loading.tsx +++ b/components/rua/loading/rua-loading.tsx @@ -1,9 +1,9 @@ -import React, { memo } from 'react'; import clsx from 'clsx'; +import { useTheme } from 'next-themes'; +import Image from 'next/image'; import loadingImage from 'public/images/img/mona-loading-default.gif'; import loadingImageDimmed from 'public/images/img/mona-loading-dimmed.gif'; -import Image from 'next/image'; -import { useTheme } from 'next-themes'; +import { memo } from 'react'; type Props = { className?: string;