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

Commit

Permalink
Merge branch 'dev' into more-scene-ecs-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
HexaField committed Nov 23, 2023
2 parents 06c093a + 80846d1 commit 43e5782
Show file tree
Hide file tree
Showing 49 changed files with 384 additions and 707 deletions.
4 changes: 2 additions & 2 deletions packages/client-core/src/admin/adminRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import '@etherealengine/engine/src/EngineModule'
const $allowed = lazy(() => import('@etherealengine/client-core/src/admin/allowedRoutes'))

const AdminRoutes = () => {
const location = useLocation()
const _location = useLocation()
const admin = useHookstate(getMutableState(AuthState)).user

const allowedRoutes = useHookstate(getMutableState(AllowedAdminRoutesState))
Expand Down Expand Up @@ -70,7 +70,7 @@ const AdminRoutes = () => {

return (
<Dashboard>
<Suspense fallback={<LoadingCircle message={`Loading ${location.pathname.split('/')[2]}...`} />}>
<Suspense fallback={<LoadingCircle message={`Loading ${_location.pathname.split('/')[2]}...`} />}>
<Routes>
<Route path="/*" element={<$allowed />} />
{<Route path="/" element={<Analytics />} />}
Expand Down
9 changes: 7 additions & 2 deletions packages/client-core/src/admin/components/Analytics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ const Analytics = () => {
return (
<>
<div className={styles.dashboardCardsContainer}>
{analyticsServiceQueries.map((query) => (
<AnalyticsService name={query.type} colors={query.colors!} analyticsQueryMap={analyticsQueryMap} />
{analyticsServiceQueries.map((query, index) => (
<AnalyticsService
key={query.type + index}
name={query.type}
colors={query.colors!}
analyticsQueryMap={analyticsQueryMap}
/>
))}
</div>
<div className={styles.mt20px}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ const CreateInviteModal = ({ open, onClose }: Props) => {
locationId.set(e.target.value)
const location = adminLocations.find((location) => location.id === e.target.value)
if (location && location.sceneId) {
const sceneName = location.sceneId.split('/')
AdminSceneService.fetchAdminScene(sceneName[0], sceneName[1])
AdminSceneService.fetchAdminScene(location.sceneId)
}
}

Expand All @@ -155,8 +154,7 @@ const CreateInviteModal = ({ open, onClose }: Props) => {
if (instance) {
const location = adminLocations.find((location) => location.id === instance.locationId)
if (location) {
const sceneName = location.sceneId.split('/')
AdminSceneService.fetchAdminScene(sceneName[0], sceneName[1])
AdminSceneService.fetchAdminScene(location.sceneId)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ const UpdateInviteModal = ({ open, onClose, invite }: Props) => {
locationId.set(e.target.value)
const location = await Engine.instance.api.service(locationPath).get(e.target.value)
if (location && location.sceneId) {
const sceneName = location.sceneId.split('/')
AdminSceneService.fetchAdminScene(sceneName[0], sceneName[1])
AdminSceneService.fetchAdminScene(location.sceneId)
}
}

Expand All @@ -216,7 +215,7 @@ const UpdateInviteModal = ({ open, onClose, invite }: Props) => {

if (!location) return
const sceneName = location.sceneId.split('/')
AdminSceneService.fetchAdminScene(sceneName[0], sceneName[1])
AdminSceneService.fetchAdminScene(location.sceneId)
}

const handleUserChange = (e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const LocationTable = ({ className, search }: Props) => {
el,
id,
name: <a href={`/location/${transformLink(name)}`}>{name}</a>,
sceneId: <a href={`/studio/${sceneId}`}>{sceneId}</a>,
sceneId: <a href={`/studio/${sceneId.split('/')[0]}`}>{sceneId}</a>,
maxUsersPerInstance,
scene,
locationType,
Expand Down
11 changes: 5 additions & 6 deletions packages/client-core/src/admin/services/SceneService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,24 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/

import { SceneData, SceneMetadata } from '@etherealengine/common/src/interfaces/SceneInterface'
import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'
import { SceneDataType, scenePath } from '@etherealengine/engine/src/schemas/projects/scene.schema'
import { SceneDataType, SceneMetadataType, scenePath } from '@etherealengine/engine/src/schemas/projects/scene.schema'
import { defineState, getMutableState } from '@etherealengine/hyperflux'

export const SCENE_PAGE_LIMIT = 100

export const AdminSceneState = defineState({
name: 'AdminSceneState',
initial: () => ({
scenes: [] as Array<SceneMetadata>,
scenes: [] as Array<SceneMetadataType>,
skip: 0,
limit: SCENE_PAGE_LIMIT,
total: 0,
retrieving: false,
fetched: false,
updateNeeded: true,
lastFetched: Date.now(),
singleScene: { scene: {} } as SceneData
singleScene: { scene: {} } as SceneDataType
})
})

Expand All @@ -58,10 +57,10 @@ export const AdminSceneService = {
lastFetched: Date.now()
})
},
fetchAdminScene: async (projectName: string, sceneName: string) => {
fetchAdminScene: async (sceneKey: string) => {
const scene = await Engine.instance.api
.service(scenePath)
.get(null, { query: { project: projectName, name: sceneName, metadataOnly: false } })
.get(null, { query: { sceneKey: sceneKey, metadataOnly: false } })
getMutableState(AdminSceneState).merge({
singleScene: scene,
retrieving: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export const useLoadLocation = (props: { locationName: string }) => {
*/
useEffect(() => {
if (!locationState.currentLocation.location.sceneId.value) return
const [project, scene] = locationState.currentLocation.location.sceneId.value.split('/')
const scenePath = locationState.currentLocation.location.sceneId.value.split('/')
const project = scenePath[scenePath.length - 2]
const scene = scenePath[scenePath.length - 1].replace('.scene.json', '')
return SceneServices.setCurrentScene(project, scene)
}, [locationState.currentLocation.location.sceneId])
}
Expand Down
5 changes: 2 additions & 3 deletions packages/client-core/src/world/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ Ethereal Engine. All Rights Reserved.
*/

import config from '@etherealengine/common/src/config'
import { SceneJson } from '@etherealengine/common/src/interfaces/SceneInterface'
import { parseStorageProviderURLs } from '@etherealengine/engine/src/common/functions/parseSceneJSON'
import { SceneState } from '@etherealengine/engine/src/ecs/classes/Scene'
import { SceneID } from '@etherealengine/engine/src/schemas/projects/scene.schema'
import { SceneID, SceneJsonType } from '@etherealengine/engine/src/schemas/projects/scene.schema'

const fileServer = config.client.fileServer

export const loadSceneJsonOffline = async (projectName, sceneName) => {
const sceneID = `${projectName}/${sceneName}` as SceneID
const sceneData = (await (await fetch(`${fileServer}/projects/${sceneID}.scene.json`)).json()) as SceneJson
const sceneData = (await (await fetch(`${fileServer}/projects/${sceneID}.scene.json`)).json()) as SceneJsonType
const hasKTX2 = await fetch(`${fileServer}/projects/${sceneID}.thumbnail.ktx2`).then((res) => res.ok)
SceneState.loadScene(sceneID, {
scene: parseStorageProviderURLs(sceneData),
Expand Down
6 changes: 4 additions & 2 deletions packages/client/src/engine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ initializeBrowser()
API.createAPI()
pipeLogs(Engine.instance.api)

export default function ({ children }) {
export default function ({ children, tailwind = false }) {
const ref = createRef()
const { t } = useTranslation()
return (
return !tailwind ? (
<FullscreenContainer ref={ref}>
<Suspense fallback={<LoadingCircle message={t('common:loader.loadingClient')} />}>{children}</Suspense>
</FullscreenContainer>
) : (
children
)
}
48 changes: 0 additions & 48 deletions packages/client/src/engine_tw.tsx

This file was deleted.

24 changes: 13 additions & 11 deletions packages/client/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const App = () => {
<Routes>
{/* @todo - these are for backwards compatibility with non tailwind pages - they will be removed eventually */}
<Route
key={'admin'}
path={'/admin/*'}
key="admin"
path="/admin/*"
element={
<Suspense fallback={<LoadingCircle message={t('common:loader.starting')} />}>
<Engine>
Expand All @@ -60,8 +60,8 @@ const App = () => {
}
/>
<Route
key={'location'}
path={'/location/*'}
key="location"
path="/location/*"
element={
<Suspense fallback={<LoadingCircle message={t('common:loader.starting')} />}>
<Engine>
Expand All @@ -71,8 +71,8 @@ const App = () => {
}
/>
<Route
key={'studio'}
path={'/studio/*'}
key="studio"
path="/studio/*"
element={
<Suspense fallback={<LoadingCircle message={t('common:loader.starting')} />}>
<Engine>
Expand All @@ -82,8 +82,8 @@ const App = () => {
}
/>
<Route
key={'offline'}
path={'/offline/*'}
key="offline"
path="/offline/*"
element={
<Suspense fallback={<LoadingCircle message={t('common:loader.starting')} />}>
<Engine>
Expand All @@ -94,11 +94,13 @@ const App = () => {
/>
{/* This will become redundant and we can embed the TailwindPage directly */}
<Route
key={'default'}
path={'/*'}
key="default"
path="/*"
element={
<Suspense>
<TailwindPage />
<Engine tailwind>
<TailwindPage />
</Engine>
</Suspense>
}
/>
Expand Down
27 changes: 11 additions & 16 deletions packages/client/src/pages/_app_tw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,10 @@ import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'
import { getMutableState, useHookstate } from '@etherealengine/hyperflux'
import { loadWebappInjection } from '@etherealengine/projects/loadWebappInjection'

import EngineTW from '../engine_tw'
import PublicRouter, { CenteredLoadingCircle } from '../route/public_tw'
import { ThemeContextProvider } from '../themes/themeContext'

import 'daisyui/dist/full.css'
import { useTranslation } from 'react-i18next'
import 'tailwindcss/tailwind.css'
import '../themes/base.css'
import '../themes/components.css'
import '../themes/utilities.css'
Expand Down Expand Up @@ -101,19 +98,17 @@ const TailwindPage = () => {
}, [notistackRef.current])

return (
<EngineTW>
<ThemeContextProvider>
<SnackbarProvider
ref={notistackRef as any}
maxSnack={7}
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
action={defaultAction}
>
<AppPage />
<Debug />
</SnackbarProvider>
</ThemeContextProvider>
</EngineTW>
<ThemeContextProvider>
<SnackbarProvider
ref={notistackRef as any}
maxSnack={7}
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
action={defaultAction}
>
<AppPage />
<Debug />
</SnackbarProvider>
</ThemeContextProvider>
)
}

Expand Down
1 change: 0 additions & 1 deletion packages/client/src/pages/editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const EditorRouter = () => {
<Suspense fallback={<LoadingCircle message={t('common:loader.loadingEditor')} />}>
<PopupMenuInline />
<Routes>
<Route path=":projectName/:sceneName" element={<EditorPage />} />
<Route path=":projectName" element={<EditorPage />} />
<Route path="*" element={<ProjectPage />} />
</Routes>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
themes: ['default', 'dark', 'vaporwave'],
// daisyUI config (optional)
styled: true,
base: true,
base: false,
utils: true,
logs: false,
rtl: false,
Expand Down
54 changes: 0 additions & 54 deletions packages/common/src/interfaces/SceneInterface.ts

This file was deleted.

Loading

0 comments on commit 43e5782

Please sign in to comment.