This tutorial will show you how to create a basic Mixed Reality app using Babylon.js and Visual Studio Code. The app you’re going to build will render a cube, let you rotate it to bring the other faces into view, and add interactions. In this tutorial, you learn how to:
[!div class=”checklist”]
- Set up a development environment
- The Babylon.js API to create basic 3D elements
- Create a new web page
- Interact with 3D elements
- Run the application in a Windows Mixed Reality Simulator
To create this project from scratch, start with a Visual Studio Code (VSCode) project.
[!NOTE] Using VSCode isn’t mandatory, but we’ll be using it for convenience throughout the tutorial. More experienced JavaScript developers can use any other editor of their choice, even the simplest Notepad.
Create a basic html markup and reference the Babylon.js javascript file. The final code is as shown below:
<html>
<head>
<title>Babylon.js sample code</title>
<script src="https://cdn.babylonjs.com/babylon.js"></script>
</head>
<body>
</body>
</html>
Add a canvas HTML element inside the body to render the contents of Babylon.js. Note that the canvas has an id attribute, which lets you access this HTML element from JavaScript later on.
<html>
<head>
<title>Babylon.js sample code</title>
<script src="https://cdn.babylonjs.com/babylon.js"></script>
<style>
body,#renderCanvas { width: 100%; height: 100%;}
</style>
</head>
<body>
<canvas id="renderCanvas"></canvas>
</body>
</html>
[!div class=”nextstepaction”] Next Tutorial: 2. Prepare a scene