Polidea’s open-source project Sirius - a security tool for obfuscating code in iOS apps. Learn more about code obfuscation and our commercial support.
Have Fun with Nature—Polidea's VR Experience
We already had a chance to try some VR and AR technologies in a form of Polidea Labs projects—check Augmenting Reality on the web and Augmenting reality with an iPhone. The aim was to check the level of advancement of available tools and do some basic research. It was a great introduction to preparing a better demo. With the gathered knowledge we were able to create an interactive web VR experience in which we combined a beautiful design with a thoroughly-planned development.
About the project
It took us some time to finalize the concept of this app. We did a couple of prototypes on the way, since imagining how something should work in VR and actually making it happen are two different things. As WebVR is not suitable for high-quality rendering we decided to create a low-poly world, but improve the experience with a colorful landscape. By placing rocks from the menu on correct shapes on the stone in the middle, a user is able to change the scenery around them. You can try and play around with it yourself here. It works both in a desktop browser as a 360-degree mode and on mobile as a VR mode. You should definitely try it out on your VR headset.
Development and technology stack
You can check full source code on our github.
Even though VR and AR are still developing, there are a lot of various tools to choose from. Creating an app which will be available on as many platforms as possible was a fundamental argument in favor of choosing WebVR. On top of that, we decided to also use the A-Frame framework, which is very well documented. It easily integrates with a regular HTML, but you have to use dedicated markup tags. You might also use built-in JS functions to build more complex logic around simple HTML parameters.
For instance, we used
registerComponent to create an item parameter which will invoke specific behavior when it’s hovered in 3D. It has to define a schema aka a list of properties which will be interpreted by A-frame in the markup. Here’s the source code:
As you might have noticed, we are really fond of React in Polidea. Since the app was supposed to smoothly transition from 2D Landing Page to VR and also dynamically adapt to the gameplay state we’ve decided to use
aframe-react library and keep most of the code as React Components. It made a project more readable and well-organized. It’s wasn’t all roses, React DOM substitution mechanism doesn’t always play well along A-frame animations. We made it work, but we had to compromise between React and A-frame syntaxes.
One of the helpful tools we used during development was ngrok. It gives remote access to the app when you are developing it locally on your machine. We were able to instantly share and test each other's versions of the code and check them on various devices. It proved to be very useful as it turned out we had to debug code on Daydream and Gear VR devices. Unfortunately, the free version of ngrok is quite limited, but once you go premium it might boost your web development process significantly.
Challenges and tips
First of all, WebVR ecosystem still hasn’t matured enough. At the early stage of the project we used an A-frame redux library, which one week later was removed from NPM to make space for its successor. Fortunately, the newer version of the library turned out to be more intuitive and easy-to-use.
Still…be careful. If you are tempted to use experimental libraries—which utilize a well-known web development pattern—think it through; evaluate if you know it well enough to transition to a newer version or if you’re capable of fixing it yourself, when necessary.
There’s no good advice for a situation like this, but at this point it’s better to use the most stable A-frame libraries, even though they require you to write additional code. Remember to use a specific version in
yarn file, because even a small patch can break your project.
Commercial VR development practices are still developing and so is the VR design process. It was a challenge to build a process, where both designers and developers could work hand-in-hand, including rapid prototyping and 3D modeling. VR/AR designers needed to check if their vision “feels” good in VR. Developers also didn’t know if it’s possible to easily transform their concepts into a working application.
However, we transformed this ‘don’t know’ circle into a successful close agile collaboration. Instead of receiving all designs and UI project at the beginning, we were incrementally adding small components and testing. Some visual attributes were changed in the code, some required only 3D models improvements. At some point, it became as pleasant as assembling a Lego set. So don’t feel discouraged by frequent code changes, when developing a VR—try to use the most out of React and A-frame by smartly dividing your code into smaller components.
It was a challenge to make Daydream and GearVR controllers work properly, mostly due to a testing inconvenience. We were still developing and testing it mostly in a desktop browser, but as often as possible we were running it using NGROK on both Daydream and Samsung Gear VR devices.
Web VR and AR is still growing and is bound to rapidly evolve in the near future. Obviously, hardware ecosystem grows the fastest, so it will take some time for development technologies to catch up until they are reliable enough and easy to use in various situations. A-frame is definitely a framework you should choose if you are into web development and try to acquire new skills in VR and AR areas. There’s still a lot of room for discovering best design patterns, creating good development practices and building interesting VR or AR applications. In Polidea, we are not slowing down as we’re constantly improving the process of creating VR & AR applications.
- KatarzynaSoftware Engineer