@@ -8,24 +8,25 @@ import '../styles.css';
88import steps from '../Utils/steps.json' ;
99import WalkthroughUI from './WalkthroughUI' ;
1010import WalkthroughController from '../Controllers/WalkthroughController' ;
11- import Loading from '../Utils/Loading' ; // Import the Loading component
11+ import Loading from '../Utils/Loading' ;
1212import { SpeedInsights } from '@vercel/speed-insights/react' ;
13- import { Analytics } from "@vercel/analytics/react"
13+ import { Analytics } from "@vercel/analytics/react" ;
1414import * as THREE from 'three' ;
1515import { SoftShadows } from '@react-three/drei' ;
16+ import AudioPlayer from '../Utils/AudioPlayer' ;
1617
1718function Home ( ) {
1819 const modelRef = useRef ( ) ;
1920 const Model = React . lazy ( ( ) => import ( './Model' ) ) ;
2021 const [ currentStep , setCurrentStep ] = useState ( 0 ) ;
2122 const [ isTransitioning , setIsTransitioning ] = useState ( false ) ;
2223 const [ completedEvents , setCompletedEvents ] = useState ( { } ) ;
23- const [ isLoading , setIsLoading ] = useState ( true ) ; // Loading state
24+ const [ isLoading , setIsLoading ] = useState ( true ) ;
2425 const [ isWalkthroughActive , setIsWalkthroughActive ] = useState ( true ) ;
2526 const [ pcZoomed , setPcZoomed ] = useState ( false ) ;
2627
2728 const exitWalkthrough = ( ) => {
28- setIsWalkthroughActive ( false ) ; // Or any logic to hide the walkthrough
29+ setIsWalkthroughActive ( false ) ;
2930 } ;
3031
3132 const { description, events } = steps [ currentStep ] || { } ;
@@ -44,43 +45,34 @@ function Home() {
4445 if ( ! isTransitioning && currentStep > 0 ) {
4546 setCurrentStep ( ( prev ) => prev - 1 ) ;
4647 }
47- }
48+ } ;
4849
4950 const completeEvent = ( eventName , stepIndex ) => {
50- // TODO: wait till lerp animation is done
5151 if ( isTransitioning ) {
5252 return ;
5353 }
54- // Ensure that the event only completes if it's the correct step
5554 if ( stepIndex !== currentStep ) {
5655 return ;
5756 }
58-
59- // Check if the event is already completed for the given step
6057 setCompletedEvents ( ( prev ) => {
6158 const isEventAlreadyCompleted = prev [ stepIndex ] ?. [ eventName ] ;
62-
6359 if ( isEventAlreadyCompleted ) {
64- return prev ; // Event is already completed, so return previous state
60+ return prev ;
6561 }
66-
67- // If not completed, create a new state object
6862 const updatedEvents = {
6963 ...prev ,
7064 [ stepIndex ] : {
7165 ...prev [ stepIndex ] ,
7266 [ eventName ] : true ,
7367 } ,
7468 } ;
75-
76- // Check if all events for the current step are now completed
7769 const stepEvents = steps [ stepIndex ] ?. events || { } ;
7870 const allEventsCompleted = Object . keys ( stepEvents ) . every (
7971 ( event ) => updatedEvents [ stepIndex ] ?. [ event ] === true
8072 ) ;
8173
8274 if ( allEventsCompleted ) {
83- nextStep ( ) ; // Move to the next step if all events are completed
75+ nextStep ( ) ;
8476 }
8577
8678 return updatedEvents ;
@@ -93,8 +85,9 @@ function Home() {
9385
9486 return (
9587 < div className = "container" >
96- < Suspense fallback = { < Loading /> } >
88+ < Suspense fallback = { < Loading isLoading = { isLoading } /> } >
9789 { isLoading && < Loading /> }
90+ < AudioPlayer />
9891 < Canvas shadows = { { type : THREE . PCFSoftShadowMap , mapSize : { width : 2048 , height : 2048 } } } precision = "high" >
9992 { ! isWalkthroughActive && < Lighting /> }
10093 < SoftShadows size = { 20 } samples = { 16 } />
@@ -108,7 +101,6 @@ function Home() {
108101 setPcZoomed = { setPcZoomed }
109102 />
110103 < OrbitControls enableZoom = { false } enablePan = { false } enableRotate = { false } />
111- { /* <Stats /> */ }
112104 < ModelController
113105 modelRef = { modelRef }
114106 isWalkthroughActive = { isWalkthroughActive }
0 commit comments