Skip to content

Commit b64fbe2

Browse files
committed
Add rotation and position parameters to hand-controls.
The adjustment for Pico4 has been removed. It set the handModelOrientationX to -45 degrees, which now is the default value. As a result this adjustment is not neede anymore.
1 parent b0148d9 commit b64fbe2

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

docs/components/hand-controls.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ handles hand animations and poses.
3333
| color | Color of hand material. | white |
3434
| hand | Associated controller. Can be `left` or `right`. | left |
3535
| handModelStyle | Style of the hand 3D model loaded. Can be `lowPoly`, `highPoly` or `toon`. | lowPoly |
36-
36+
| offSetRotation | Rotation offset for the hand model. Default value aligned with Meta Quest controllers. | 45 0 90 |
37+
| offSetPosition | Position offset for the hand model. Default value aligned with Meta Quest controllers. | 0 0 0.02 |
3738

3839
## Events
3940

src/components/hand-controls.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ export var Component = registerComponent('hand-controls', {
5353
schema: {
5454
color: {default: 'white', type: 'color'},
5555
hand: { default: 'left' },
56-
handModelStyle: {default: 'lowPoly', oneOf: ['lowPoly', 'highPoly', 'toon']}
56+
handModelStyle: {default: 'lowPoly', oneOf: ['lowPoly', 'highPoly', 'toon']},
57+
// Default rotation and position is aligned with Meta Quest Controllers in the Meta Horizon Browser
58+
offSetRotation: {default: {x: '45', y: '0', z: '90'}, type: 'vec3'},
59+
offSetPosition: {default: {x: '0', y: '0', z: '0.02'}, type: 'vec3'}
5760
},
5861

5962
after: ['tracked-controls'],
@@ -117,24 +120,19 @@ export var Component = registerComponent('hand-controls', {
117120
var el = this.el;
118121
var hand = this.data.hand;
119122
var mesh = this.el.getObject3D('mesh');
123+
var offSetRotation = this.data.offSetRotation;
124+
var offSetPosition = this.data.offSetPosition;
120125

121126
el.object3D.visible = true;
122127

123-
var handModelOrientationZ = hand === 'left' ? Math.PI / 2 : -Math.PI / 2;
124128
// The WebXR standard defines the grip space such that a cylinder held in a closed hand points
125129
// along the Z axis. The models currently have such a cylinder point along the X-Axis.
126-
var handModelOrientationX = el.sceneEl.hasWebXR ? -Math.PI / 2 : 0;
127-
128-
// Pico4, at least on Wolvic, needs a different rotation offset
129-
// for the hand model. Pico Browser claims to use oculus
130-
// controllers instead; will load meta-touch-controls and does
131-
// not require this adjustment.
132-
if (evt.detail.name === 'pico-controls') {
133-
handModelOrientationX += Math.PI / 4;
134-
}
130+
var handModelOrientationX = el.sceneEl.hasWebXR ? -THREE.MathUtils.degToRad(offSetRotation.x) : 0;
131+
var handModelOrientationY = THREE.MathUtils.degToRad(offSetRotation.y);
132+
var handModelOrientationZ = hand === 'left' ? THREE.MathUtils.degToRad(offSetRotation.z) : -THREE.MathUtils.degToRad(offSetRotation.z);
135133

136-
mesh.position.set(0, 0, 0);
137-
mesh.rotation.set(handModelOrientationX, 0, handModelOrientationZ);
134+
mesh.position.set(offSetPosition.x, offSetPosition.y, offSetPosition.z);
135+
mesh.rotation.set(handModelOrientationX, handModelOrientationY, handModelOrientationZ);
138136
},
139137

140138
onControllerDisconnected: function () {

0 commit comments

Comments
 (0)