HoloJS
HoloJS is a framework for creating UWP applications using JavaScript and WebGL.
HoloJS is a C++ library that hosts Chakra to run JavaScript code, and also hosts ANGLE to handle OpenGL ES graphics calls. OpenGL ES calls are translated from WebGL calls by the JavaScript app. When running on a Microsoft HoloLens, HoloJS supports holographic rendering.
Code sample
A sample project is included for Windows Holographic. The sample takes a few moments to load and there is no loading indicator.
The sample works on Windows Holographic by getting a holographic view matrix from the HoloJS host layer. This is done in JavaScript by calling window.getViewMatrix():
// Draw the cube.
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVerticesIndexBuffer);
gl.uniformMatrix4fv(pUniform, false, new Float32Array(identity));
gl.uniformMatrix4fv(mUniform, false, new Float32Array(model));
gl.uniformMatrix4fv(vUniform, false, window.getViewMatrix());
gl.drawElements(gl.TRIANGLES, 36, gl.UNSIGNED_SHORT, 0);
This view matrix represents a view from the middle point between left and right views of the holographic stereo camera. The app should not set a projection matrix in this case, or it should set a projection matrix that is the identity matrix. ANGLE for Windows Holographic will apply the correct projection matrices for the holographic device to each vertex automatically, after splitting the output into left and right views by using a geometry shader.
Additional remarks
Note This library requires Visual Studio 2015 Update 3 to build, and supports Windows Universal platforms such as Windows 10 and Windows Holographic. Windows Holographic devices include the Microsoft HoloLens and the Microsoft HoloLens Emulator.
To obtain information about Windows 10 development, go to the [Windows Dev Center] (http://go.microsoft.com/fwlink/?LinkID=532421).
To obtain information about the tools used for Windows Holographic development, including Microsoft Visual Studio 2015 Update 3 and the Microsoft HoloLens Emulator, go to [Install the tools] (https://developer.microsoft.com/windows/holographic/install_the_tools).
Reference
The following Windows Universal APIs are used to demonstrate spatial locations, and holographic rendering in this code sample:
System requirements
Client: Windows 10, Windows 10 Holographic
Phone: Not tested
Build the sample
- Clone the repo, then update submodules so that you get ANGLE.
- Start Microsoft Visual Studio 2015 and select File > Open > Project/Solution.
- Starting in the folder where you cloned the repo, go to the HoloJS subfolder. Double-click the Visual Studio 2015 Solution (.sln) file.
- Press Ctrl+Shift+B, or select Build > Build Solution.
Run the sample
The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.
Deploying the sample to the Microsoft HoloLens emulator
- Click the debug target drop-down, and select Microsoft HoloLens Emulator.
- Select Build > Deploy Solution.
Deploying the sample to a Microsoft HoloLens
- Developer unlock your Microsoft HoloLens. For instructions, go to [Enable your device for development] (https://msdn.microsoft.com/windows/uwp/get-started/enable-your-device-for-development#enable-your-windows-10-devices).
- Find the IP address of your Microsoft HoloLens. The IP address can be found in Settings > Network & Internet > Wi-Fi > Advanced options. Or, you can ask Cortana for this information by saying: "Hey Cortana, what's my IP address?"
- Right-click on your project in Visual Studio, and then select Properties.
- In the Debugging pane, click the drop-down and select Remote Machine.
- Enter the IP address of your Microsoft HoloLens into the field labelled Machine Name.
- Click OK.
- Select Build > Deploy Solution.
Pairing your developer-unlocked Microsoft HoloLens with Visual Studio
The first time you deploy from your development PC to your developer-unlocked Microsoft HoloLens, you will need to use a PIN to pair your PC with the Microsoft HoloLens.
- When you select Build > Deploy Solution, a dialog box will appear for Visual Studio to accept the PIN.
- On your Microsoft HoloLens, go to Settings > Update > For developers, and click on Pair.
- Type the PIN displayed by your Microsoft HoloLens into the Visual Studio dialog box and click OK.
- On your Microsoft HoloLens, select Done to accept the pairing.
- The solution will then start to deploy.
Deploying and running the sample
- To debug the sample and then run it, follow the steps listed above to connect your developer- unlocked Microsoft HoloLens, then press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or select Debug > Start Without Debugging.