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-1827-separate-physics-world-per-scene
Browse files Browse the repository at this point in the history
  • Loading branch information
HexaField committed Jun 27, 2024
2 parents d115101 + 7b93735 commit fec0caa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 36 deletions.
8 changes: 4 additions & 4 deletions public/scenes/Benchmarks.gltf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"bakeType": "Baked",
"resolution": 2048,
"refreshMode": "OnAwake",
"envMapOrigin": "https://localhost:8642/projects/default-project/default.envmap.ktx2",
"envMapOrigin": "__$project$__/default-project/default.envmap.ktx2",
"boxProjection": true
},
"EE_fog": {
Expand Down Expand Up @@ -211,8 +211,8 @@
"shadowMapType": 2
},
"EE_scene_settings": {
"thumbnailURL": "https://localhost:8642/projects/default-project/default.thumbnail.jpg",
"loadingScreenURL": "https://localhost:8642/projects/default-project/default.loadingscreen.ktx2",
"thumbnailURL": "__$project$__/default-project/public/scenes/default.thumbnail.jpg",
"loadingScreenURL": "__$project$__/default-project/public/scenes/default.loadingscreen.ktx2",
"primaryColor": "#38620D",
"backgroundColor": "rgb(214, 214, 211)",
"alternativeColor": "#376312",
Expand Down Expand Up @@ -254,7 +254,7 @@
"EE_skybox": {
"backgroundColor": 0,
"equirectangularPath": "",
"cubemapPath": "https://localhost:8642/projects/default-project/assets/skyboxsun25deg/",
"cubemapPath": "__$project$__/default-project/assets/skyboxsun25deg/",
"backgroundType": 1,
"skyboxProps": {
"turbidity": 10,
Expand Down
4 changes: 2 additions & 2 deletions public/scenes/Examples.gltf
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@
"shadowMapType": 2
},
"EE_scene_settings": {
"thumbnailURL": "__$project$__/default-project/default.thumbnail.jpg",
"loadingScreenURL": "__$project$__/default-project/default.loadingscreen.ktx2",
"thumbnailURL": "__$project$__/default-project/public/scenes/default.thumbnail.jpg",
"loadingScreenURL": "__$project$__/default-project/public/scenesdefault.loadingscreen.ktx2",
"primaryColor": "#38620D",
"backgroundColor": "rgb(214, 214, 211)",
"alternativeColor": "#376312",
Expand Down
44 changes: 14 additions & 30 deletions src/sceneRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ 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 { 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 { Engine, Entity, getComponent, setComponent } from '@etherealengine/ecs'
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'
import { RendererComponent } from '@etherealengine/spatial/src/renderer/WebGLRendererSystem'
import Button from '@etherealengine/ui/src/primitives/tailwind/Button'
import { HiChevronDoubleLeft, HiChevronDoubleRight } from 'react-icons/hi2'

Expand Down Expand Up @@ -64,6 +66,7 @@ export const useRouteScene = (projectName = 'ee-development-test-suite', sceneNa

const gltfState = useMutableState(GLTFAssetState)
const sceneEntity = useHookstate<undefined | Entity>(undefined)
const viewerEntity = useMutableState(EngineState).viewerEntity.value

useEffect(() => {
if (!assetQuery.data[0]) return
Expand All @@ -74,11 +77,11 @@ export const useRouteScene = (projectName = 'ee-development-test-suite', sceneNa
}, [assetQuery.data, gltfState])

useImmediateEffect(() => {
const entity = Engine.instance.viewerEntity
setComponent(entity, CameraOrbitComponent)
setComponent(entity, InputComponent)
getComponent(entity, CameraComponent).position.set(0, 0, 4)
}, [])
if (!viewerEntity) return
setComponent(viewerEntity, CameraOrbitComponent)
setComponent(viewerEntity, InputComponent)
getComponent(viewerEntity, CameraComponent).position.set(0, 0, 4)
}, [viewerEntity])

return sceneEntity
}
Expand All @@ -94,6 +97,8 @@ const Routes = (props: { routes: RouteData[]; header: string }) => {

const ref = useRef(null as null | HTMLDivElement)

useEngineCanvas(ref)

const onClick = (routeIndex: number) => {
setCurrentRoute(routeIndex)
setCurrentSubRoute(0)
Expand Down Expand Up @@ -126,29 +131,11 @@ const Routes = (props: { routes: RouteData[]; header: string }) => {
window.history.pushState(null, '', url.toString())
}, [currentRoute, currentSubRoute])

useEffect(() => {
if (!ref?.current) return

const canvas = getComponent(Engine.instance.viewerEntity, RendererComponent).renderer.domElement
canvas.parentElement?.removeChild(canvas)
ref.current.appendChild(canvas)

getComponent(Engine.instance.viewerEntity, RendererComponent).needsResize = true

const observer = new ResizeObserver(() => {
getComponent(Engine.instance.viewerEntity, RendererComponent).needsResize = true
})

observer.observe(ref.current)
return () => {
observer.disconnect()
}
}, [ref])

const selectedRoute = currentRoute !== null ? routes[currentRoute] : null
const selectedSub = selectedRoute && selectedRoute.sub && selectedRoute.sub[currentSubRoute]
const Entry = selectedRoute && selectedRoute.entry
const subProps = selectedSub ? selectedSub.props : {}

return (
<>
<style type="text/css">{styles.toString()}</style>
Expand All @@ -167,10 +154,7 @@ const Routes = (props: { routes: RouteData[]; header: string }) => {
)
}
/>
<div
className="NavBarContainer"
style={{ zIndex: '100', width: hidden.value ? '0%' : '' }}
>
<div className="NavBarContainer" style={{ zIndex: '100', width: hidden.value ? '0%' : '' }}>
<Header header={header} />
<div className="NavBarSelectionContainer">
{routes.map((route, index) => {
Expand Down

0 comments on commit fec0caa

Please sign in to comment.