Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 15 additions & 10 deletions docs/components/tracked-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ the entity, observes buttons state and emits appropriate events. For non-6DOF c
such as [daydream-controls][daydreamcontrols], a primitive arm model is used to emulate
positional data.

tracked-controls sets two components that handles different Web API versions for VR:

- tracked-controls-webvr
- tracked-controls-webxr

## Example

Note that due to recent browser-specific changes, Vive controllers may be returned
Expand All @@ -35,16 +40,16 @@ so using idPrefix for Vive / OpenVR controllers is recommended.

## Value

| Property | Description | Default Value |
|-------------------|-----------------------------------------------------------------|----------------------------|
| armModel | Whether the arm model is used for positional data if absent. | 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 |

| 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 |

## Events

Expand Down
4 changes: 3 additions & 1 deletion src/components/tracked-controls-webvr.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var EVENTS = {
*/
module.exports.Component = registerComponent('tracked-controls-webvr', {
schema: {
autoHide: {default: true},
controller: {default: 0},
id: {type: 'string', default: ''},
hand: {type: 'string', default: ''},
Expand Down Expand Up @@ -102,7 +103,8 @@ module.exports.Component = registerComponent('tracked-controls-webvr', {
this.controller = controller;
// Legacy handle to the controller for old components.
this.el.components['tracked-controls'].controller = controller;
this.el.object3D.visible = !!this.controller;

if (this.data.autoHide) { this.el.object3D.visible = !!this.controller; }
},

/**
Expand Down
3 changes: 2 additions & 1 deletion src/components/tracked-controls-webxr.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ module.exports.Component = registerComponent('tracked-controls-webxr', {
);
// Legacy handle to the controller for old components.
this.el.components['tracked-controls'].controller = this.controller;
this.el.object3D.visible = !!this.controller;

if (this.data.autoHide) { this.el.object3D.visible = !!this.controller; }
},

tick: function () {
Expand Down
1 change: 1 addition & 0 deletions src/components/tracked-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var registerComponent = require('../core/component').registerComponent;
*/
module.exports.Component = registerComponent('tracked-controls', {
schema: {
autoHide: {default: true},
controller: {default: 0},
id: {type: 'string', default: ''},
hand: {type: 'string', default: ''},
Expand Down