Skip to content

Commit

Permalink
Apply a PI/4 offset on the hands models when using pico4 controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Elettrotecnica committed Jun 6, 2024
1 parent 928c7fa commit 0f83c83
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/pico-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@ module.exports.Component = registerComponent('pico-controls', {
this.onButtonTouchEnd = function (evt) { onButtonEvent(evt.detail.id, 'touchend', self, self.data.hand); };
this.onButtonTouchStart = function (evt) { onButtonEvent(evt.detail.id, 'touchstart', self, self.data.hand); };
this.bindMethods();

// Pico4, at least on Wolvic, needs a different rotation offset
// for the hands model when this component is used via
// hand-controls.
// Note: at the time of writing, the Pico Browser on Pico4 claims
// to use oculus controllers and does not use this component. It
// probably also applies the same offset an oculus controller has.
if (this.el.components['hand-controls']) {
this.el.addEventListener('controllerconnected', function (evt) {
if (evt.detail.component === self) {
self.el.getObject3D('mesh').rotation.x += Math.PI / 4;
}
}, {once: true});
}
},

update: function () {
Expand Down Expand Up @@ -120,6 +134,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

0 comments on commit 0f83c83

Please sign in to comment.