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

Commit

Permalink
Merge branch 'dev' into IR-2746-Optimize-performance-of-webpages-when…
Browse files Browse the repository at this point in the history
…-not-rendering-3d-world
  • Loading branch information
HexaField committed Jun 25, 2024
2 parents 9d055c4 + e9c976d commit 708fddc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/benchmarksAllRoute.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/benchmarksRoute.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/examplesRoute.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
10 changes: 8 additions & 2 deletions src/sceneRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import { useLoadEngineWithScene, useNetwork } from '@etherealengine/client-core/
import { useLoadScene } from '@etherealengine/client-core/src/components/World/LoadLocationScene'
import { useEngineCanvas } from '@etherealengine/client-core/src/hooks/useEngineCanvas'
import '@etherealengine/client-core/src/world/LocationModule'
import { staticResourcePath } from '@etherealengine/common/src/schema.type.module'
import { Entity, getComponent, setComponent } from '@etherealengine/ecs'
import '@etherealengine/engine/src/EngineModule'
import { GLTFAssetState } from '@etherealengine/engine/src/gltf/GLTFState'
import { useHookstate, useImmediateEffect, useMutableState } from '@etherealengine/hyperflux'
import { EngineState } from '@etherealengine/spatial/src/EngineState'
import { CameraComponent } from '@etherealengine/spatial/src/camera/components/CameraComponent'
import { CameraOrbitComponent } from '@etherealengine/spatial/src/camera/components/CameraOrbitComponent'
import { useFind } from '@etherealengine/spatial/src/common/functions/FeathersHooks'
import { InputComponent } from '@etherealengine/spatial/src/input/components/InputComponent'

type Metadata = {
Expand Down Expand Up @@ -56,17 +59,20 @@ 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 | Entity>(undefined)
const viewerEntity = useMutableState(EngineState).viewerEntity.value

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(() => {
if (!viewerEntity) return
Expand Down

0 comments on commit 708fddc

Please sign in to comment.