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

mouse-controls are attached to the window, behaviour should be configurable #23

Closed
bumblehead opened this issue Dec 21, 2015 · 3 comments

Comments

@bumblehead
Copy link

mouse-controls are attached to the window, behaviour should be configurable

https://github.com/borismus/webvr-polyfill/blob/master/src/mouse-keyboard-position-sensor-vr-device.js#L37-L40

When custom video controls such as a seek bar are created, mouse events from those bubble to the window causing unwanted camera movement. The element used here should be configurable and/or the methods bound to the window should be configurable.

As a work-around I've modified a local copy of this file with the following,

MouseKeyboardPositionSensorVRDevice.prototype.onMouseDown_ = function(e) {
  var elem = (function (e) {
    var fn = function () {};
    if (typeof e === 'object' && e) {
      if ('target' in e) {
        fn = function (ev) {
          return ev.target;
        };
      } else if ('srcElement' in e) {
        fn = function (ev) {
          return ev.srcElement;
        };
      }
    }
    return fn(e);
  }(e));

  if (/canvas/i.test(elem.tagName)) {
    this.rotateStart.set(e.clientX, e.clientY);
    this.isDragging = true;
  }
};
@pindiespace
Copy link

Put that in a pull request!

To really get rid of all the implicit document.body assumptions, you have to modify the polyfill, boilerplate, and VREffect.js. Also, the polyfill assumes there is one window, so if you try making multiple webgl windows, they all move with the mouse. To really make this work (for things like VR slideshows) will require a significant overhaul.

@iambumblehead
Copy link

I submitted a PR for some related issues. The PR was ignored and later closed.

borismus/webvr-boilerplate#77 (comment)

@borismus
Copy link
Contributor

Please re-open as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants