Skip to content

Commit

Permalink
feat: add r3f-perf
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Oct 5, 2024
1 parent 82b4b14 commit c05d35c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"forgetti": "^0.8.5",
"foxact": "^0.2.38",
"leva": "^0.9.35",
"r3f-perf": "^7.2.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"three": "^0.169.0"
Expand Down
64 changes: 64 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createXRStore, XR, XROrigin } from '@react-three/xr'

import { Appbar } from './components/appbar'
import { Model } from './components/model'
import { Perf } from './components/perf'
import { Stage } from './components/stage'

export const App = () => {
Expand All @@ -23,6 +24,7 @@ export const App = () => {
<group position={[0, 0, 2]}>
<XROrigin />
</group>
<Perf />
<Appbar />
<Stage>
<Model />
Expand Down
15 changes: 15 additions & 0 deletions src/components/perf.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { IfInSessionMode } from '@react-three/xr'
import { useControls } from 'leva'
import { Perf as R3FPerf } from 'r3f-perf'

export const Perf = () => {
const { showPerf } = useControls('Debug', {
showPerf: import.meta.env.DEV,
})

return showPerf && (
<IfInSessionMode deny={['immersive-ar', 'immersive-vr']}>
<R3FPerf position="top-left" />
</IfInSessionMode>
)
}

0 comments on commit c05d35c

Please sign in to comment.