Ahh yeah! I was intending to do just that, but my code’s a jumble as usual and i guess there’s a few folk who might get grumpy but its not their work, so hey
I’ll figure out some key points and if you can forgive the pretty backwards code, some scripts that might make it quite clear, i already know others could do a far superior effort to my own
I think if you can give me a while, i can finish using my implementation for what I intended it for and avoid making people grumpy, and have a pretty smashing demo going for it, and i can give out some cogent help
I can i think give a few pointers though - i used 2 apis really, the WebVR API, which is in particular firefox nightlies http://mozvr.com can help, with links to the firefox nightlys and a github with most the information you need to get it all going, although chrome are being lively too. Secondly I used the Gamepad API for a controller, i didnt implement it very gracefully,but with both this and webvr you can much identify what you’ll need to run on the page, which is generally the eventlisteners and such that will detect your hardware, and what would be more suited bringing into the unity creation
In terms of getting things into the build, and maybe this is something that could be extended upon in future because while im sure there are more performant and more elegant ways to do it, my go at it felt crude. I made a function on the page js that would bring together any useful values exposed by the apis based on their role. So i had a function that contained the values to initialise a vr camera rig, one that grabbed all the output of the sensor device and so on
You can execute that function from within your creation using Application.ExternalCall(function here) and then from the called js function, send desired information using SendMessage(GameObject, Function, string). This did get a bit messy as there’s sometimes a lot of values to move and only one string, well it just makes for a nice long strong you can punctuate with delimeters to help string.Split it back into its constituent parts back in Unity. Thats how i did it anyways, i’d like to hear of alternatives for sure.
In terms of setting up in Unity, i spent quite a long time trying to follow the example code involving matrices etc etc and in the end i gave up and saw what Unity could do instead. All you need for a suitable camera setup say, for a first person controller, is the controller, a child gameobject to act like a ‘head’, this will be oriented by the hmd.sensor information beamed in via my clumsy communication channel, the values for the Quaternion map nearly 1 to 1, or are easily fixable with tweaks
Position scanning isnt any more complicated, just keep the ‘head’ working around local transform
To the head you can add two cameras, have their rects set up so they take half the viewport each, and place them directly together, in the center fore of the head. The initialisation values webvr supplies include a suitable eye offset for each eye based im assuming on a default ipd or the one saved in your oculus service profile
I’m getting a bit scatterbrained atm because tired so i’m sorry if this doesnt help much, you’re welcome to ask questions and if noone else has gotten to it by the time ive done it, i should be able to offer some code and more experienced insight and hopefully quite a surprising thing to come out of a browser
Hope that helps a bit for now
Edit: Ahh i just remembered a fairly helpful other thing - webvr will distort each eye view automatically, you dont have to do it yourself, and this can save a bit of hassle