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

Commit

Permalink
Merge pull request #63 from EtherealEngine/refactor-xr-lights
Browse files Browse the repository at this point in the history
refactor xr lights
  • Loading branch information
HexaField authored Nov 23, 2023
2 parents fc1095b + 0329c32 commit 5c52742
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
29 changes: 13 additions & 16 deletions examples/XRLightEstimation.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import React, { useEffect } from 'react'
import { Mesh, MeshStandardMaterial, SphereGeometry } from 'three'

import { MediaIconsBox } from '@etherealengine/client-core/src/components/MediaIconsBox'
import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'
import { XRLightProbeState } from '@etherealengine/engine/src/xr/XRLightProbeSystem'
import { getMutableState, useHookstate } from '@etherealengine/hyperflux'

import { useLocationSpawnAvatar } from '@etherealengine/client-core/src/components/World/EngineHooks'
import { getComponent, setComponent } from '@etherealengine/engine/src/ecs/functions/ComponentFunctions'
import { createEntity, removeEntity } from '@etherealengine/engine/src/ecs/functions/EntityFunctions'
import { addObjectToGroup } from '@etherealengine/engine/src/scene/components/GroupComponent'
import { NameComponent } from '@etherealengine/engine/src/scene/components/NameComponent'
import { VisibleComponent } from '@etherealengine/engine/src/scene/components/VisibleComponent'
import { TransformComponent } from '@etherealengine/engine/src/transform/components/TransformComponent'
import { Template } from './utils/template'

export const LightProbe = () => {
const xrLightProbeState = useHookstate(getMutableState(XRLightProbeState).environment)
const xrLightProbeState = useHookstate(getMutableState(XRLightProbeState))

useEffect(() => {
if (!xrLightProbeState.value) return

// const entity = createEntity()
const entity = createEntity()

const ballGeometry = new SphereGeometry(0.5, 32, 32)
const ballMaterial = new MeshStandardMaterial({
Expand All @@ -25,16 +29,12 @@ export const LightProbe = () => {
})
const ballMesh = new Mesh(ballGeometry, ballMaterial)

Engine.instance.scene.add(ballMesh)
// ballGroup.add(ballMesh);

// const outlineMesh = new Mesh(isEstimatingLight.geometry.value, new MeshBasicMaterial({ wireframe: true }))
// addObjectToGroup(entity, outlineMesh)
// setComponent(entity, VisibleComponent)
// setComponent(entity, NameComponent, 'Plane ' + isEstimatingLight.plane.orientation.value)
addObjectToGroup(entity, ballMesh)
getComponent(entity, TransformComponent).position.set(0, 2, 0)
setComponent(entity, VisibleComponent)
setComponent(entity, NameComponent, 'Light Estimation Helper')
return () => {
// removeObjectFromGroup(entity, outlineMesh)
// removeComponent(entity, VisibleComponent)
removeEntity(entity)
}
}, [xrLightProbeState])

Expand All @@ -46,9 +46,6 @@ export default function XRLightEstimation() {
return (
<>
<Template />
<div style={{ pointerEvents: 'all' }}>
<MediaIconsBox />
</div>
<LightProbe />
</>
)
Expand Down
3 changes: 0 additions & 3 deletions examples/XRMeshes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ export default function AvatarBenchmarking() {
return (
<>
<Template />
<div style={{ pointerEvents: 'all' }}>
<MediaIconsBox />
</div>
<QueryReactor Components={[XRDetectedPlaneComponent]} ChildEntityReactor={DetectedPlanes} />
<QueryReactor Components={[XRDetectedMeshComponent]} ChildEntityReactor={DetectedMeshes} />
</>
Expand Down
3 changes: 0 additions & 3 deletions examples/XRSuite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ export default function XRSuite() {
return (
<>
<Template />
<div style={{ pointerEvents: 'all' }}>
<MediaIconsBox />
</div>
<QueryReactor Components={[XRDetectedPlaneComponent]} ChildEntityReactor={DetectedPlanes} />
<QueryReactor Components={[XRDetectedMeshComponent]} ChildEntityReactor={DetectedMeshes} />
<LightProbe />
Expand Down
15 changes: 14 additions & 1 deletion examples/utils/template.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React, { useEffect } from 'react'

import { ARPlacement } from '@etherealengine/client-core/src/components/ARPlacement'
import { MediaIconsBox } from '@etherealengine/client-core/src/components/MediaIconsBox'
import { Shelves } from '@etherealengine/client-core/src/components/Shelves'
import { useLoadEngineWithScene, useOfflineNetwork } from '@etherealengine/client-core/src/components/World/EngineHooks'
import { useLoadScene } from '@etherealengine/client-core/src/components/World/LoadLocationScene'
import { XRLoading } from '@etherealengine/client-core/src/components/XRLoading'
import { AvatarService } from '@etherealengine/client-core/src/user/services/AvatarService'

export function Template(props: { projectName?: string; sceneName?: string }) {
Expand All @@ -13,5 +17,14 @@ export function Template(props: { projectName?: string; sceneName?: string }) {
AvatarService.fetchAvatarList()
}, [])

return <></>
return (
<>
<div style={{ pointerEvents: 'all' }}>
<Shelves />
<ARPlacement />
<XRLoading />
<MediaIconsBox />
</div>
</>
)
}
2 changes: 2 additions & 0 deletions examplesRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react'
import { Route, Routes } from 'react-router-dom'

import '@etherealengine/client-core/src/world/LocationModule'

const buttonStyle = {
width: 'auto',
height: '100%',
Expand Down

0 comments on commit 5c52742

Please sign in to comment.