Building Fun Experiments with WebXR & Babylon.js

Rate this content
Bookmark

During this session, we’ll see a couple of demos of what you can do using WebXR, with Babylon.js. From VR audio experiments, to casual gaming in VR on an arcade machine up to more serious usage to create new ways of collaboration using either AR or VR, you should have a pretty good understanding of what you can do today.


Check the article as well to see the full content including code samples: article

FAQ

WebXR is a web API that enables the creation of both virtual reality (VR) and augmented reality (AR) experiences. It supports a range of devices including Oculus Quest 2, HTC Vive, Valve Index, and HoloLens 2. WebXR is a development from WebVR, focusing on providing both VR and AR capabilities.

Babylon.js is an open-source 3D engine that runs on top of WebGL and WebGPU. It supports WebXR out of the box and is used for developing immersive 3D and XR applications. It's written in TypeScript, enhancing code quality and development experience with features like auto-completion.

To start developing with Babylon.js, you can visit the project's website and follow the documentation to learn about its features and how to use them in your projects. Babylon.js provides extensive support for 3D graphics and XR applications, making it suitable for a variety of use cases.

WebXR supports a variety of devices for immersive experiences, including VR devices like Oculus Quest 2, HTC Vive, and Valve Index, as well as AR devices such as smartphones with Android OS and Microsoft's HoloLens 2. It is also supported by Chromium-based browsers like Chrome, Microsoft Edge, and Samsung Internet on Android.

Yes, Babylon.js is licensed under the Apache 2 license, allowing it to be used freely for both personal and commercial projects. It is widely adopted in industry, including by companies like Microsoft, Adobe, Sony, and Ubisoft for various applications.

Babylon.js supports VR and AR through its integration with WebXR. It offers features like spatial audio for VR, dynamic textures for AR, and out-of-the-box support for VR controllers. Developers can easily create immersive experiences that work across multiple types of devices.

Babylon.js is primarily written in TypeScript, which offers advantages such as strong typing and object-oriented features. This makes it easier to develop complex applications with improved code quality and maintainability.

David Rousset
David Rousset
33 min
07 Apr, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk explores the use of Babylon.js and WebXR to create immersive VR and AR experiences on the web. It showcases various demos, including transforming a 2D game into a 3D and VR experience, VR music composition, AR demos, and exploring a virtual museum. The speaker emphasizes the potential of web development in the metaverse and mentions the use of WebXR in Microsoft products. The limitations of WebXR on Safari iOS are discussed, along with the simplicity and features of Babylon.js. Contact information is provided for further inquiries.

1. Introduction to Web XR and Babylon GS

Short description:

Hello, I'm David from Microsoft. Today, I'll show you web XR experiments using Babylon JS, a 3D engine running on WebGL and WebGPU. Web XR enables both VR and AR experiences on different devices. It's a replacement for web VR and currently supported in Chromium browsers. Babylon GS is an open-source framework that supports WebXR and provides great features like auto completion and spatialization in VR. It's widely used in Microsoft applications.

Hello, my name is David. I'm working at Microsoft and today I'm going to show you some web XR experiments using Babylon JS. It's going to be fun.

I'm going to show you a lot of different samples and let's have a look together what you can do today with web XR. So I'm working in the developer division of Microsoft, the people in charge of GitHub, VS Code, Visual Studio, some Azure features too. But today I'm going to talk about WebGL and web XR.

So feel free to follow me on Twitter if you've got questions after the talk. So what is web XR? So probably you've heard about that, but let's briefly define before having some demos about this technology. So web XR is a web API obviously, that can enable both virtual reality, so using Oculus Quest 2, HTC Vive headsets or Valve Index, but also AR using either smartphone, using Android OS. But also the HoloLens 2 can support the AR feature of web XR. So it's a replacement of web VR, if you heard about web VR before. So it was only doing VR and there's been some refactor around the API. And also it's supporting currently only in Chromium browser, so Microsoft Edge, Chrome of course, but also Samsung internet on Android, and also obviously, Chrome on Android. So I already talk about the various hardware supported.

And today we're going to talk about Babylon GS. So Babylon GS, this is a 3D engine I've been working on a couple of years ago with a friend of mine, so that's why it's my little baby in a way. And if you'd like to start on Babylon GS, feel free to have a link below, but we're going to see that just after that. So Babylon GS, if you don't know what Babylon GS is yet, it's a 3D open source engine running on top of WebGL, but also WebGPU today. We're supporting WebGPU. We are using Web Audio, which could be great for spatialization in VR. And we are supporting WebXR out of the box. It's an open source framework using the Apache 2 license. A lot of contribution from the community. More than half of the code source now come from the community. Completely written in TypeScript, which enables great features like auto completion and quality of the code, generally thanks to types. And it supports WebXR out of the box, also using controls already for VR. You have a lot of controls that work in 2D with mouse and VR thanks to the pointer elements. Soon we have MRTK, which is mixed reality tool kit coming to Babylon GS version 5. That will enable even more control for productivity. It's being used today by a lot of first-party applications in Microsoft, so PowerPoint, like the 3D model you have on your screen.

2. WebXR Demos and VR Experience

Short description:

SharePoint, Teams. Also, the XCloud, the cloud gaming service of Xbox is using Babylon GS for the touch control. Later on, I will publish a blog post on my blog to share the source code of all the demos. First, we're going to use the super simple, but yet super powerful feature named the XR Experience. We're using this line of code. If you don't have a VR headset, what you can install is an extension in Chrome or Edge named the WebXR extension. And if you have this extension enabled, you will have this button being there asking you to switch into a immersive mode. So very useful, you see one line of code and really have an experience running out of the box and you can exit the immersive mode to go back to the classical mode, I would say. But let's have a look how it works in a real headset like the Valve Index in my case. So let's switch back to my powerpoint presentation and this time will be a video of me inside this room reusing it. And you see that in the headset obviously, I've got a stereoscopic rendering. I'm using there the VR view of SteamVR on Windows and you see the immersive experience, so you have to one day try it using any kind of headset compatible with WebXR like Valve Index on Desktop but also Xerox Oculus Quest 2 and you have like super cool immersive experience with only one line of code once again and we manage for you all the teleportation, display of the controllers, stuff like that. So you see, super easy to enable.

SharePoint, Teams. Also, the XCloud, the cloud gaming service of Xbox is using Babylon GS for the touch control. It's being used by Adobe, some partners, Sony and the US Army or Ubisoft.

So let's jump into some fun demos. Later on, I will publish a blog post on my blog to share the source code of all the demos, but we have only 20 minutes, so let's just see what you can do with WebXR if you don't know yet what you can do with it.

First, we're going to use the super simple, but yet super powerful feature named the XR Experience. We're using this line of code. Using only one line of code, you will enable some VR experience in our case. So I'm going to jump into Chrome for now. So you see this scene, which only loads this scene valley with Hill Valley from Back to the Future 3D scene, and once the scene has been loaded in this callback code, what I'm going to ask to Babylon.js, using this single line of code, is please turn this existing experience into a VR compatible experience. You need to provide only one parameter, which is what should act as a floor to support the teleportation target we're going to see in video just after that.

If you don't have a VR headset, what you can install is an extension in Chrome or Edge named the WebXR extension, so you can search for it in your favorite search engine. And if you have this extension enabled, you will have this button being there asking you to switch into a immersive mode. So I'm going to click on this button, it's going to render, you know, for left eye and right eye for stereoscopic rendering. And to be able to simulate a VR headset, you need to press the F12 key and then you will have a new WebXR there property. So let's snap that on the right and this one on the left. And let's try to, for instance, move the headset. You see I can move on the various side to simulate the fact that you're moving, but also obviously the controller and you can also switch from Quest by default to HTC Vive. And you see that Babylon JS is getting the right model out of the box, downloading it from our CDN. So let's switch back to a Oculus Quest. So very useful, you see one line of code and really have an experience running out of the box and you can exit the immersive mode to go back to the classical mode, I would say. So super easy to have a first experience, just load a scene, add this line of code and it will work. But let's have a look how it works in a real headset like the Valve Index in my case. So let's switch back to my powerpoint presentation and this time will be a video of me inside this room reusing it. So you see that we can point on the floor and teleport, choose the orientation when you will arrive on the target. So I decided to face the door of the DeLorean there. Then I can move away and face the front of the car. And you see that in the headset obviously, I've got a stereoscopic rendering. I'm using there the VR view of SteamVR on Windows and you see the immersive experience, so you have to one day try it using any kind of headset compatible with WebXR like Valve Index on Desktop but also Xerox Oculus Quest 2 and you have like super cool immersive experience with only one line of code once again and we manage for you all the teleportation, display of the controllers, stuff like that. So you see, super easy to enable.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Optimizing HTML5 Games: 10 Years of Learnings
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Optimizing HTML5 Games: 10 Years of Learnings
Top Content
The open source PlayCanvas game engine is built specifically for the browser, incorporating 10 years of learnings about optimization. In this talk, you will discover the secret sauce that enables PlayCanvas to generate games with lightning fast load times and rock solid frame rates.
Making Awesome Games with LittleJS
JS GameDev Summit 2022JS GameDev Summit 2022
34 min
Making Awesome Games with LittleJS
LittleJS is a super lightweight game engine that is easy to use and powerfully fast. The developer will talk about why he made it, what it does, and how you can use it to create your own games. The talk will include a demonstration of how to build a small game from scratch with LittleJS.
How Not to Build a Video Game
React Summit 2023React Summit 2023
32 min
How Not to Build a Video Game
In this talk we'll delve into the art of creating something meaningful and fulfilling. Through the lens of my own journey of rediscovering my passion for coding and building a video game from the ground up with JavaScript and React, we will explore the trade-offs between easy solutions and fast performance. You will gain valuable insights into rapid prototyping, test infrastructure, and a range of CSS tricks that can be applied to both game development and your day-to-day work.
Boost the Performance of Your WebGL Unity Games!
JS GameDev Summit 2023JS GameDev Summit 2023
7 min
Boost the Performance of Your WebGL Unity Games!
Unity, when deployed on the web, faces three critical challenges: build size, memory usage, and overall performance. This lecture delves deep into advanced optimization techniques to help you address each of these issues. Attendees will gain insights into:
- Effective strategies for optimizing textures, audio, and models.- A detailed analysis of our ASTC experimentation with Unity, shedding light on the unexpected results despite Unity's claims.- A comprehensive guide to Unity's memory profiling tool and its implications.- An exploration of lesser-known Unity settings that remain underutilized by many developers.
Additionally, we'll introduce our proprietary tool designed specifically for Unity optimization. We will also showcase CrazyGames' developer dashboard, our platform that enables developers to monitor and enhance the performance of their web-based games seamlessly. 
Join us to equip yourself with the latest strategies and tools to elevate your Unity web gaming projects.
How to Make a Web Game All by Yourself
JS GameDev Summit 2023JS GameDev Summit 2023
27 min
How to Make a Web Game All by Yourself
It's never been easier to make your own web game, but it's still extremely difficult. What game should you make? Which engine should you choose? Let's discuss how to answer these problems and ways to leverage the unique platform that is the web.

Workshops on related topic

Make a Game With PlayCanvas in 2 Hours
JSNation 2023JSNation 2023
116 min
Make a Game With PlayCanvas in 2 Hours
Top Content
Featured WorkshopFree
Steven Yau
Steven Yau
In this workshop, we’ll build a game using the PlayCanvas WebGL engine from start to finish. From development to publishing, we’ll cover the most crucial features such as scripting, UI creation and much more.
Table of the content:- Introduction- Intro to PlayCanvas- What we will be building- Adding a character model and animation- Making the character move with scripts- 'Fake' running- Adding obstacles- Detecting collisions- Adding a score counter- Game over and restarting- Wrap up!- Questions
Workshop levelFamiliarity with game engines and game development aspects is recommended, but not required.
PlayCanvas End-to-End : the quick version
JS GameDev Summit 2022JS GameDev Summit 2022
121 min
PlayCanvas End-to-End : the quick version
Top Content
WorkshopFree
João Ruschel
João Ruschel
In this workshop, we’ll build a complete game using the PlayCanvas engine while learning the best practices for project management. From development to publishing, we’ll cover the most crucial features such as asset management, scripting, audio, debugging, and much more.
Introduction to WebXR with Babylon.js
JS GameDev Summit 2022JS GameDev Summit 2022
86 min
Introduction to WebXR with Babylon.js
Workshop
Gustavo Cordido
Gustavo Cordido
In this workshop, we'll introduce you to the core concepts of building Mixed Reality experiences with WebXR and Balon.js.
You'll learn the following:- How to add 3D mesh objects and buttons to a scene- How to use procedural textures- How to add actions to objects- How to take advantage of the default Cross Reality (XR) experience- How to add physics to a scene
For the first project in this workshop, you'll create an interactive Mixed Reality experience that'll display basketball player stats to fans and coaches. For the second project in this workshop, you'll create a voice activated WebXR app using Balon.js and Azure Speech-to-Text. You'll then deploy the web app using Static Website Hosting provided Azure Blob Storage.