From b64fbe2c09b27dd47d3d7d90f026466ce982817f Mon Sep 17 00:00:00 2001 From: Adam Filandr Date: Sun, 7 Dec 2025 23:15:13 +0100 Subject: [PATCH] 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. --- docs/components/hand-controls.md | 3 ++- src/components/hand-controls.js | 24 +++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/docs/components/hand-controls.md b/docs/components/hand-controls.md index 3999a778444..4d8f27182ed 100644 --- a/docs/components/hand-controls.md +++ b/docs/components/hand-controls.md @@ -33,7 +33,8 @@ handles hand animations and poses. | color | Color of hand material. | white | | hand | Associated controller. Can be `left` or `right`. | left | | handModelStyle | Style of the hand 3D model loaded. Can be `lowPoly`, `highPoly` or `toon`. | lowPoly | - +| offSetRotation | Rotation offset for the hand model. Default value aligned with Meta Quest controllers. | 45 0 90 | +| offSetPosition | Position offset for the hand model. Default value aligned with Meta Quest controllers. | 0 0 0.02 | ## Events diff --git a/src/components/hand-controls.js b/src/components/hand-controls.js index 5c813ba2749..5684c664773 100644 --- a/src/components/hand-controls.js +++ b/src/components/hand-controls.js @@ -53,7 +53,10 @@ export var Component = registerComponent('hand-controls', { schema: { color: {default: 'white', type: 'color'}, hand: { default: 'left' }, - handModelStyle: {default: 'lowPoly', oneOf: ['lowPoly', 'highPoly', 'toon']} + handModelStyle: {default: 'lowPoly', oneOf: ['lowPoly', 'highPoly', 'toon']}, + // Default rotation and position is aligned with Meta Quest Controllers in the Meta Horizon Browser + offSetRotation: {default: {x: '45', y: '0', z: '90'}, type: 'vec3'}, + offSetPosition: {default: {x: '0', y: '0', z: '0.02'}, type: 'vec3'} }, after: ['tracked-controls'], @@ -117,24 +120,19 @@ export var Component = registerComponent('hand-controls', { var el = this.el; var hand = this.data.hand; var mesh = this.el.getObject3D('mesh'); + var offSetRotation = this.data.offSetRotation; + var offSetPosition = this.data.offSetPosition; el.object3D.visible = true; - var handModelOrientationZ = hand === 'left' ? Math.PI / 2 : -Math.PI / 2; // The WebXR standard defines the grip space such that a cylinder held in a closed hand points // along the Z axis. The models currently have such a cylinder point along the X-Axis. - var handModelOrientationX = el.sceneEl.hasWebXR ? -Math.PI / 2 : 0; - - // Pico4, at least on Wolvic, needs a different rotation offset - // for the hand model. Pico Browser claims to use oculus - // controllers instead; will load meta-touch-controls and does - // not require this adjustment. - if (evt.detail.name === 'pico-controls') { - handModelOrientationX += Math.PI / 4; - } + var handModelOrientationX = el.sceneEl.hasWebXR ? -THREE.MathUtils.degToRad(offSetRotation.x) : 0; + var handModelOrientationY = THREE.MathUtils.degToRad(offSetRotation.y); + var handModelOrientationZ = hand === 'left' ? THREE.MathUtils.degToRad(offSetRotation.z) : -THREE.MathUtils.degToRad(offSetRotation.z); - mesh.position.set(0, 0, 0); - mesh.rotation.set(handModelOrientationX, 0, handModelOrientationZ); + mesh.position.set(offSetPosition.x, offSetPosition.y, offSetPosition.z); + mesh.rotation.set(handModelOrientationX, handModelOrientationY, handModelOrientationZ); }, onControllerDisconnected: function () {