Skip to content

Commit

Permalink
add suspense
Browse files Browse the repository at this point in the history
  • Loading branch information
donsiamese committed Aug 8, 2023
1 parent 8b94c28 commit cdfe3ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
12 changes: 7 additions & 5 deletions src/components/Daniele.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ const Daniele = (props) => {
const { nodes, materials, animations } = useGLTF('../assets/models/Daniele.glb')
const { actions } = useAnimations(animations, group)
const isCollectingQuest = usePlayerStore((state) => state.isCollectingQuest)

const actionRef = useRef(false)
useEffect(() => {
if (actionRef.current) {
actionRef.current.fadeOut(0.5)
}
if (isCollectingQuest) {
actions['Idle'].fadeOut(0.5)
actions['Talking'].reset().fadeIn(0.5).play()
actionRef.current = actions['Talking']
} else {
actions['Talking'].fadeOut(0.5)
actions['Idle'].reset().fadeIn(0.5).play()
actionRef.current = actions['Idle']
}
actionRef.current.reset().fadeIn(0.5).play()
}, [isCollectingQuest])
return (
<group ref={group} {...props} dispose={null}>
Expand Down
10 changes: 3 additions & 7 deletions src/components/World.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import FirTree from './FirTree'
import FirTreeSmall from './FirTreeSmall'
import Clouds from './Clouds'
import { Airship } from './Airship'
import Target from './Target'
import Pound from './Pound'
import Ocean from './Ocean'
import Windmill from './Windmill'
Expand Down Expand Up @@ -45,9 +44,6 @@ import TheDispatcher from './TheDispatcher'
import Lumberjack from './Lumberjack'
import IcescreamTruck from './IcescreamTruck'
import Windsock from './Windsock'
import GroundViewSign from './GroundViewSign'
import BirdEyeViewSign from './BirdEyeViewSign'
import OverheadViewSign from './OverheadViewSign'
import Boundaries from './Boundaries'
import Rig from './Rig'
import Grass from './Grass'
Expand All @@ -60,8 +56,6 @@ import Sensor from './Sensor'
import Mushrooms from './Mushroom'
import Prize from './Prize'
import Butterflies from './butterflies'
import { ViewTypeOverhead } from '../constants'
// import { AnimationStoreLoader } from '../store/animations'

const QuestsById = Quests.reduce((acc, quest) => {
acc[quest.id] = quest
Expand Down Expand Up @@ -190,7 +184,9 @@ const World = ({
/>
<Physics debug={debugPhysics}>
<TheDispatcher quest={QuestsById.Daniele} position={[61.1, 11.02, -16.51]}>
<Daniele scale={0.065} rotation={[0, 1.8, 0]} />
<Suspense fallback={null}>
<Daniele scale={0.065} rotation={[0, 1.8, 0]} />
</Suspense>
</TheDispatcher>
<TheDispatcher
quest={QuestsById.FlorentinaArmaselu}
Expand Down

0 comments on commit cdfe3ab

Please sign in to comment.