stewdio / THREE.VRController

Support hand controllers for Oculus, Vive, Windows Mixed Reality, Daydream, GearVR, and more by adding VRController to your existing Three.js-based WebVR project.
https://stewdio.github.io/THREE.VRController/
MIT License
230 stars 32 forks source link

npm #14

Open cmloegcmluin opened 6 years ago

cmloegcmluin commented 6 years ago

Any interest in making this awesome tool available as an npm package?

stewdio commented 6 years ago

Yes! Do you want to write the first draft of that? :wink:

cmloegcmluin commented 6 years ago

Already took care of it, actually! https://www.npmjs.com/package/three-vrcontroller-module

Kif11 commented 5 years ago

@cmloegcmluin Thanks a lot! How did you do it? Is it possible to automate?

cmloegcmluin commented 5 years ago

This is the commit that did it: https://github.com/cmloegcmluin/THREE.VRController/commit/ec8c720e4de1bc7dbea2cd2827551cfe3d82f973#diff-8d6f5c826e622ae81907df0290f3fa04

Automation should be possible. The key changes are:

  1. at the top, importing from THREE rather than expecting THREE to already exist in the global scope
  2. at the bottom, exporting the VRController rather than patching the global THREE.

The rest of the changes are not important. In fact, if you were automating this, you'd probably want to simply import * as THREE. That would have a couple benefits.

  1. The rest of the file could stay the same.
  2. You wouldn't have to do the step of finding the list of only the exports of THREE that you need for that module, as I have done for VRController.

Good luck and let me know if you have any other questions.

(By the way, a bunch of my VR Three.js stuff stopped working in Chrome this week due to a change in the WebXR API: navigator.xr.requestDevice is not a function. In fact, all of the WebVR examples at good old https://threejs.org/examples/ are down for this same reason (not surprised since I modeled my code after one of them)).

cmloegcmluin commented 5 years ago

Also, I noticed that the GitHub URL for my npm package was out of date, and have corrected it. I apologize if you had already gone looking for this information and I didn't make it easy on you!

Kif11 commented 5 years ago

Cool! Thanks for detailed explanation. I will probably use your fork instead because I really don't get an idea of assuming THREE in global scope. I might open an PR to you repo since I found some functionality missing from the library. https://github.com/stewdio/THREE.VRController/issues/25

cmloegcmluin commented 5 years ago

Sure thing. Happy to help.

I'll try to explain the whole global vs. module issue. THREE relies on the order you import files, such as with Githubissues.

  • Githubissues is a development platform for aggregating issues.