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

Commit 4322560

Browse files
authored
Persistent Anchors (#7207)
1 parent 79990ff commit 4322560

10 files changed

Lines changed: 197 additions & 143 deletions

File tree

β€Žpackages/client-core/i18n/en/editor.jsonβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@
145145
"lbl-unload": "Unload",
146146
"lbl-reload": "Reload"
147147
},
148-
"vps-wayspot": {
149-
"name": "VPS Wayspot",
150-
"description": "Assign a VPS Wayspot",
151-
"lbl-name": "Wayspot Name"
148+
"persistent-anchor": {
149+
"name": "Persistent Anchor",
150+
"description": "Anchors this entity to a real life reference",
151+
"lbl-name": "Anchor Name"
152152
},
153153
"media": {
154154
"name": "Media",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react'
2+
import { useTranslation } from 'react-i18next'
3+
4+
import { useComponent } from '@xrengine/engine/src/ecs/functions/ComponentFunctions'
5+
import { PersistentAnchorComponent } from '@xrengine/engine/src/xr/XRAnchorComponents'
6+
7+
import InputGroup from '../inputs/InputGroup'
8+
import StringInput from '../inputs/StringInput'
9+
import NodeEditor from './NodeEditor'
10+
import { EditorComponentType, updateProperty } from './Util'
11+
12+
export const PersistentAnchorNodeEditor: EditorComponentType = (props) => {
13+
const { t } = useTranslation()
14+
15+
const anchor = useComponent(props.node.entity, PersistentAnchorComponent)
16+
17+
return (
18+
<NodeEditor
19+
{...props}
20+
name={t('editor:properties.persistent-anchor.name')}
21+
description={t('editor:properties.persistent-anchor.description')}
22+
>
23+
<InputGroup name="Volume" label={t('editor:properties.persistent-anchor.lbl-name')}>
24+
<StringInput value={anchor.name.value} onChange={updateProperty(PersistentAnchorComponent, 'name')} />
25+
</InputGroup>
26+
</NodeEditor>
27+
)
28+
}
29+
30+
export default PersistentAnchorNodeEditor

β€Žpackages/editor/src/components/properties/VPSWayspotNodeEditor.tsxβ€Ž

Lines changed: 0 additions & 30 deletions
This file was deleted.

β€Žpackages/editor/src/functions/PrefabEditors.tsxβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { WaterComponent } from '@xrengine/engine/src/scene/components/WaterCompo
3636
import { LightPrefabs } from '@xrengine/engine/src/scene/systems/LightSystem'
3737
import { ScenePrefabs } from '@xrengine/engine/src/scene/systems/SceneObjectUpdateSystem'
3838
import { TransformComponent } from '@xrengine/engine/src/transform/components/TransformComponent'
39-
import { VPSWayspotComponent } from '@xrengine/engine/src/xr/VPSComponents'
39+
import { PersistentAnchorComponent } from '@xrengine/engine/src/xr/XRAnchorComponents'
4040

4141
import ChairIcon from '@mui/icons-material/Chair'
4242

@@ -59,6 +59,7 @@ import ModelNodeEditor from '../components/properties/ModelNodeEditor'
5959
import MountPointNodeEditor from '../components/properties/MountPointNodeEditor'
6060
import OceanNodeEditor from '../components/properties/OceanNodeEditor'
6161
import ParticleEmitterNodeEditor from '../components/properties/ParticleEmitterNodeEditor'
62+
import PersistentAnchorNodeEditor from '../components/properties/PersistentAnchorNodeEditor'
6263
import PointLightNodeEditor from '../components/properties/PointLightNodeEditor'
6364
import PortalNodeEditor from '../components/properties/PortalNodeEditor'
6465
import PositionalAudioNodeEditor from '../components/properties/PositionalAudioNodeEditor'
@@ -73,7 +74,6 @@ import TransformPropertyGroup from '../components/properties/TransformPropertyGr
7374
import { EditorComponentType } from '../components/properties/Util'
7475
import VideoNodeEditor from '../components/properties/VideoNodeEditor'
7576
import VolumetricNodeEditor from '../components/properties/VolumetricNodeEditor'
76-
import VPSWayspotNodeEditor from '../components/properties/VPSWayspotNodeEditor'
7777
import WaterNodeEditor from '../components/properties/WaterNodeEditor'
7878

7979
export const EntityNodeEditor = new Map<Component, EditorComponentType>()
@@ -110,7 +110,7 @@ EntityNodeEditor.set(SplineComponent, SplineNodeEditor)
110110
EntityNodeEditor.set(EnvmapComponent, EnvMapEditor)
111111
EntityNodeEditor.set(EnvMapBakeComponent, EnvMapBakeNodeEditor)
112112
EntityNodeEditor.set(InstancingComponent, InstancingNodeEditor)
113-
EntityNodeEditor.set(VPSWayspotComponent, VPSWayspotNodeEditor)
113+
EntityNodeEditor.set(PersistentAnchorComponent, PersistentAnchorNodeEditor)
114114

115115
export const prefabIcons = {
116116
[LightPrefabs.ambientLight]: AmbientLightNodeEditor.iconComponent,

β€Žpackages/engine/src/xr/8thwall/XR8.tsβ€Ž

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
import { EngineRenderer } from '../../renderer/WebGLRendererSystem'
2222
import { SkyboxComponent } from '../../scene/components/SkyboxComponent'
2323
import { updateSkybox } from '../../scene/functions/loaders/SkyboxFunctions'
24-
import { VPSWayspotComponent } from '../VPSComponents'
24+
import { PersistentAnchorComponent } from '../XRAnchorComponents'
2525
import { endXRSession, requestXRSession } from '../XRSessionFunctions'
2626
import { XRAction, XRState } from '../XRState'
2727
import { XR8Pipeline } from './XR8Pipeline'
@@ -30,7 +30,7 @@ import { XR8Type } from './XR8Types'
3030
type XR8Assets = {
3131
xr8Script: HTMLScriptElement
3232
xrExtrasScript: HTMLScriptElement
33-
xrCoachingOverlayScript: HTMLScriptElement
33+
// xrCoachingOverlayScript: HTMLScriptElement
3434
}
3535

3636
function loadScript(url): Promise<HTMLScriptElement> {
@@ -48,10 +48,10 @@ function loadScript(url): Promise<HTMLScriptElement> {
4848
* @returns
4949
*/
5050
const initialize8thwall = async (): Promise<XR8Assets> => {
51-
const [xr8Script, xrExtrasScript, xrCoachingOverlayScript] = await Promise.all([
51+
const [xr8Script, xrExtrasScript /*, xrCoachingOverlayScript*/] = await Promise.all([
5252
loadScript(`https://apps.8thwall.com/xrweb?appKey=${config.client.key8thWall}`),
53-
loadScript(`https://cdn.8thwall.com/web/xrextras/xrextras.js`),
54-
loadScript(`https://cdn.8thwall.com/web/coaching-overlay/coaching-overlay.js`)
53+
loadScript(`https://cdn.8thwall.com/web/xrextras/xrextras.js`)
54+
// loadScript(`https://cdn.8thwall.com/web/coaching-overlay/coaching-overlay.js`)
5555
])
5656

5757
/** the global XR8 object will not exist immediately, so wait for it */
@@ -71,18 +71,18 @@ const initialize8thwall = async (): Promise<XR8Assets> => {
7171

7272
XR8 = globalThis.XR8
7373
XRExtras = globalThis.XRExtras
74-
VpsCoachingOverlay = globalThis.VpsCoachingOverlay
74+
// VpsCoachingOverlay = globalThis.VpsCoachingOverlay
7575

7676
return {
7777
xr8Script,
78-
xrExtrasScript,
79-
xrCoachingOverlayScript
78+
xrExtrasScript
79+
// xrCoachingOverlayScript
8080
}
8181
}
8282

8383
export let XR8: XR8Type
8484
export let XRExtras
85-
export let VpsCoachingOverlay
85+
// export let VpsCoachingOverlay
8686

8787
const initialize8thwallDevice = async (existingCanvas: HTMLCanvasElement | null, world: World) => {
8888
if (existingCanvas) {
@@ -161,7 +161,7 @@ const initialize8thwallDevice = async (existingCanvas: HTMLCanvasElement | null,
161161

162162
// if (enableVps) {
163163
// VpsCoachingOverlay.configure({
164-
// // wayspotName: vpsWayspotName // todo - support multiple wayspots, for now just use the nearest one
164+
// // persistentanchorName: vpsPersistentAnchorName // todo - support multiple persistentanchors, for now just use the nearest one
165165
// })
166166
// }
167167

@@ -210,6 +210,10 @@ class XRHitTestResultProxy {
210210
createAnchor = undefined
211211
}
212212

213+
class XRReferenceSpace {}
214+
215+
class XRHitTestSource {}
216+
213217
class XRSessionProxy extends EventDispatcher {
214218
readonly inputSources: XRInputSource[]
215219

@@ -218,12 +222,12 @@ class XRSessionProxy extends EventDispatcher {
218222
this.inputSources = inputSources
219223
}
220224
async requestReferenceSpace(type: 'local' | 'viewer') {
221-
const space = {}
222-
return space as XRReferenceSpace
225+
const space = new XRReferenceSpace()
226+
return space
223227
}
224228

225229
async requestHitTestSource(args: { space: XRReferenceSpace }) {
226-
const source = {}
230+
const source = new XRHitTestSource()
227231
return source as XRHitTestSource
228232
}
229233
}
@@ -269,7 +273,7 @@ class XRFrameProxy {
269273
}
270274

271275
const skyboxQuery = defineQuery([SkyboxComponent])
272-
const vpsQuery = defineQuery([VPSWayspotComponent])
276+
const vpsQuery = defineQuery([PersistentAnchorComponent])
273277

274278
export default async function XR8System(world: World) {
275279
let _8thwallScripts = null as XR8Assets | null
@@ -415,16 +419,16 @@ export default async function XR8System(world: World) {
415419
* session, changing the overrides, and entering the session again
416420
*/
417421
const vpsReactor = startReactor(function XR8VPSReactor() {
418-
const hasWayspot = useQuery(vpsQuery).length
422+
const hasPersistentAnchor = useQuery(vpsQuery).length
419423

420424
useEffect(() => {
421425
/** data oriented approach to overriding functions, check if it's already changed, and abort if as such */
422-
if (hasWayspot || using8thWall) {
426+
if (hasPersistentAnchor || using8thWall) {
423427
overrideXRSessionFunctions()
424428
} else {
425429
revertXRSessionFunctions()
426430
}
427-
}, [hasWayspot])
431+
}, [hasPersistentAnchor])
428432

429433
return null
430434
})
@@ -462,7 +466,7 @@ export default async function XR8System(world: World) {
462466
if (_8thwallScripts) {
463467
_8thwallScripts.xr8Script.remove()
464468
_8thwallScripts.xrExtrasScript.remove()
465-
_8thwallScripts.xrCoachingOverlayScript.remove()
469+
// _8thwallScripts.xrCoachingOverlayScript.remove()
466470
}
467471
if (cameraCanvas) cameraCanvas.remove()
468472
revertXRSessionFunctions()

β€Žpackages/engine/src/xr/8thwall/XR8Pipeline.tsβ€Ž

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Quaternion, Vector3 } from 'three'
33
import { dispatchAction } from '@xrengine/hyperflux'
44

55
import { World } from '../../ecs/classes/World'
6-
import { VPSActions } from '../VPSComponents'
6+
import { PersistentAnchorActions } from '../XRAnchorComponents'
77
import { XR8 } from './XR8'
88
import {
99
CameraPipelineModule,
@@ -44,17 +44,21 @@ export const XR8Pipeline = (world: World, cameraCanvas: HTMLCanvasElement): Came
4444

4545
const onWayspotFound = (event: WayspotFoundEvent) => {
4646
const { name, position, rotation } = event.detail
47-
dispatchAction(VPSActions.wayspotFound({ name, position: position as Vector3, rotation: rotation as Quaternion }))
47+
dispatchAction(
48+
PersistentAnchorActions.anchorFound({ name, position: position as Vector3, rotation: rotation as Quaternion })
49+
)
4850
}
4951

5052
const onWayspotUpdated = (event: WayspotUpdatedEvent) => {
5153
const { name, position, rotation } = event.detail
52-
dispatchAction(VPSActions.wayspotUpdated({ name, position: position as Vector3, rotation: rotation as Quaternion }))
54+
dispatchAction(
55+
PersistentAnchorActions.anchorUpdated({ name, position: position as Vector3, rotation: rotation as Quaternion })
56+
)
5357
}
5458

5559
const onWayspotLost = (event: WayspotLostEvent) => {
5660
const { name } = event.detail
57-
dispatchAction(VPSActions.wayspotLost({ name }))
61+
dispatchAction(PersistentAnchorActions.anchorLost({ name }))
5862
}
5963

6064
return {

β€Žpackages/engine/src/xr/VPSSystem.tsβ€Ž

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
Β (0)