Skip to content

Commit

Permalink
feat: suspense
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Oct 6, 2024
1 parent d4edacd commit 57ab8be
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { OrbitControls } from '@react-three/drei'
import { Canvas } from '@react-three/fiber'
import { createXRStore, IfInSessionMode, XR } from '@react-three/xr'
import { Leva } from 'leva'
import { Suspense } from 'react'

import { Model } from './components/model'
import { Perf } from './components/perf'
import { Stage } from './components/stage'
import { Toolbar } from './components/toolbar'
import { Loading } from './components/uikit/loading'
import { Origin } from './components/xr/origin'
import { PlayingProvider } from './contexts/playing'

Expand Down Expand Up @@ -35,7 +37,9 @@ export const App = () => {
/>
</IfInSessionMode>
<Stage>
<Model />
<Suspense fallback={<Loading />}>
<Model />
</Suspense>
</Stage>
</XR>
</Canvas>
Expand Down
4 changes: 3 additions & 1 deletion src/components/model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,7 @@ export const Model = () => {

useFrame(() => playing && helper.update(clock.getDelta()))

return (<primitive castShadow object={model} scale={modelScale} />)
return (
<primitive castShadow object={model} scale={modelScale} />
)
}
8 changes: 8 additions & 0 deletions src/components/uikit/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Root } from '@react-three/uikit'
import { Loading as UikitLoading } from '@react-three/uikit-apfel'

export const Loading = () => (
<Root>
<UikitLoading size="sm" />
</Root>
)

0 comments on commit 57ab8be

Please sign in to comment.