From e9c976d2c9c8f2991428a0eb8413b5d2ef44282b Mon Sep 17 00:00:00 2001 From: HexaField Date: Fri, 21 Jun 2024 18:09:59 +1000 Subject: [PATCH] hack fix avatars always spawning and scenes not loading after adding cache busting --- src/benchmarksAllRoute.tsx | 2 +- src/benchmarksRoute.tsx | 2 +- src/examplesRoute.tsx | 2 +- src/sceneRoute.tsx | 11 ++++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/benchmarksAllRoute.tsx b/src/benchmarksAllRoute.tsx index 6bd8ff2..a048dab 100644 --- a/src/benchmarksAllRoute.tsx +++ b/src/benchmarksAllRoute.tsx @@ -1,4 +1,4 @@ -import '@etherealengine/client-core/src/world/LocationModule' +import '@etherealengine/engine/src/EngineModule' import { setComponent } from '@etherealengine/ecs' import React, { useEffect } from 'react' import { BenchmarkComponent } from './engine/Register' diff --git a/src/benchmarksRoute.tsx b/src/benchmarksRoute.tsx index cdff1ba..589d664 100644 --- a/src/benchmarksRoute.tsx +++ b/src/benchmarksRoute.tsx @@ -1,6 +1,6 @@ import React from 'react' -import '@etherealengine/client-core/src/world/LocationModule' +import '@etherealengine/engine/src/EngineModule' import AvatarBenchmarkEntry from './benchmarks/avatarBenchmark' import AvatarIKBenchmarkEntry from './benchmarks/avatarIKBenchmark' import HeapBenchmarkEntry from './benchmarks/heapBenchmark' diff --git a/src/examplesRoute.tsx b/src/examplesRoute.tsx index 1cf9b54..8a1b530 100644 --- a/src/examplesRoute.tsx +++ b/src/examplesRoute.tsx @@ -1,6 +1,6 @@ import React from 'react' -import '@etherealengine/client-core/src/world/LocationModule' +import '@etherealengine/engine/src/EngineModule' import AvatarMocapEntry from './examples/avatarMocap' import AvatarTestEntry from './examples/avatarTest' import ComponentExamplesRoute, { subComponentExamples } from './examples/componentExamples/componentExamples' diff --git a/src/sceneRoute.tsx b/src/sceneRoute.tsx index 95e22af..c927f3f 100644 --- a/src/sceneRoute.tsx +++ b/src/sceneRoute.tsx @@ -5,7 +5,7 @@ import React, { useEffect, useRef, useState } from 'react' import { useLoadEngineWithScene, useNetwork } from '@etherealengine/client-core/src/components/World/EngineHooks' import { useLoadScene } from '@etherealengine/client-core/src/components/World/LoadLocationScene' -import '@etherealengine/client-core/src/world/LocationModule' +import '@etherealengine/engine/src/EngineModule' import { Engine, Entity, getComponent, setComponent } from '@etherealengine/ecs' import { GLTFAssetState } from '@etherealengine/engine/src/gltf/GLTFState' import { useHookstate, useImmediateEffect, useMutableState } from '@etherealengine/hyperflux' @@ -13,6 +13,8 @@ import { CameraComponent } from '@etherealengine/spatial/src/camera/components/C import { CameraOrbitComponent } from '@etherealengine/spatial/src/camera/components/CameraOrbitComponent' import { InputComponent } from '@etherealengine/spatial/src/input/components/InputComponent' import { RendererComponent } from '@etherealengine/spatial/src/renderer/WebGLRendererSystem' +import { staticResourcePath } from '@etherealengine/common/src/schema.type.module' +import { useFind } from '@etherealengine/spatial/src/common/functions/FeathersHooks' type Metadata = { name: string @@ -55,16 +57,19 @@ export const useRouteScene = (projectName = 'ee-development-test-suite', sceneNa useLoadScene({ projectName: projectName, sceneName: sceneName }) useNetwork({ online: false }) useLoadEngineWithScene() + const sceneKey = `projects/${projectName}/${sceneName}` + const assetQuery = useFind(staticResourcePath, { query: { key: sceneKey, type: 'scene' } }) const gltfState = useMutableState(GLTFAssetState) const sceneEntity = useHookstate(undefined) useEffect(() => { - const sceneURL = `projects/${projectName}/${sceneName}` + if (!assetQuery.data[0]) return + const sceneURL = assetQuery.data[0].url if (!gltfState[sceneURL].value) return const entity = gltfState[sceneURL].value if (entity) sceneEntity.set(entity) - }, [gltfState]) + }, [assetQuery.data, gltfState]) useImmediateEffect(() => { const entity = Engine.instance.viewerEntity