Skip to content

Commit

Permalink
Remove WebVR support and polyfill (#5451)
Browse files Browse the repository at this point in the history
* Remove WebVR specific code

* Remove unused orientationOffset from the controls components

---------

Co-authored-by: Noeri Huisman <[email protected]>
  • Loading branch information
mrxz and mrxz authored Oct 15, 2024
1 parent 4449ed5 commit 6049ceb
Show file tree
Hide file tree
Showing 35 changed files with 60 additions and 2,231 deletions.
1 change: 0 additions & 1 deletion docs/components/magicleap-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ mappings, events, and Magic Leap controller model/
|----------------------|----------------------------------------------------|----------------------|
| hand | The hand that will be tracked (e.g., right, left). | |
| model | Whether the Magic Leap controller model is loaded. | true |
| orientationOffset | Offset to apply to model orientation. | x: 0, y: 0, z: 0 |

## Events

Expand Down
1 change: 0 additions & 1 deletion docs/components/oculus-touch-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ mappings, events, and a Touch controller model.
|----------------------|----------------------------------------------------|----------------------|
| hand | The hand that will be tracked (i.e., right, left). | left |
| model | Whether the Touch controller model is loaded. | true |
| orientationOffset | Offset to apply to model orientation. | x: 0, y: 0, z: 0 |

## Events

Expand Down
2 changes: 0 additions & 2 deletions docs/components/tracked-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ so using idPrefix for Vive / OpenVR controllers is recommended.

| Property | Description | Default Value |
|-------------------|------------------------------------------------------------------------------------------|------------------|
| armModel | Whether the arm model is used for positional data if absent. | true |
| autoHide | Whether to toggle visibility automatically when controller is connected or disconnected. | true |
| controller | Index of the controller in array returned by the Gamepad API. | 0 |
| id | Selects the controller from the Gamepad API using exact match. | |
| idPrefix | Selects the controller from the Gamepad API using prefix match. | |
| headElement | Head element for arm model if needed (if not active camera). | |
| hand | Which hand to use, if arm model is needed. (left negates X) | right |
| orientationOffset | Offset to apply to model orientation. | x: 0, y: 0, z: 0 |
| space | Specifies whether to use targetRayspace or gripSpace to determine controller pose. | targetRaySpace |

## Events
Expand Down
1 change: 0 additions & 1 deletion docs/components/vive-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ buttons (trigger, grip, menu, system) and trackpad.
| buttonHighlightColor | Button colors when pressed and active. | #22D1EE (light blue) |
| hand | The hand that will be tracked (i.e., right, left). | left |
| model | Whether the Vive controller model is loaded. | true |
| orientationOffset | Offset to apply to model orientation. | x: 0, y: 0, z: 0 |

## Events

Expand Down
2 changes: 0 additions & 2 deletions docs/components/vive-focus-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ and/or pressed buttons (trackpad, trigger).

| Property | Description | Default |
|----------------------|----------------------------------------------------|----------------------|
| armModel | Whether the arm model is used for positional data. | true |
| buttonTouchedColor | Button colors when touched (Trackpad only). | #777777 |
| buttonHighlightColor | Button colors when pressed and active. | #FFFFFF |
| hand | The hand that will be tracked (e.g., right, left). | |
| model | Whether the Vive Focus controller model is loaded. | true |
| orientationOffset | Offset to apply to model orientation. | x: 0, y: 0, z: 0 |

## Events

Expand Down
1 change: 0 additions & 1 deletion docs/components/windows-motion-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ to the pressed buttons (trigger, grip, menu, thumbstick, trackpad) and moved axe
| hand | The hand that will be tracked (i.e., right, left). | right |
| pair | Which pair of controllers, if > 2 are connected. | 0 |
| model | Whether the controller model is loaded. | true |
| hideDisconnected | Disable rendering of controller model when no matching gamepad (based on ID & hand) is connected. | true |


## Events
Expand Down
1 change: 0 additions & 1 deletion docs/core/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ global. This same interface is also exposed if requiring with CommonJS
| Property | Description |
| ---------- | ------------- |
| AFRAME | The object described above. |
| hasNativeWebVRImplementation | Whether the client has native WebVR support. |

## Requiring `AFRAME` in a Node.js Environment

Expand Down
3 changes: 1 addition & 2 deletions docs/introduction/interactions-and-controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ AFRAME.registerComponent('custom-controls', {
var el = this.el;
var controlConfiguration = {
hand: hand,
model: false,
orientationOffset: {x: 0, y: 0, z: hand === 'left' ? 90 : -90}
model: false
};

// Build on top of controller components.
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
"load-bmfont": "^1.2.3",
"super-animejs": "^3.1.0",
"three": "npm:[email protected]",
"three-bmfont-text": "dmarcos/three-bmfont-text#eed4878795be9b3e38cf6aec6b903f56acd1f695",
"webvr-polyfill": "^0.10.12"
"three-bmfont-text": "dmarcos/three-bmfont-text#eed4878795be9b3e38cf6aec6b903f56acd1f695"
},
"devDependencies": {
"@babel/core": "^7.24.0",
Expand Down
7 changes: 0 additions & 7 deletions scripts/preghpages.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ const path = require('path');
const shell = require('shelljs');
const replace = require('replace-in-file');

// Inject `<meta>` tag for Chrome for Android's WebVR Origin Trial:
// https://webvr.rocks/chrome_for_android#what_is_the_webvr_origin_trial
const originTrialMetaTag = `
<!-- Origin Trial Token, feature = WebVR (For Chrome M59+), origin = https://aframe.io, expires = 2017-07-28 -->
<meta http-equiv="origin-trial" data-feature="WebVR (For Chrome M59+)" data-expires="2017-07-28" content="ArFv1ZeTwzkhjNE00uAE+XtiQB41fwqG/TqlFMLrepd9sforQSvQE/tgfIbUMYNuNre4QR1k4/z8xp2mV3dbhwwAAABeeyJvcmlnaW4iOiJodHRwczovL2FmcmFtZS5pbzo0NDMiLCJmZWF0dXJlIjoiV2ViVlIxLjEiLCJleHBpcnkiOjE1MDEyMTcwMDIsImlzU3ViZG9tYWluIjp0cnVlfQ==">
`.trim();
const rootDir = path.join(__dirname, '..');

shell.cd(rootDir);
Expand All @@ -34,4 +28,3 @@ function htmlReplace (before, after) {
}

htmlReplace('dist/aframe-master.js', 'dist/aframe-master.min.js');
htmlReplace('<head>', `<head>\n ${originTrialMetaTag}`);
2 changes: 0 additions & 2 deletions src/components/generic-tracked-controller-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ module.exports.Component = registerComponent('generic-tracked-controller-control
hand: {default: ''}, // This informs the degenerate arm model.
defaultModel: {default: true},
defaultModelColor: {default: 'gray'},
orientationOffset: {type: 'vec3'},
disabled: {default: false}
},

Expand Down Expand Up @@ -134,7 +133,6 @@ module.exports.Component = registerComponent('generic-tracked-controller-control
el.setAttribute('tracked-controls', {
hand: data.hand,
idPrefix: GAMEPAD_ID_PREFIX,
orientationOffset: data.orientationOffset,
iterateControllerProfiles: true
});
if (!this.data.defaultModel) { return; }
Expand Down
6 changes: 2 additions & 4 deletions src/components/hp-mixed-reality-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ var INPUT_MAPPING_WEBXR = {
module.exports.Component = registerComponent('hp-mixed-reality-controls', {
schema: {
hand: {default: 'none'},
model: {default: true},
orientationOffset: {type: 'vec3'}
model: {default: true}
},

mapping: INPUT_MAPPING_WEBXR,
Expand Down Expand Up @@ -125,8 +124,7 @@ module.exports.Component = registerComponent('hp-mixed-reality-controls', {
// TODO: verify expected behavior between reserved prefixes.
idPrefix: GAMEPAD_ID,
hand: data.hand,
controller: this.controllerIndex,
orientationOffset: data.orientationOffset
controller: this.controllerIndex
});

// Load model.
Expand Down
1 change: 0 additions & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ require('./shadow');
require('./sound');
require('./text');
require('./tracked-controls');
require('./tracked-controls-webvr');
require('./tracked-controls-webxr');
require('./visible');
require('./valve-index-controls');
Expand Down
2 changes: 1 addition & 1 deletion src/components/look-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var utils = require('../utils/');
var PI_2 = Math.PI / 2;

/**
* look-controls. Update entity pose, factoring mouse, touch, and WebVR API data.
* look-controls. Update entity pose, factoring mouse, touch.
*/
module.exports.Component = registerComponent('look-controls', {
dependencies: ['position', 'rotation'],
Expand Down
6 changes: 2 additions & 4 deletions src/components/magicleap-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ var INPUT_MAPPING_WEBXR = {
module.exports.Component = registerComponent('magicleap-controls', {
schema: {
hand: {default: 'none'},
model: {default: true},
orientationOffset: {type: 'vec3'}
model: {default: true}
},

mapping: INPUT_MAPPING_WEBXR,
Expand Down Expand Up @@ -120,8 +119,7 @@ module.exports.Component = registerComponent('magicleap-controls', {
// TODO: verify expected behavior between reserved prefixes.
idPrefix: GAMEPAD_ID_COMPOSITE,
hand: data.hand,
controller: this.controllerIndex,
orientationOffset: data.orientationOffset
controller: this.controllerIndex
});

// Load model.
Expand Down
33 changes: 5 additions & 28 deletions src/components/oculus-go-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,12 @@ var trackedControlsUtils = require('../utils/tracked-controls');
var checkControllerPresentAndSetup = trackedControlsUtils.checkControllerPresentAndSetup;
var emitIfAxesChanged = trackedControlsUtils.emitIfAxesChanged;
var onButtonEvent = trackedControlsUtils.onButtonEvent;
var isWebXRAvailable = require('../utils/').device.isWebXRAvailable;

var GAMEPAD_ID_WEBXR = 'oculus-go';
var GAMEPAD_ID_WEBVR = 'Oculus Go';
var AFRAME_CDN_ROOT = require('../constants').AFRAME_CDN_ROOT;
var OCULUS_GO_CONTROLLER_MODEL_URL = AFRAME_CDN_ROOT + 'controllers/oculus/go/oculus-go-controller.gltf';

// Prefix for Gen1 and Gen2 Oculus Touch Controllers.
var GAMEPAD_ID_PREFIX = isWebXRAvailable ? GAMEPAD_ID_WEBXR : GAMEPAD_ID_WEBVR;

/**
* Button indices:
* 0 - trackpad
* 1 - trigger
*
* Axis:
* 0 - trackpad x
* 1 - trackpad y
*/
var INPUT_MAPPING_WEBVR = {
axes: {trackpad: [0, 1]},
buttons: ['trackpad', 'trigger']
};
var GAMEPAD_ID_PREFIX = 'oculus-go';

/**
* Button indices:
Expand All @@ -39,17 +22,15 @@ var INPUT_MAPPING_WEBVR = {
* 1 - touchpad y
* Reference: https://github.com/immersive-web/webxr-input-profiles/blob/master/packages/registry/profiles/oculus/oculus-go.json
*/
var INPUT_MAPPING_WEBXR = {
var INPUT_MAPPING = {
axes: {touchpad: [0, 1]},
buttons: ['trigger', 'none', 'touchpad']
};

var INPUT_MAPPING = isWebXRAvailable ? INPUT_MAPPING_WEBXR : INPUT_MAPPING_WEBVR;

/**
* Oculus Go controls.
* Interface with Oculus Go controller and map Gamepad events to
* controller buttons: trackpad, trigger
* controller buttons: trigger, touchpad
* Load a controller model and highlight the pressed buttons.
*/
module.exports.Component = registerComponent('oculus-go-controls', {
Expand All @@ -58,9 +39,7 @@ module.exports.Component = registerComponent('oculus-go-controls', {
buttonColor: {type: 'color', default: '#FFFFFF'},
buttonTouchedColor: {type: 'color', default: '#BBBBBB'},
buttonHighlightColor: {type: 'color', default: '#7A7A7A'},
model: {default: true},
orientationOffset: {type: 'vec3'},
armModel: {default: true}
model: {default: true}
},

mapping: INPUT_MAPPING,
Expand Down Expand Up @@ -128,10 +107,8 @@ module.exports.Component = registerComponent('oculus-go-controls', {
var el = this.el;
var data = this.data;
el.setAttribute('tracked-controls', {
armModel: data.armModel,
hand: data.hand,
idPrefix: GAMEPAD_ID_PREFIX,
orientationOffset: data.orientationOffset
idPrefix: GAMEPAD_ID_PREFIX
});
if (!this.data.model) { return; }
this.el.setAttribute('gltf-model', OCULUS_GO_CONTROLLER_MODEL_URL);
Expand Down
Loading

0 comments on commit 6049ceb

Please sign in to comment.