benvanik / vr.js

NPAPI plugin to expose fun VR devices to Javascript.
Apache License 2.0
498 stars 105 forks source link

.getOrientation()? #21

Open iraladson opened 10 years ago

iraladson commented 10 years ago

Hey,

I'm trying to track down the point where the Oculus rotation values are taken from the USB and brought into the vr.state.hmd.rotation variable. So far I've been able to track it to line 489, but I have a few questions. 1) what is global['vr_driver']? Right now, I'm assuming 'global' is the window object and ['vr_driver'] is some property on it, but I'm not to sure. When is 'global' defined? Is it the window object or am I completely off on that?

2) The .getOrientation() method that takes 'state.hmd.rotation' as a parameter...I have no idea what it means. Is it a primitive function? I can't find any reference to it in vr.js. Is it defined elsewhere?

Thanks for anything you can tell me. Just trying learn. The code I reference is below. Awesome library btw.

vr.DriverDataSource.prototype.poll = function(state) { //line 485 var present = this.driver.isPresent(); state.hmd.present = present; if (present) { this.driver.getOrientation(state.hmd.rotation); //<<---THIS LINE line 489 } else { state.hmd.rotation[0] = state.hmd.rotation[1] = state.hmd.rotation[2] = 0; state.hmd.rotation[3] = 0; }