This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from EtherealEngine/ir-1827-separate-physics-w…
…orld-per-scene Ir 1827 separate physics world per scene
- Loading branch information
Showing
127 changed files
with
7,814 additions
and
6,035 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
module.exports = { | ||
'fail-zero': false, | ||
parallel: true, | ||
spec: ['tests/**/*.test.ts'], | ||
failZero: false, | ||
parallel: false, | ||
require: [ | ||
'tests/mocha.env', // init env here | ||
'ts-node/register' | ||
'jsdom-global/register' | ||
], | ||
spec: [ | ||
'./**/*.test.ts', | ||
'./**/*.test.tsx' | ||
], | ||
extension: [ | ||
'ts' | ||
] | ||
}; | ||
'ts', | ||
'tsx' | ||
], | ||
bail: true, | ||
exit: true, | ||
recursive: true, | ||
jobs: '1', | ||
timeout: '60000' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from 'react' | ||
import { useHookstate, useImmediateEffect, useMutableState } from '@etherealengine/hyperflux' | ||
import Button from '@etherealengine/ui/src/primitives/tailwind/Button' | ||
import { endXRSession, requestXRSession } from '@etherealengine/spatial/src/xr/XRSessionFunctions' | ||
|
||
import { EmulatorSettings, emulatorStates } from './js/emulatorStates.js' | ||
import EmulatedDevice from './js/emulatedDevice.js' | ||
import { syncDevicePose } from './js/messenger.js' | ||
import Devtool from './jsx/app' | ||
import devtoolCSS from './styles/index.css?inline' | ||
import { overrideXR } from '../src/functions/xrBotHookFunctions.js' | ||
|
||
import 'bootstrap/dist/css/bootstrap.min.css' | ||
import 'bootstrap' | ||
import { XRState } from '@etherealengine/spatial/src/xr/XRState.js' | ||
|
||
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 flex-no-wrap flex-col h-full overflow-hidden m-0 bg-gray-900 text-gray-900 text-xs select-none h-full overflow-hidden" | ||
> | ||
<div className="flex flex-no-wrap flex-row h-10 bg-gray-800 text-gray-900 text-xs select-none"> | ||
<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.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}; |
Oops, something went wrong.