-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
optimize tracked controls tick, discovery, and various utils #2943
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
Conversation
src/components/gearvr-controls.js
Outdated
| this.onButtonUp = function (evt) { self.onButtonEvent(evt.detail.id, 'up'); }; | ||
| this.onButtonTouchStart = function (evt) { self.onButtonEvent(evt.detail.id, 'touchstart'); }; | ||
| this.onButtonTouchEnd = function (evt) { self.onButtonEvent(evt.detail.id, 'touchend'); }; | ||
| this.onButtonDown = function (evt) { |
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.
Can we keep the one liners. It makes the code harder to parse?
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.
Some were going over a character limit causing them to wrap. Want me to revert still?
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.
I think it's ok going over the character limit in same cases to avoid contortions and breaking style consistency
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.
Changed it
325c594 to
4055bc3
Compare
src/components/daydream-controls.js
Outdated
| this.onButtonUp = function (evt) { | ||
| self.onButtonEvent(evt.detail.id, 'up'); | ||
| }; | ||
| this.onButtonTouchStart = function (evt) { |
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.
one liner
src/components/daydream-controls.js
Outdated
| self.onButtonEvent(evt.detail.id, 'up'); | ||
| }; | ||
| this.onButtonTouchStart = function (evt) { | ||
| self.onButtonEvent(evt.detail.id, 'touchstart'); |
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.
one liner
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.
yeah i can catch them all if you just note once
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.
though i missed this file xD
src/components/daydream-controls.js
Outdated
| this.onButtonTouchStart = function (evt) { | ||
| self.onButtonEvent(evt.detail.id, 'touchstart'); | ||
| }; | ||
| this.onButtonTouchEnd = function (evt) { |
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.
one liner
4055bc3 to
13ff155
Compare
src/components/daydream-controls.js
Outdated
| buttonMeshes.system = controllerObject3D.getObjectByName('HomeButton_HomeButton_Cylinder.005'); | ||
| buttonMeshes.trackpad = controllerObject3D.getObjectByName('TouchPad_TouchPad_Cylinder.003'); | ||
| // Offset pivot point | ||
| buttonMeshes.menu = controllerObject3D.getObjectByName( |
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.
If needed I think it looks better to break the whole expression to the line below instead of just an argument
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.
i'll just restore to one liners
13ff155 to
88fb20b
Compare
|
I believe it could be nice to have the tick ms as a parameter, for some applications 500ms it could be way too much |
|
It just detects new controllers right? Half a second isn't much |
|
@ngokevin my fault, I was thinking that the tick was in updating the position/rotation, not just on updating the list, I've checked the coded already O:) |
|
Updated to save another couple object allocations and to skip type check per tracked controls per tick. |
|
Has this been checked to ensure that controller pose update rate is unaffected in-VR? I know things have changed a lot since we started these... once upon a time, the only way the controller pose was updated was when it was grabbed by tracked-controls system tick, and then utilized by tracked-controls component tick |
|
Ok so I think the assumption is that the browser continues to make pose changes to the same controller object, which is still updated unthrottled by tracked-controls component tick, so unless some browser has done wacky things in its implementation, LGTM. Only quirk is if controller goes away, and we won't know it for up to 500ms; need to ensure that dying controller object state doesn't break things before detection. |
|
Yeah, it'd be pretty noticeable if controllers only moved once every 500ms. The tracked-controls component handles the pose update. The system only handles detection for connected/disconnected so it's fine. I'll double-check what happens on disconnect. |
Description:
There was some messy/dirty/redundant code. Tested with Vive controllers.
Changes proposed:
getGamepadsByPrefixutil. This was only being used in the tracked controls tick, and tracked controls never used the prefix feature. We call thenavigator.gamePadsnow directly in the controls tick. Previously, we were creating a string and array on each tick, and then re-looping over that array and copying it to another array.updateControllersListin theisControllerPresentutil. This didn't really do anything since controllers were picked up through thecontrollersupdateevent rather than within here.axisLabels), fixing 95-char lengths, and cleaner comments.