Skip to content

Commit

Permalink
fixes for tracked-controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyabel committed Oct 3, 2017
1 parent 005036b commit 138183c
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 30 deletions.
54 changes: 43 additions & 11 deletions dist/aframe-master.js
Original file line number Diff line number Diff line change
Expand Up @@ -75943,7 +75943,7 @@ _dereq_('./core/a-mixin');
_dereq_('./extras/components/');
_dereq_('./extras/primitives/');

console.log('A-Frame Version: 0.5.0 (Date 03-10-2017, Commit #e83d220)');
console.log('A-Frame Version: 0.5.0 (Date 03-10-2017, Commit #005036b)');
console.log('three Version:', pkg.dependencies['three']);
console.log('WebVR Polyfill Version:', pkg.dependencies['webvr-polyfill']);

Expand Down Expand Up @@ -77238,6 +77238,8 @@ function fixVideoAttributes (videoEl) {

},{"../core/system":108,"../lib/three":144,"../utils/":165}],158:[function(_dereq_,module,exports){
var registerSystem = _dereq_('../core/system').registerSystem;
var trackedControlsUtils = _dereq_('../utils/tracked-controls');
var utils = _dereq_('../utils');

/**
* Tracked controls system.
Expand All @@ -77253,10 +77255,8 @@ module.exports.System = registerSystem('tracked-controls', {

if (!navigator.getVRDisplays) { return; }

this.sceneEl.addEventListener('enter-vr', function () {
navigator.getVRDisplays().then(function (displays) {
if (displays.length) { self.vrDisplay = displays[0]; }
});
navigator.getVRDisplays().then(function (displays) {
if (displays.length) { self.vrDisplay = displays[0]; }
});
},

Expand All @@ -77268,6 +77268,15 @@ module.exports.System = registerSystem('tracked-controls', {
* Update controller list.
*/
updateControllerList: function () {
var prevCount = this.controllers.length;
this.controllers = this.getControllerList();

if (this.controllers.length !== prevCount) {
this.sceneEl.emit('controllersupdated', { controllers: this.controllers });
}
},

getControllerList: function() {
var controllers = this.controllers;
var gamepad;
var gamepads;
Expand All @@ -77286,12 +77295,11 @@ module.exports.System = registerSystem('tracked-controls', {
}
}

if (controllers.length !== prevCount) {
this.el.emit('controllersupdated', undefined, false);
}
return this.controllers;
}
});
},{"../core/system":108}],159:[function(_dereq_,module,exports){

},{"../core/system":108,"../utils":165,"../utils/tracked-controls":169}],159:[function(_dereq_,module,exports){
/**
* Faster version of Function.prototype.bind
* @param {Function} fn - Function to wrap.
Expand Down Expand Up @@ -78198,6 +78206,29 @@ var DEFAULT_HANDEDNESS = _dereq_('../constants').DEFAULT_HANDEDNESS;
var AXIS_LABELS = ['x', 'y', 'z', 'w'];
var NUM_HANDS = 2; // Number of hands in a pair. Should always be 2.

/**
* Return enumerated gamepads matching id prefix.
*
* @param {object} idPrefix - prefix to match in gamepad id, if any.
*/
module.exports.getGamepadsByPrefix = function (idPrefix) {
var gamepadsList = [];
var gamepad;
var gamepads = navigator.getGamepads && navigator.getGamepads();
if (!gamepads) { return gamepadsList; }

for (var i = 0; i < gamepads.length; ++i) {
gamepad = gamepads[i];
// need to check that gamepad is valid, since browsers may return array of null values
if (gamepad) {
if (!idPrefix || gamepad.id.indexOf(idPrefix) === 0) {
gamepadsList.push(gamepad);
}
}
}
return gamepadsList;
};

/**
* Called on controller component `.play` handlers.
* Check if controller matches parameters and inject tracked-controls component.
Expand Down Expand Up @@ -78242,7 +78273,7 @@ module.exports.checkControllerPresentAndSetup = function (component, idPrefix, q
* @param {object} idPrefix - Prefix to match in gamepad id if any.
* @param {object} queryObject - Map of values to match.
*/
function isControllerPresent (component, idPrefix, queryObject) {
function isControllerPresent (component, idPrefix, queryObject ) {
var gamepads;
var sceneEl = component.sceneEl;
var trackedControlsSystem;
Expand All @@ -78253,7 +78284,7 @@ function isControllerPresent (component, idPrefix, queryObject) {
trackedControlsSystem = sceneEl && sceneEl.systems['tracked-controls'];
if (!trackedControlsSystem) { return false; }

gamepads = trackedControlsSystem.controllers;
gamepads = trackedControlsSystem.getControllerList();
if (!gamepads.length) { return false; }

return !!findMatchingController(gamepads, null, idPrefix, queryObject.hand, filterControllerIndex);
Expand Down Expand Up @@ -78346,6 +78377,7 @@ module.exports.emitIfAxesChanged = function (component, axesMapping, evt) {
component.el.emit(buttonTypes[i] + 'moved', detail);
}
};

},{"../constants":89}],170:[function(_dereq_,module,exports){
/**
* @author dmarcos / https://github.com/dmarcos
Expand Down
8 changes: 4 additions & 4 deletions dist/aframe-master.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 138183c

Please sign in to comment.