aframe-desktop-vr-controller
v0.1.3
Published
Simulates a VR controller on the desktop, controllable using mouse & keyboard.
Downloads
10
Maintainers
Readme
desktop-vr-controller
When entering VR on a desktop system with no actual VR headset / controllers attached, simulates a VR controller on the desktop, controllable using mouse & keyboard.
The simulated controller is always an Oculus Quest 2 controller.
Controls
The component only has an effect on desktop systems with no actual VR headset / controllers attached. On a VR headset, or a desktop system with a VR headset / controllers attached, it should have no effect.
Contextual prompts appear next to the controller, showing the available controls.
The controller can be moved and rotated using the mouse:
- left button + drag to move left/right and up/down
- right button + drag to pitch and yaw
- roll mouse wheel while holding left or right button to move in / out
- middle mouse button + drag to roll
Buttons can be pressed using the keyboard:
- Left shift / left control for left grip and trigger
- Right shift / right control for right grip and trigger
- X & Y for X & Y buttons (on left controller)
- V & B for A & B buttons (on right controller) - not e that V is used instead of A to avoid overlap with WASD
Thumbsticks can be controlled as follows:
- Hold down 1 or 2 to engage thumbstick for the left or right controller
- A thumbstick controller will appear on-screen at the current mouse location. Move the mouse to move the thumbstick.
- Left or right click can be used to click the thumbstick.
The Enter key can be used to lock any controller button in the down position. This is particularly useful to lock thumbstick activation, and can also be useful to simulate holding down grip or trigger.
Locked buttons can be released by pressing and releasing the corresponding key.
On mobile devices, including the desktop-vr-controller component will cause a simulated VR controller to appear, but it will not be usable.
Schema
None. Currently there are no configurable settings.
There's lots of settings that could be usefully configurable, and hopefully will be in a future version
Installation
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/desktop-vr-controller.min.js"></script>
Or via npm
npm install aframe-desktop-vr-controller
then in your code...
if (!AFRAME.components['desktop-vr-controller']) require('aframe-desktop-vr-controller')
(the if
test avoids conflicts with other npm packages that may also use aframe-desktop-vr-controller
)
Usage
Add the desktop-vr-controller
attribute to any entity that uses oculus-touch-controls
, or a component that wraps this component, such as hand-controls
, laser-controls
, etc.
E.g.
<a-entity id="leftHand"
laser-controls="hand: left"
raycaster="objects: .raycastable"
position="-0.4 1.4 -0.5"
desktop-vr-controller></a-entity>
The controller will auto-configure to the correct hand, based on the hand settings on the oculus-touch-controls
, hand-controls
, laser-controls
, etc. component.
The labels that show the controls point to the physical positions of the buttons on the controllers. When hand-controls
is used, no controller model is displayed, meaning that these indications are not as clear as they are when controller models are displayed.
Examples
desktop-vr-controller.html - VR controllers with a classic A-Frame example
object-manipulation.html - VR controllers together with laser-manipulation to move and rotate entities with a laser pointer.