@@ -2,13 +2,12 @@ import styles from "./Home.module.css";
22import { useState , useEffect , useRef } from "react" ;
33import LevelComponent from "../../components/LevelComponent" ;
44import { main } from "./js/main.js" ;
5- // import { main } from "./solarsystem.js";
65import { useMouseMoving } from "../../hooks/useMouseMoving.js" ;
6+
77export default function Home ( ) {
8- const lvlNum = 4 ;
98 const canvasRef = useRef < HTMLCanvasElement | null > ( null ) ;
109 const zoomOutRef = useRef < ( ( ) => void ) | null > ( null ) ;
11-
10+ const getLevelRef = useRef < ( ( ) => number ) | null > ( null ) ;
1211 const [ isVisible , setIsVisible ] = useState ( false ) ;
1312 const [ mountKey , setMountKey ] = useState ( 0 ) ;
1413 const isMouseMoving = useMouseMoving ( 2500 ) ;
@@ -26,8 +25,9 @@ export default function Home() {
2625
2726 useEffect ( ( ) => {
2827 if ( ! canvasRef . current ) return ;
29- const { zoomOut } = main ( canvasRef . current , handleOpen ) ;
28+ const { zoomOut, getLevel } = main ( canvasRef . current , handleOpen ) ;
3029 zoomOutRef . current = zoomOut ;
30+ getLevelRef . current = getLevel ;
3131 } , [ ] ) ;
3232
3333 return (
@@ -47,10 +47,9 @@ export default function Home() {
4747
4848 < div className = "absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-[90vw] h-[90vh] z-50" >
4949 < LevelComponent
50- // key={mountKey}
51- selectedLevel = { 1 }
52- onClose = { ( ) => handleClose ( ) }
53-
50+ key = { mountKey }
51+ onClose = { ( ) => handleClose ( ) }
52+ lvl = { getLevelRef . current ? getLevelRef . current ( ) : 0 }
5453 />
5554 </ div >
5655
0 commit comments