Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
routes specify if they spawn avatar or not
Browse files Browse the repository at this point in the history
  • Loading branch information
HexaField committed Jul 5, 2024
1 parent 3d1469d commit 09ddc40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/examplesRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ export const examples: RouteCategories = [
{
name: 'Immersive AR',
description: 'Immersive AR example',
entry: ImmersiveAR
entry: ImmersiveAR,
spawnAvatar: true
},
{
name: 'Immersive VR',
description: 'Immersive VR example',
entry: ImmersiveVR
entry: ImmersiveVR,
spawnAvatar: true
}
]
},
Expand Down
21 changes: 9 additions & 12 deletions src/sceneRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import '@etherealengine/engine/src/EngineModule'
import { GLTFAssetState } from '@etherealengine/engine/src/gltf/GLTFState'
import {
getMutableState,
none,
useHookstate,
useImmediateEffect,
useMutableState,
Expand All @@ -25,20 +26,13 @@ import { CameraOrbitComponent } from '@etherealengine/spatial/src/camera/compone
import { useFind } from '@etherealengine/spatial/src/common/functions/FeathersHooks'
import { InputComponent } from '@etherealengine/spatial/src/input/components/InputComponent'
import Button from '@etherealengine/ui/src/primitives/tailwind/Button'
import { HiChevronLeft, HiChevronRight, HiChevronUp, HiChevronDown } from 'react-icons/hi2'
import { HiChevronDown, HiChevronLeft, HiChevronRight, HiChevronUp } from 'react-icons/hi2'

type Metadata = {
export type RouteData = {
name: string
description: string
}

type SubRoute = Metadata & {
props: {}
}

export type RouteData = Metadata & {
entry: (...args: any[]) => any
sub?: SubRoute[]
spawnAvatar?: boolean
}

export type RouteCategories = Array<{ category: string; routes: RouteData[] }>
Expand Down Expand Up @@ -90,8 +84,6 @@ export const useRouteScene = (projectName = 'ee-development-test-suite', sceneNa
setComponent(viewerEntity, CameraOrbitComponent)
setComponent(viewerEntity, InputComponent)
getComponent(viewerEntity, CameraComponent).position.set(0, 3, 4)

SearchParamState.set('spectate', '')
}, [viewerEntity])

return sceneEntity
Expand Down Expand Up @@ -121,6 +113,11 @@ const Routes = (props: { routeCategories: RouteCategories; header: string }) =>
route.routes.filter((r) => getPathForRoute(route.category, r.name) === currentRoute)
)[0]

useEffect(() => {
if (selectedRoute.spawnAvatar) SearchParamState.set('spectate', '')
else SearchParamState.set('spectate', none)
}, [selectedRoute.spawnAvatar])

const Entry = selectedRoute && selectedRoute.entry

return (
Expand Down

0 comments on commit 09ddc40

Please sign in to comment.