Skip to content

Commit

Permalink
zero pivot values apparently block-copied from vive-controls; adjust …
Browse files Browse the repository at this point in the history
…model orientation and position
  • Loading branch information
machenmusik committed Mar 31, 2018
1 parent 6ce3b6f commit ad7bf74
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/oculus-touch-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var bind = require('../utils/bind');
var registerComponent = require('../core/component').registerComponent;
var trackedControlsUtils = require('../utils/tracked-controls');
var onButtonEvent = trackedControlsUtils.onButtonEvent;
var THREE = require('../lib/three');

var TOUCH_CONTROLLER_MODEL_BASE_URL = 'https://cdn.aframe.io/controllers/oculus/oculus-touch-controller-';
var TOUCH_CONTROLLER_MODEL_OBJ_URL_L = TOUCH_CONTROLLER_MODEL_BASE_URL + 'left.obj';
Expand All @@ -11,7 +12,7 @@ var TOUCH_CONTROLLER_MODEL_OBJ_MTL_R = TOUCH_CONTROLLER_MODEL_BASE_URL + 'right.

var GAMEPAD_ID_PREFIX = 'Oculus Touch';

var PIVOT_OFFSET = {x: 0, y: -0.015, z: 0.04};
var PIVOT_OFFSET = {x: 0, y: 0, z: 0};

/**
* Oculus Touch controls.
Expand Down Expand Up @@ -191,6 +192,18 @@ module.exports.Component = registerComponent('oculus-touch-controls', {

// Offset pivot point
controllerObject3D.position = PIVOT_OFFSET;

// Fix issue #2965 for default Touch model, rotate it 45 degrees.
// But if it isn't the default Touch model, don't.
controllerObject3D.traverse(function (o3d) {
if (o3d instanceof THREE.Mesh) {
if (o3d.name.startsWith('body_oculus-touch-controller-')) {
o3d.parent.rotateX(45 * Math.PI / 180);
o3d.parent.translateY(0.02);
o3d.parent.translateZ(-0.03);
}
}
});
},

onAxisMoved: function (evt) {
Expand Down

0 comments on commit ad7bf74

Please sign in to comment.