From 718ef3a0960accd133aaed9a5d5320eac672b928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=97=8D+85CD?= <50108258+kwaa@users.noreply.github.com> Date: Sat, 5 Oct 2024 14:40:28 +0800 Subject: [PATCH] refactor: move session mode check to root --- src/app.tsx | 13 +++--- src/components/perf.tsx | 7 +--- src/components/toolbar.tsx | 86 +++++++++++++++++++------------------- 3 files changed, 51 insertions(+), 55 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 7c8033e..cf98a13 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,6 +1,6 @@ import { OrbitControls } from '@react-three/drei' import { Canvas } from '@react-three/fiber' -import { createXRStore, XR, XROrigin } from '@react-three/xr' +import { createXRStore, IfInSessionMode, XR, XROrigin } from '@react-three/xr' import { Leva } from 'leva' import { Model } from './components/model' @@ -11,6 +11,7 @@ import { Toolbar } from './components/toolbar' export const App = () => { const store = createXRStore({ controller: { teleportPointer: true }, + depthSensing: true, emulate: import.meta.env.DEV ? 'metaQuest3' : false, hand: { rayPointer: { cursorModel: { color: 'white' } }, @@ -27,16 +28,18 @@ export const App = () => { - - - - + + + + + + diff --git a/src/components/perf.tsx b/src/components/perf.tsx index 88e0154..19cd027 100644 --- a/src/components/perf.tsx +++ b/src/components/perf.tsx @@ -1,4 +1,3 @@ -import { IfInSessionMode } from '@react-three/xr' import { useControls } from 'leva' import { Perf as R3FPerf } from 'r3f-perf' @@ -7,9 +6,5 @@ export const Perf = () => { showPerf: import.meta.env.DEV, }) - return showPerf && ( - - - - ) + return showPerf && () } diff --git a/src/components/toolbar.tsx b/src/components/toolbar.tsx index 646eb4f..0b5dacf 100644 --- a/src/components/toolbar.tsx +++ b/src/components/toolbar.tsx @@ -1,7 +1,7 @@ import { Fullscreen, Text } from '@react-three/uikit' import { Button, Card } from '@react-three/uikit-apfel' import { BoxIcon, GithubIcon, PlayIcon, ScanIcon } from '@react-three/uikit-lucide' -import { IfInSessionMode, useXRStore } from '@react-three/xr' +import { useXRStore } from '@react-three/xr' import { useControls } from 'leva' export const Toolbar = () => { @@ -11,51 +11,49 @@ export const Toolbar = () => { }) return showToolbar && ( - - + - - - - - - - - + + + + + + ) }