-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cardboard support for cursor-controller #343
Changes from all commits
17fcb6c
9ab2ba8
2ad5ef9
4fba73d
26737bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,8 @@ AFRAME.registerComponent("cursor-controller", { | |
this.data.playerRig.addEventListener(this.data.primaryUp, this._handlePrimaryUp); | ||
this.data.playerRig.addEventListener(this.data.grabEvent, this._handlePrimaryDown); | ||
this.data.playerRig.addEventListener(this.data.releaseEvent, this._handlePrimaryUp); | ||
this.data.playerRig.addEventListener("gamepadbuttondown", this._handlePrimaryDown); | ||
this.data.playerRig.addEventListener("gamepadbuttonup", this._handlePrimaryUp); | ||
|
||
this.data.playerRig.addEventListener("model-loaded", this._handleModelLoaded); | ||
|
||
|
@@ -116,6 +118,8 @@ AFRAME.registerComponent("cursor-controller", { | |
this.data.playerRig.removeEventListener(this.data.primaryUp, this._handlePrimaryUp); | ||
this.data.playerRig.removeEventListener(this.data.grabEvent, this._handlePrimaryDown); | ||
this.data.playerRig.removeEventListener(this.data.releaseEvent, this._handlePrimaryUp); | ||
this.data.playerRig.removeEventListener("gamepadbuttondown", this._handlePrimaryDown); | ||
this.data.playerRig.removeEventListener("gamepadbuttonup", this._handlePrimaryUp); | ||
|
||
this.data.playerRig.removeEventListener("model-loaded", this._handleModelLoaded); | ||
|
||
|
@@ -317,11 +321,13 @@ AFRAME.registerComponent("cursor-controller", { | |
|
||
for (let i = 0; i < e.changedTouches.length; i++) { | ||
const touch = e.changedTouches[i]; | ||
const thisTouchDidNotDriveMousePos = | ||
Math.abs(touch.clientX - this.lastTouch.clientX) > 0.1 && | ||
Math.abs(touch.clientY - this.lastTouch.clientY) > 0.1; | ||
if (thisTouchDidNotDriveMousePos) { | ||
return; | ||
if (this.lastTouch) { | ||
const thisTouchDidNotDriveMousePos = | ||
Math.abs(touch.clientX - this.lastTouch.clientX) > 0.1 && | ||
Math.abs(touch.clientY - this.lastTouch.clientY) > 0.1; | ||
if (thisTouchDidNotDriveMousePos) { | ||
return; | ||
} | ||
} | ||
} | ||
this._setLookControlsEnabled(true); | ||
|
@@ -370,10 +376,8 @@ AFRAME.registerComponent("cursor-controller", { | |
}, | ||
|
||
_handleEnterVR: function() { | ||
if (AFRAME.utils.device.checkHeadsetConnected()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was it necessary to remove this check? In theory it should return true because the polyfill provides a "Cardboard" headset. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if thats true, at least it wasn't in the older version of the polyfill. But regardless listening to just enter/exit VR should be sufficient. That check was mostly just there as a holdover from before when we only used the cursor for 2d mode. |
||
this.inVR = true; | ||
this._updateController(); | ||
} | ||
this.inVR = true; | ||
this._updateController(); | ||
}, | ||
|
||
_handleExitVR: function() { | ||
|
@@ -382,7 +386,7 @@ AFRAME.registerComponent("cursor-controller", { | |
}, | ||
|
||
_handlePrimaryDown: function(e) { | ||
if (e.target === this.controller) { | ||
if (e.target === this.controller || e.type === "gamepadbuttondown") { | ||
const isInteractable = this._isTargetOfType(TARGET_TYPE_INTERACTABLE) && !this.grabStarting; | ||
if (isInteractable || this._isTargetOfType(TARGET_TYPE_UI)) { | ||
this.grabStarting = true; | ||
|
@@ -394,7 +398,7 @@ AFRAME.registerComponent("cursor-controller", { | |
}, | ||
|
||
_handlePrimaryUp: function(e) { | ||
if (e.target === this.controller) { | ||
if (e.target === this.controller || e.type === "gamepadbuttonup") { | ||
if (this._isGrabbing() || this._isTargetOfType(TARGET_TYPE_UI)) { | ||
this.grabStarting = false; | ||
this.data.cursor.emit("cursor-release", e.detail); | ||
|
@@ -440,7 +444,7 @@ AFRAME.registerComponent("cursor-controller", { | |
_updateController: function() { | ||
this.hasPointingDevice = this.controllerQueue.length > 0 && this.inVR; | ||
|
||
this._setCursorVisibility(this.hasPointingDevice); | ||
this._setCursorVisibility(this.hasPointingDevice || this.isMobile); | ||
|
||
if (this.hasPointingDevice) { | ||
const controllerData = this.controllerQueue[0]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,7 @@ | |
ik-root | ||
player-info | ||
networked-avatar | ||
gamepad-controls | ||
> | ||
<a-entity | ||
id="player-hud" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(apologies in advance, as I know this is a WIP PR.)
is this a correct branch? this appears to be for #364 perhaps?
btw,
gamepadbuttondown
/gamepadbuttonup
/gamepadaxismove
are events that are proprietary to and work only in Firefox. (see w3c/gamepad#15 for context.) also, only in Firefox Nightly/Beta is theabout:config
flagdom.gamepad.non_standard_events
set totrue
; in release-channel Firefox, it'sfalse
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gamepadbuttondown
is fired by https://github.com/donmccurdy/aframe-extras/blob/master/src/controls/gamepad-controls.jsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gd lol, I should've checked before spamming you with unnecessary info. thanks!