Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IR-5702] Unit Test - Spatial XR coverage: System Executes #860

Draft
wants to merge 173 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
e59a25f
tst: Sketch files for all `spatial/XR` module unit tests
heysokam Oct 11, 2024
5f7015a
fmt: Standarize the names of some `XRComponents.ts` components
heysokam Oct 11, 2024
ace557a
tst: Temporarily disable the (wip) `VPSSystem` unit tests
heysokam Oct 11, 2024
4f12fd9
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Oct 30, 2024
c0db60b
tst: Move the `webxr-emulator` and `devtool` folders from `ir-bot`
heysokam Oct 31, 2024
a595339
tst: Apply changes from #583
heysokam Nov 1, 2024
8c549d8
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 1, 2024
9710ab6
fixes for webxr emulator tests
HexaField Nov 2, 2024
7223724
tst: Remove redundant todo note about the webxr test not passing
heysokam Nov 4, 2024
fc2640d
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 4, 2024
8f37d1b
tst: Add `webxr-emulator` to the `.prettierignore` list
heysokam Nov 4, 2024
405b472
tst: Add `webxr-emulator` to the eslint ignore list
heysokam Nov 4, 2024
29ab0a7
fmt: Remove deprecated access of `viewerEntity` from `Engine`
heysokam Nov 4, 2024
2ca4737
tst: Unit Tests for all static data of the `spatial/xr` module
heysokam Nov 4, 2024
59d9978
tst: Document the `VPSSystem` definition bug
heysokam Nov 4, 2024
9d0272b
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 4, 2024
bba083a
tst: Activate the VPSSystem tests. Import bug is gone
heysokam Nov 5, 2024
a5d4546
tst: Simplify WebXR test imports by adding `requestEmulatedXRSesssion`
heysokam Nov 5, 2024
9d61833
tst: Unit Tests for `XRSessionFunctions.ts` (phase 1)
heysokam Nov 5, 2024
1e3c6aa
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 5, 2024
083b0b5
tst: Unit Tests for `XRSessionFunctions.ts` (phase 2)
heysokam Nov 6, 2024
94ec5fd
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 6, 2024
6cfbaac
tst: Add the webxr-emulator folders to the tsconfig.exclude array
heysokam Nov 6, 2024
09935df
tst: Also add `emulator.ts` to the tsconfig.exclude array
heysokam Nov 6, 2024
06aba0e
fix: Accidental change to `XRSession.onSessionEnd` floor and origin
heysokam Nov 7, 2024
d0f7756
tst: Add `.style` property to the MockRenderer canvas
heysokam Nov 7, 2024
e196ff9
tst: Add `mockEmulatedXREngine` helper functions
heysokam Nov 7, 2024
c412ae1
tst: Unit Tests for `XRSessionFunctions.ts` (phase 3)
heysokam Nov 7, 2024
bb485fe
tst: Add VSCode `vitest run - spatial : Current File` debug launcher
heysokam Nov 7, 2024
e05831b
tst: Bugfix for `XRSessionFunctions.ts/onSessionEnd` unit tests
heysokam Nov 7, 2024
c92252a
tst: Unit Tests for `XRState.ts` (phase 1)
heysokam Nov 8, 2024
6f4882b
tst: Add `getViewerPose` function to `MockXRFrame`
heysokam Nov 8, 2024
75a5750
tst: Update `WebXR Emulator` test to use the helper functions
heysokam Nov 8, 2024
1733267
tst: Unit Tests for `XRState.ts` (phase 2)
heysokam Nov 8, 2024
fce887a
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 8, 2024
7a63b1d
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 13, 2024
2134dc5
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 13, 2024
db28b4a
tst: Fix errors on wrong imports
heysokam Nov 13, 2024
2727993
fmt: Remove deprecated `cameraEntity` access. Add `foveation` arg type
heysokam Nov 13, 2024
aeb6e6a
tst: Fix SingleFile VSCode debug runner launch command
heysokam Nov 14, 2024
cdd8fb5
tst: Unit Tests for `WebXRManager.ts` (phase 2)
heysokam Nov 14, 2024
39b153e
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 14, 2024
104fc1f
fix: Hookstate-202 triggered when calling `.setFoveation`
heysokam Nov 14, 2024
7aa12a9
fmt: Flatten the `XRPersistentAnchorSystem.execute` arrow pattern
heysokam Nov 14, 2024
5accfe0
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 15, 2024
1882641
tst: Fix assert helpers for #363
heysokam Nov 15, 2024
b0d4372
tst: Unit Tests for `XRPersistentAnchorSystem.ts` (phase 1)
heysokam Nov 15, 2024
b2515db
tst: Add MockXRAnchor to `MockXR.ts`
heysokam Nov 15, 2024
cfbad33
tst: Unit Tests for `XRPersistentAnchorSystem.ts` (phase 2)
heysokam Nov 15, 2024
8cecdb0
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 15, 2024
5668f92
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 16, 2024
acc29d3
fmt: Add typesafety hint to the result of `createPersitentAnchor`
heysokam Nov 16, 2024
ff2854a
tst: Add `requestPersistentHandle` prototype to `MockXRSpace`
heysokam Nov 16, 2024
8780c7a
tst: Unit Tests for `XRPersistentAnchorSystem.ts` (phase 3)
heysokam Nov 16, 2024
9a61b07
fmt: Remove deprecated Engine.instance access. Flatten arrow pattern
heysokam Nov 16, 2024
69957f5
tst: Attempt to fix `xrFrame.session` being undefined after mocking
heysokam Nov 16, 2024
0547b8d
tst: Unit Tests for `XRCameraViewSystem.ts`
heysokam Nov 16, 2024
42af423
tst: Unit Tests for `XRCameraSystem.ts` (phase 1)
heysokam Nov 16, 2024
dd5528b
tst: Static fields tests for most XR systems
heysokam Nov 16, 2024
d270a09
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 19, 2024
c096e46
tst: Unit Tests for `XRLightProbeSystem.ts` (phase 2)
heysokam Nov 19, 2024
889d6d6
tst: Unit Tests for `XRScenePlacementShaderSystem.ts` (phase 1)
heysokam Nov 19, 2024
469aff1
tst: Unit Tests for `XRSystem.ts` (phase 1)
heysokam Nov 19, 2024
10ee41b
tst: Unit Tests for `XR8.ts` (phase 1)
heysokam Nov 19, 2024
3eaba69
fmt: Expose `Wayspot*Event` functions as types from `XR8Types`
heysokam Nov 19, 2024
4c883af
fmt: Reorder the `XR8Pipeline.listeners` array to match the api list
heysokam Nov 19, 2024
a2dbb3b
tst: Unit Tests for `XR8Pipeline.ts` (phase 1)
heysokam Nov 19, 2024
7e3a72e
tst: Unit Tests for `XR8Pipeline.ts` (phase 2)
heysokam Nov 19, 2024
028243d
tst: Remove webxr-emulator from the branch. It is now on dev
heysokam Nov 20, 2024
09750d1
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 20, 2024
e817174
tst: Unit Tests for `XR8Pipeline.ts` (phase 3)
heysokam Nov 20, 2024
a1f0cfd
tst: Unit Tests for `XRAnchorSystem.ts` (phase 1)
heysokam Nov 20, 2024
f757b90
fmt: Remove deprecated use of `Engine.instance`
heysokam Nov 20, 2024
c8d5150
tst: Unit Tests for `XR8WebXRProxy.ts` (phase 1)
heysokam Nov 20, 2024
698781a
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 20, 2024
b478740
tst: Reorganize some todo groups
heysokam Nov 20, 2024
2dfee01
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 21, 2024
6ce5cd9
tst: Move `getIncomingAction` from XR8Pipeline to a `tests/util` file
heysokam Nov 22, 2024
e95bdac
tst: Sketch for `getXRSessionEventtTargetData` helper function
heysokam Nov 22, 2024
b47484d
tst: Unit Tests for `XRSessionFunctions.ts` (phase 4)
heysokam Nov 22, 2024
08403e7
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 22, 2024
81bce7e
tst: Fix `deviceDefinition` incorrectly assigned to `device`
heysokam Nov 23, 2024
50baae6
tst: Unit Tests for `XRSessionFunctions.ts` (phase 5)
heysokam Nov 23, 2024
627a1c3
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 23, 2024
af7782c
tst: Fix unnecessary double quotes
heysokam Nov 23, 2024
33b8dd9
fmt: Remove deprecated usage of `Engine.instance.localFloorEntity`
heysokam Nov 23, 2024
f06a86e
tst: Unit Tests for `XRDetectedMeshComponent.ts` (phase 2)
heysokam Nov 23, 2024
1ff8522
tst: Unit Tests for `XRDetectedPlaneComponent.ts` (phase 2)
heysokam Nov 23, 2024
fccc42f
fmt: Remove deprecated usage of `Engine.instance`
heysokam Nov 26, 2024
145713e
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 26, 2024
ae3b808
fmt: Rename/Group Dollhouse module scope constants for clarity
heysokam Nov 26, 2024
ff2df74
fmt: Change `XRAnchorComponent` to optional getter at `updateAnchor`
heysokam Nov 26, 2024
43a100c
tst: Unit Tests for `XRAnchorSystem.ts` (phase 2)
heysokam Nov 26, 2024
f5d1a74
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 26, 2024
fdb9c1a
tst: Unit Tests for `XRAnchorSystem.ts` (phase 3)
heysokam Nov 27, 2024
151dd0c
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Nov 27, 2024
9f5b233
fmt: Flatten conditionals at `updateDepthMaterials` & `updateUniforms`
heysokam Nov 27, 2024
b78c5ce
tst: List of missing todo cases for `WebXRManager.ts`
heysokam Nov 27, 2024
72a4894
tst: List of missing todo cases for `XRDepthOcclussion.ts`
heysokam Nov 27, 2024
61601c0
tst: List of missing todo cases for `XRDetectedMeshSystem.ts`
heysokam Nov 27, 2024
20a33a6
tst: List of missing todo cases for `XRState.ts`
heysokam Nov 27, 2024
ac46357
fmt: Flatten the `scope.setSession` function with clause guard
heysokam Nov 27, 2024
d4ee9ce
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 2, 2024
4c4b190
tst: Unit Tests for `XRDepthOcclusion.ts` (phase 2)
heysokam Dec 2, 2024
303fb0e
tst: Unit Tests for `XRDepthOcclusion.ts` (phase 3)
heysokam Dec 4, 2024
ca1b17a
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 4, 2024
0744679
tst: Unit Tests for `XRDepthOcclusion.ts` (phase 4)
heysokam Dec 4, 2024
345c59b
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 4, 2024
74e000b
fmt: Export functions as `XRDetectedMeshSystemFunctions`
heysokam Dec 5, 2024
8cfd315
tst: Unit Tests for `XRDetectedMeshSystem.ts` (phase 2)
heysokam Dec 5, 2024
e7f3d2b
tst: Unit Tests for `XRDetectedMeshSystem.ts` (phase 3)
heysokam Dec 5, 2024
7520a78
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 5, 2024
e03267a
tst: Unit Tests for `XRState.ts` (phase 3)
heysokam Dec 5, 2024
74da4f5
fmt: Split the `setSession` scope function to make it testable
heysokam Dec 5, 2024
d4d3123
Revert "fmt: Split the `setSession` scope function to make it testable"
heysokam Dec 5, 2024
870800e
tst: Unit Tests for `WebXRManager.ts` (phase 3)
heysokam Dec 5, 2024
bfda79a
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 5, 2024
c4f911d
fmt: Split the WebXRManager factory members into dedicated functions
heysokam Dec 6, 2024
435b3fc
tst: Unit Tests for `WebXRManager.ts` (phase 4)
heysokam Dec 6, 2024
60a9798
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 6, 2024
ff3374f
fmt: Improve the WebXRManager factory function setSession section
heysokam Dec 6, 2024
33eeb26
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 6, 2024
d6ccf64
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 9, 2024
cc816e4
Revert "fmt: Improve the WebXRManager factory function setSession sec…
heysokam Dec 10, 2024
fcaa04b
Revert "fmt: Split the WebXRManager factory members into dedicated fu…
heysokam Dec 10, 2024
661fbbb
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 10, 2024
7a3138b
tst: Add `setRenderTarget` to `MockRenderer`
heysokam Dec 10, 2024
0208ba3
fmt: Rename `scope` to `manager` for clarity and add type hints
heysokam Dec 10, 2024
5d5a53d
tst: Unit Tests for `WebXRManager.ts` (phase 5) (Multi-func refactor)
heysokam Dec 10, 2024
3023013
tst: Fix eslint error for `no-extra-boolean-call` on `XRState.test.ts`
heysokam Dec 10, 2024
5556229
tst: Unit Tests for `WebXRManager.ts` (phase 6)
heysokam Dec 10, 2024
579d517
tst: Engine init before/after block for each function separately
heysokam Dec 10, 2024
4e677e2
fmt: Call all WebXRManagerFunctions from the exported object
heysokam Dec 10, 2024
283c6a2
tst: Unit Tests for `WebXRManager.ts` (phase 7)
heysokam Dec 10, 2024
4edd06c
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 10, 2024
8beeaa1
fmt: Simplify the `createRenderTargetLegacy` function
heysokam Dec 10, 2024
d37aa11
tst: Fix tests for `setSession` not waiting for its completion
heysokam Dec 10, 2024
cf83f9c
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 10, 2024
cbc1da2
tst: Unit Tests for `WebXRManager.ts` (phase 8) (missing statements)
heysokam Dec 11, 2024
bd2ec60
fix: Stranded `this.` call inside the `WebXRManager` factory function
heysokam Dec 11, 2024
2f8e2f7
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 11, 2024
405dc0c
tst: Unit Tests for `WebXRManager.ts` (phase 9) (simplify statements)
heysokam Dec 11, 2024
1180384
tst: Export XREmulator helpers as an object. Add `getXRWebGLLayerData`
heysokam Dec 11, 2024
1b540f3
tst: Unit Tests for `WebXRManager.ts` (phase 10)
heysokam Dec 11, 2024
5115920
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 11, 2024
9ace077
tst: Unit Tests for `WebXRManager.ts` (phase 11)
heysokam Dec 11, 2024
7dd1e84
tst: Add `XRWebGLBinding` polyfill and mock
heysokam Dec 12, 2024
3c0e66b
tst: Unit Tests for `WebXRManager.ts` (phase 12)
heysokam Dec 12, 2024
331d79d
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 12, 2024
58adea3
tst: Improve the `XRWebGLBinding` polyfill mock
heysokam Dec 12, 2024
a8ad4f9
tst: Unit Tests for `WebXRManager.ts` (phase 13)
heysokam Dec 12, 2024
8a1eced
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 12, 2024
f01370e
tst: Unit Tests for `WebXRManager.ts` (phase 14)
heysokam Dec 12, 2024
0e02b64
tst: Add missing `XRSession` assignment on the XREngine mock
heysokam Dec 12, 2024
5433aaa
tst: Fixes for todo tests at `XRPersistentAnchorSystem`
heysokam Dec 13, 2024
6a70933
tst: Add `immersive-ar` to the list of supported WebXR emulated modes
heysokam Dec 13, 2024
371d9dd
tst: Unit Tests for `XRSessionFunctions.ts` (phase 6) (todo fixes)
heysokam Dec 13, 2024
a358ba7
tst: Note about an 8thWall-only test case
heysokam Dec 13, 2024
c723cf8
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 13, 2024
594f832
tst: Add helper for getting the last dispatched action from history
heysokam Dec 13, 2024
127209e
tst: Unit Tests for `XRSessionFunctions.ts` (phase 7)
heysokam Dec 13, 2024
5d20d2d
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 17, 2024
916744c
Merge branch 'dev' into IR-3427-unit-test-XR-coverage-to-80
heysokam Dec 18, 2024
84381bb
tst: Skip note for `XRCameraViewSystem`
heysokam Dec 18, 2024
2a7b641
tst: Statements for `XRDepthOcclusionSystem` unit tests
heysokam Dec 18, 2024
e9102df
tst: Statements for `XRHapticsSystem` unit tests
heysokam Dec 18, 2024
a5fea1d
tst: Statements for `XRLightProbeSystem` unit tests
heysokam Dec 19, 2024
ac49774
tst: Statements for `XRDetectedMeshSystem` unit tests
heysokam Dec 19, 2024
3fb70fc
fmt: Remove deprecated usage of `Engine.instance`
heysokam Dec 19, 2024
202bbd4
tst: Statements for `XRCameraSystem` unit tests
heysokam Dec 19, 2024
84e6665
fmt: Prefix module-scope variables at `XRCameraSystem.ts` with `_`
heysokam Dec 19, 2024
2c4da38
tst: Statements for `XRSystem` unit tests
heysokam Dec 19, 2024
1f23889
tst: Statements for `XRAnchorSystem` unit tests
heysokam Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tst: Move the webxr-emulator and devtool folders from ir-bot
  • Loading branch information
heysokam committed Oct 31, 2024
commit c0db60be9236be01d20dffcd080bafeff9691e6f
102 changes: 102 additions & 0 deletions packages/spatial/tests/webxr/devtool/EmulatorDevtools.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
CPAL-1.0 License

The contents of this file are subject to the Common Public Attribution License
Version 1.0. (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://github.com/ir-engine/ir-engine/blob/dev/LICENSE.
The License is based on the Mozilla Public License Version 1.1, but Sections 14
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
Exhibit A has been modified to be consistent with Exhibit B.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
specific language governing rights and limitations under the License.

The Original Code is Infinite Reality Engine.

The Original Developer is the Initial Developer. The Initial Developer of the
Original Code is the Infinite Reality Engine team.

All portions of the code written by the Infinite Reality Engine team are Copyright © 2021-2023
Infinite Reality Engine. All Rights Reserved.
*/

import { useHookstate, useImmediateEffect, useMutableState } from '@ir-engine/hyperflux'
import { endXRSession, requestXRSession } from '@ir-engine/spatial/src/xr/XRSessionFunctions'
import Button from '@ir-engine/ui/src/primitives/tailwind/Button'
import React from 'react'

import { overrideXR } from '../src/functions/xrBotHookFunctions.js'
import EmulatedDevice from './js/emulatedDevice.js'
import { EmulatorSettings, emulatorStates } from './js/emulatorStates.js'
import { syncDevicePose } from './js/messenger.js'
import Devtool from './jsx/app'
import devtoolCSS from './styles/index.css?inline'

import { XRState } from '@ir-engine/spatial/src/xr/XRState.js'
import 'bootstrap'
import 'bootstrap/dist/css/bootstrap.min.css'

const setup = async (mode: 'immersive-vr' | 'immersive-ar') => {
await overrideXR({ mode })
await EmulatorSettings.instance.load()
const device = new EmulatedDevice()
device.on('pose', syncDevicePose)
;(emulatorStates as any).emulatedDevice = device

return device
}

export const EmulatorDevtools = (props: { mode: 'immersive-vr' | 'immersive-ar' }) => {
const xrState = useMutableState(XRState)
const xrActive = xrState.sessionActive.value && !xrState.requestingSession.value

const deviceState = useHookstate(null as null | EmulatedDevice)
useImmediateEffect(() => {
setup(props.mode).then((device) => {
deviceState.set(device)
})
}, [])

const toggleXR = async () => {
if (xrActive) {
endXRSession()
} else {
requestXRSession({ mode: props.mode })
}
}

const togglePlacement = () => {
if (xrState.scenePlacementMode.value !== 'placing') {
xrState.scenePlacementMode.set('placing')
xrState.sceneScaleAutoMode.set(false)
xrState.sceneScaleTarget.set(0.1)
} else {
xrState.scenePlacementMode.set('placed')
}
}

return (
<>
<style type="text/css">{devtoolCSS.toString()}</style>
<div
id="devtools"
className="flex-no-wrap m-0 flex h-full h-full select-none flex-col overflow-hidden overflow-hidden bg-gray-900 text-xs text-gray-900"
>
<div className="flex-no-wrap flex h-10 select-none flex-row bg-gray-800 text-xs text-gray-900">
<Button className="my-1 ml-auto mr-6 px-10" onClick={toggleXR} disabled={xrState.requestingSession.value}>
{(xrActive ? 'Exit ' : 'Enter ') + (props.mode === 'immersive-ar' ? 'AR' : 'VR')}
</Button>
{props.mode === 'immersive-ar' && (
<Button className="my-1 ml-auto mr-6 px-10" onClick={togglePlacement} disabled={!xrActive}>
Place Scene
</Button>
)}
</div>
{deviceState.value && <Devtool device={deviceState.value} />}
</div>
</>
)
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
60 changes: 60 additions & 0 deletions packages/spatial/tests/webxr/devtool/js/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* Events triggered by the emulator UI and sent to the content script
*/
export const EMULATOR_ACTIONS = {
HEADSET_POSE_CHANGE: 'ea-headset-pose-change',
CONTROLLER_POSE_CHANGE: 'ea-controller-pose-change',
CONTROLLER_VISIBILITY_CHANGE: 'ea-controller-visibility-change',
BUTTON_STATE_CHANGE: 'ea-button-state-change',
ANALOG_VALUE_CHANGE: 'ea-analog-value-change',
DEVICE_TYPE_CHANGE: 'ea-device-type-change',
STEREO_TOGGLE: 'ea-stereo-toggle',
KEYBOARD_EVENT: 'ea-keyboard-event',
EXIT_IMMERSIVE: 'ea-exit-immersive',
ROOM_DIMENSION_CHANGE: 'ea-room-dimension-change',
EXCLUDE_POLYFILL: 'ea-exclude-polyfill',
INPUT_MODE_CHANGE: 'ea-input-mode-change',
HAND_POSE_CHANGE: 'ea-hand-pose-change',
HAND_VISIBILITY_CHANGE: 'ea-hand-visibility-change',
PINCH_VALUE_CHANGE: 'ea-pinch-value-change',
USER_OBJECTS_CHANGE: 'ea-user-objects-change',
};

/**
* Events triggered by the content script and caught and processed by the custom WebXR Polyfill
*/
export const POLYFILL_ACTIONS = EMULATOR_ACTIONS
// {
// HEADSET_POSE_CHANGE: 'pa-headset-pose-change',
// CONTROLLER_POSE_CHANGE: 'pa-controller-pose-change',
// CONTROLLER_VISIBILITY_CHANGE: 'pa-controller-visibility-change',
// BUTTON_STATE_CHANGE: 'pa-button-state-change',
// ANALOG_VALUE_CHANGE: 'pa-analog-value-change',
// DEVICE_TYPE_CHANGE: 'pa-device-type-change',
// STEREO_TOGGLE: 'pa-stereo-toggle',
// KEYBOARD_EVENT: 'pa-keyboard-event',
// EXIT_IMMERSIVE: 'pa-exit-immersive',
// DEVICE_INIT: 'pa-device-init',
// ROOM_DIMENSION_CHANGE: 'pa-room-dimension-change',
// INPUT_MODE_CHANGE: 'pa-input-mode-change',
// HAND_POSE_CHANGE: 'pa-hand-pose-change',
// HAND_VISIBILITY_CHANGE: 'pa-hand-visibility-change',
// PINCH_VALUE_CHANGE: 'pa-pinch-value-change',
// USER_OBJECTS_CHANGE: 'pa-user-objects-change',
// };

/**
* Events triggered from the client side that are caught by the content script and then relayed back to the emulator side
*/
export const CLIENT_ACTIONS = {
ENTER_IMMERSIVE: 'ca-enter-immersive',
EXIT_IMMERSIVE: 'ca-exit-immersive',
PING: 'ca-ping',
};
141 changes: 141 additions & 0 deletions packages/spatial/tests/webxr/devtool/js/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

export const PRESS_AND_RELEASE_DURATION = 250;

export const BUTTON_POLYFILL_INDEX_MAPPING = {
joystick: 0,
trigger: 1,
grip: 2,
button1: 3,
button2: 4,
};

export const DEVICE = {
HEADSET: '0',
INPUT_RIGHT: '2',
INPUT_LEFT: '3',
};

export const OBJECT_NAME = {};
OBJECT_NAME[DEVICE.HEADSET] = 'headset';
OBJECT_NAME[DEVICE.INPUT_LEFT] = 'left-controller';
OBJECT_NAME[DEVICE.INPUT_RIGHT] = 'right-controller';

export const DEFAULT_TRANSFORMS = {};
DEFAULT_TRANSFORMS[DEVICE.HEADSET] = {
position: [0, 1.7, 0],
rotation: [0, 0, 0, 'XYZ'],
};
DEFAULT_TRANSFORMS[DEVICE.INPUT_RIGHT] = {
position: [0.25, 1.5, -0.4],
rotation: [0, 0, 0, 'XYZ'],
};
DEFAULT_TRANSFORMS[DEVICE.INPUT_LEFT] = {
position: [-0.25, 1.5, -0.4],
rotation: [0, 0, 0, 'XYZ'],
};

export const CONTROLLER_STRINGS = {};
CONTROLLER_STRINGS[DEVICE.INPUT_LEFT] = {
name: 'left-controller',
displayName: 'Left Controller',
handedness: 'left',
button1: 'ButtonX',
button2: 'ButtonY',
};
CONTROLLER_STRINGS[DEVICE.INPUT_RIGHT] = {
name: 'right-controller',
displayName: 'Right Controller',
handedness: 'right',
button1: 'ButtonA',
button2: 'ButtonB',
};

export const HAND_STRINGS = {};
HAND_STRINGS[DEVICE.INPUT_LEFT] = {
name: 'left-hand',
displayName: 'Left Hand',
handedness: 'left',
};
HAND_STRINGS[DEVICE.INPUT_RIGHT] = {
name: 'right-hand',
displayName: 'Right Hand',
handedness: 'right',
};

export const KEYBOARD_CONTROL_MAPPING = {
left: {
joystickLeft: 'a',
joystickRight: 'd',
joystickForward: 'w',
joystickBackward: 's',
trigger: 'e',
grip: 'q',
button1: 'x',
button2: 'z',
joystick: 'c',
},
right: {
joystickLeft: 'ArrowLeft',
joystickRight: 'ArrowRight',
joystickForward: 'ArrowUp',
joystickBackward: 'ArrowDown',
trigger: 'Enter',
grip: 'Shift',
button1: "'",
button2: '/',
joystick: '.',
},
};

export const GAMEPAD_ID_TO_INPUT_ID_MAPPING = {
3: 'joystick',
5: 'button2',
4: 'button1',
0: 'trigger',
1: 'grip',
};

export const SEMANTIC_LABELS = {
Desk: 'desk',
Couch: 'couch',
Floor: 'floor',
Ceiling: 'ceiling',
Wall: 'wall',
Door: 'door',
Window: 'window',
Table: 'table',
Shelf: 'shelf',
Bed: 'bed',
Screen: 'screen',
Lamp: 'lamp',
Plant: 'plant',
WallArt: 'wall art',
Other: 'other',
};

export const TRIGGER_MODES = ['slow', 'normal', 'fast', 'turbo'];

export const TRIGGER_CONFIG = {
slow: {
interval: 20,
holdTime: 100,
},
normal: {
interval: 10,
holdTime: 50,
},
fast: {
interval: 5,
holdTime: 10,
},
turbo: {
interval: 1,
holdTime: 1,
},
};
Loading
Loading