Skip to content

Commit 4de86a1

Browse files
committed
2 parents 110e332 + 2dd7810 commit 4de86a1

File tree

1 file changed

+87
-5
lines changed

1 file changed

+87
-5
lines changed

README.md

Lines changed: 87 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ LIVE DEMO : [▶️ https://rufus31415.github.io/sandbox/simple-webxr-xrtk-solve
147147
|:-------------------------:|:-------------------------:|
148148
|<img src="https://raw.githubusercontent.com/Rufus31415/Simple-WebXR-Unity/master/images/xrtk-solvers-ios.gif" height="225px"> | <img src="https://raw.githubusercontent.com/Rufus31415/Simple-WebXR-Unity/master/images/xrtk-solvers-simulator.gif" height="225px">|
149149

150-
[work in progress...](https://github.com/Rufus31415/WebXR)
150+
[work in progress...](https://github.com/XRTK/WebXR)
151151

152152
---
153153

@@ -158,12 +158,94 @@ Unity has a unified plug-in framework that enables direct integrations or XR for
158158

159159
---
160160

161-
# How to use
161+
# Quick start
162+
163+
## Import and build a sample scene
164+
165+
First create a new 3D project
166+
167+
![tuto_NewProject](https://user-images.githubusercontent.com/22075796/117204491-a5c77280-adf0-11eb-8b86-409dfe25424e.JPG)
168+
169+
Download the latest release of SimpleWebXR : https://github.com/Rufus31415/Simple-WebXR-Unity/releases
170+
- ```SimpleWebXR.unitypackage```: contains only SimpleWebXR and its demo scenes
171+
- ```SimpleWebXR+MRTK.unitypackage``` : contains SimpleWebXR addon for MRTK. MRTK should be initialized in your project, see : https://docs.microsoft.com/fr-fr/windows/mixed-reality/mrtk-unity/
172+
173+
174+
Open the unitypackage file and import all resources : in tab ```Project```, right click on ```Assets > Import Package > Custom Package```
175+
176+
![image](https://user-images.githubusercontent.com/22075796/117205332-c93eed00-adf1-11eb-8426-49f5773fa17f.png)
177+
178+
From the directory ```Assets/SimpleWebXR/Example/Scenes```, just drag/drop a scene (for example the PaintExample) in the tab "Hierarchy"
179+
. You can play the scene, but it won't do anything (except if you are playing a MRTK sample).
180+
181+
Then, build the scene : ```File > Build Settings...```. Remove all scenes from the list and click ```Add open scenes``` so that you only get the scene we are going to build.
182+
183+
Select the WebGL plateform and click ```Switch platform```. Then click the ```Build``` button and create and select a ```Build``` directory next to Assets.
184+
185+
![image](https://user-images.githubusercontent.com/22075796/117208767-ca721900-adf5-11eb-831f-14c16804052c.png)
186+
187+
## Run your build locally in your browser
188+
189+
Your browser should be compatible with WebXR. For a first try, you can install the emulator :
190+
- For Chrome : https://chrome.google.com/webstore/detail/webxr-api-emulator/mjddjgeghkdijejnciaefnkjmkafnnje
191+
- For Firefox : https://addons.mozilla.org/en-US/firefox/addon/webxr-api-emulator
192+
193+
You now need a http server to serve you files. I recommend this one : https://www.npmjs.com/package/http-server
194+
- Just download node.js : https://nodejs.org/en/
195+
- install the server in your system with the command ```npm install --global http-server```
196+
197+
198+
You can now open a command line in your directory ```Build``` and run ```http-server```. Open your browser to the url : http://120.0.0.1:8080 then open the inspector and you should have a tab "WebXR" from where you can select your simulated device. You can move the controllers and the headset from here.
199+
200+
Now click the button "Start VR" to enter in immersion. Congrats !
201+
202+
![image](https://user-images.githubusercontent.com/22075796/117209832-32752f00-adf7-11eb-8c80-47a29058c1b4.png)
203+
204+
205+
## Run your build on your smartphone or headset
206+
207+
You can continue to host the page on your PC and serve it to other devices. The difficulty is that most browsers require a secure context for WebXR, i.e. https or localhost.
208+
209+
So it's a bit more complicated, but not impossible ;) ! First you need a certificate :
210+
- Download openssl. If you are on windows, download ```binaries``` from : http://gnuwin32.sourceforge.net/packages/openssl.htm
211+
- Extract and run the command : ```openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem -config **PATH_TO_OPENSSL**\share\openssl.cnf```where **PATH_TO_OPENSSL** is the absolute path to the directory you just extracted.
212+
- This will generate the files ```cert.pem```and ```key.pem```
213+
- Move these files in your Build directory
214+
215+
To serve your files, you should now run ```http-server -S -C cert.pem``` in your Build directory. You will see in the console all the URLs where the build is accessible. In your smartphone or headset, type the one with the same subnetwork than your PC. Ensure that your firewall accepts the request. On your device, the browser will say the page is not secure, but anyway, you can continue ;)
216+
217+
218+
162219
# Installation
163220
Just add these 3 files in your Unity Asset folder, then add SimpleWebXR MonoBehavior on a game object in your scene.
164-
- [SimpleWebXR.cs](https://github.com/Rufus31415/Simple-WebXR-Unity/blob/master/Assets/SimpleWebXR/Plugins/SimpleWebXR.cs): Mono Behaviour that displays the "Start AR" button and communicates with javascript. This behavior should be in your scene.
165-
- [SimpleWebXR.jslib](https://github.com/Rufus31415/Simple-WebXR-Unity/blob/master/Assets/SimpleWebXR/Plugins/SimpleWebXR.jslib): Javascript plugin that is included in the application and that makes the link between the Unity engine and the WebXR session. It displays the rendering and obtains the positions and characteristics of the camera.
166-
- [SimpleWebXR.jspre](https://github.com/Rufus31415/Simple-WebXR-Unity/blob/master/Assets/SimpleWebXR/Plugins/SimpleWebXR.jspre): Javascript plugin executed before the application that initializes a number of things.
221+
- [SimpleWebXR.cs](https://github.com/Rufus31415/Simple-WebXR-Unity/blob/master/com.rufus31415.simplewebxr/Runtime/Scripts/SimpleWebXR.cs): Mono Behaviour that displays the "Start AR" button and communicates with javascript. This behavior should be in your scene.
222+
- [SimpleWebXR.jslib](https://github.com/Rufus31415/Simple-WebXR-Unity/blob/master/com.rufus31415.simplewebxr/Runtime/Plugins/WebGL/SimpleWebXR.jslib): Javascript plugin that is included in the application and that makes the link between the Unity engine and the WebXR session. It displays the rendering and obtains the positions and characteristics of the camera.
223+
- [SimpleWebXR.jspre](https://github.com/Rufus31415/Simple-WebXR-Unity/blob/master/com.rufus31415.simplewebxr/Runtime/Plugins/WebGL/SimpleWebXR.jslib): Javascript plugin executed before the application that initializes a number of things.
224+
225+
## Download Unity Package
226+
Download the latest release of SimpleWebXR from : https://github.com/Rufus31415/Simple-WebXR-Unity/releases
227+
- ```SimpleWebXR.unitypackage```: contains only SimpleWebXR and its demo scenes
228+
- ```SimpleWebXR+MRTK.unitypackage``` : contains SimpleWebXR addon for MRTK. MRTK should be initialized in your project, see : https://docs.microsoft.com/fr-fr/windows/mixed-reality/mrtk-unity/
229+
230+
## Add from Package Manager
231+
232+
You can add the package ```com.rufus31415.simplewebxr```from the Package Manager. Go to ```Window > Package Manager``` Click the button ```+ > add package from git URL``` and enter ```https://github.com/Rufus31415/Simple-WebXR-Unity.git?path=/com.rufus31415.simplewebxr/```, after clicking on ```add``` it can take minutes even if Unity doesn't seem busy.
233+
234+
![image](https://user-images.githubusercontent.com/22075796/117214228-ceee0000-adfc-11eb-994a-0eab9048565d.png)
235+
236+
237+
## Edit ```manifest.json``` file
238+
239+
For the bravest, you can edit the file ```Packages/manifest.json``` so that it contains the line :
240+
``` json
241+
{
242+
"dependencies": {
243+
"com.rufus31415.simplewebxr": "https://github.com/Rufus31415/Simple-WebXR-Unity.git?path=/com.rufus31415.simplewebxr/",
244+
...
245+
...
246+
}
247+
}
248+
```
167249

168250
# Samples
169251
You can use the examples provided in this repository as a starting point.

0 commit comments

Comments
 (0)