Skip to content
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

Improve pico-controls on third-party browsers such as Wolvic #5534

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
10 changes: 10 additions & 0 deletions src/components/hand-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ module.exports.Component = registerComponent('hand-controls', {
el.setAttribute('pico-controls', controlConfiguration);
el.setAttribute('windows-motion-controls', controlConfiguration);
el.setAttribute('hp-mixed-reality-controls', controlConfiguration);

// Pico4, at least on Wolvic, needs a different rotation
// offset for the hand model. Pico Browser claims to use
// oculus controllers instead; will load oculus-touch-controls
// and does not require this adjustment.
el.addEventListener('controllerconnected', function (evt) {
Copy link
Member

@dmarcos dmarcos Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a onControllerConnected method in the component we should put this logic there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can, however I need to make sure the adjustment is applied only the first time the event fires, or hands will rotate everytime I put the headset down and come back again later, hence the "once true" on the handler.

Could use a flag to be set once instead... would you prefer something like that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best is probably remove it the rotation on onControllerDisconnected

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried a different approach: I have now moved the logics to compute the various offsets to the hand model out of the model load handler and into the controller-connected handler.

b0adabf

I have updated the demo links

if (evt.detail.name === 'pico-controls') {
mesh.rotation.x += Math.PI / 4;
}
}, {once: true});
});
}
},
Expand Down
11 changes: 6 additions & 5 deletions src/components/pico-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ var PICO_MODEL_GLB_BASE_URL = AFRAME_CDN_ROOT + 'controllers/pico/pico4/';
*/
var INPUT_MAPPING_WEBXR = {
left: {
axes: {touchpad: [2, 3]},
buttons: ['trigger', 'squeeze', 'none', 'thumbstick', 'xbutton', 'ybutton']
axes: {thumbstick: [2, 3]},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these apply to all the pico controllers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in my tests one would not be able to e.g. turn using the blink-controls component and perform gestures with hand-controls without these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean using wolvic, which advertises the right controller type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about other browsers? The built-in one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Pico browser uses the oculus-controls component and behaves as an oculus controller. It was working properly before these changes and keeps doing so afterwards.

buttons: ['trigger', 'grip', 'none', 'thumbstick', 'xbutton', 'ybutton']
},
right: {
axes: {touchpad: [2, 3]},
buttons: ['trigger', 'squeeze', 'none', 'thumbstick', 'abutton', 'bbutton']
axes: {thumbstick: [2, 3]},
buttons: ['trigger', 'grip', 'none', 'thumbstick', 'abutton', 'bbutton']
}
};

Expand Down Expand Up @@ -120,6 +120,7 @@ module.exports.Component = registerComponent('pico-controls', {
controller: this.controllerIndex,
orientationOffset: data.orientationOffset
});

// Load model.
if (!this.data.model) { return; }
this.el.setAttribute('gltf-model', PICO_MODEL_GLB_BASE_URL + this.data.hand + '.glb');
Expand Down Expand Up @@ -163,6 +164,6 @@ module.exports.Component = registerComponent('pico-controls', {
},

onAxisMoved: function (evt) {
emitIfAxesChanged(this, this.mapping.axes, evt);
emitIfAxesChanged(this, this.mapping[this.data.hand].axes, evt);
}
});
Loading