API

Babylon.js and heyVR.io

heyVR.io is a publishing platform for WebXR games, giving you access to a global audience of hundreds of thousands of players across multiple devices.

It offers a wide range of ready-to-use gameplay features to enhance your players' experience and enable you to start earning from your game through in-game content sales and advertisements.

Publishing Flow

heyVR.io is free to use, both for players and game developers. Developers can create an account on the Developer Area and publish their games free of charge. To read more about how the process works, please refer to the documentation on Publishing Flow.

SDK Implementation

While implementing the heyVR SDK in your games is completely optional, it's highly recommended that you take advantage of the SDK to further enhance your game and make use of features such as save games, leaderboards, inventory, etc. to provide a better user experience.

heyVR offers two different ways to integrate the SDK into your Babylon.js game. Depending on your development environment, you can proceed with either of them.

1) Built-in SDK

Every game submitted on heyVR has the option to enable the built-in SDK. This injects the SDK into the game at runtime.

1.1) Installation

The built-in SDK does not require any installation. To enable the built-in SDK, all you need to do is choose an SDK version for your build before uploading it. You can read more about this on the documentation website.

If you're using TypeScript, you can install the type definition package for the built-in SDK. Simply run: npm i @heyvr/sdk-types -D in your project's root directory.

1.2) Basic Usage

Since the SDK loads asynchronously, it's important to make sure it's been loaded before making calls. To do so, you can listen to the event that's dispatched by the SDK on load:

const doStuff= () => 'Executed on SDK load'
window.heyVR ?
doStuff() :
window.addEventListener( 'heyVR.SDKLoaded', doStuff );

Once the SDK is loaded, all the methods are available via the window.heyVR object. Here's a simple example of checking a user's authentication status:

window.heyVR.user.isLoggedIn()
.then( () => console.log( 'User is authenticated!' ) )
.catch( () => console.warn( 'User is not logged in.' ) );

The SDK offers extensive methods and functionality, including a sandbox version that allows your game to use the SDK features locally. To read about how to use these features, please consult the SDK documentation.

2) NPM Package

You might be using NPM to manage your game's dependencies. In that case, you can take advantage of the NPM package that heyVR provides.

2.1) Installation

You can install the package by running the following command in your project:

npm i @heyvr/sdk-gameplay

The package already includes the type definitions, in case you're using TypeScript.

2.2) Basic Usage

The package's API is extremely similar to the built-in SDK. You can start by importing the pieces that you need. Let's replicate the previous example.

import {User} from "@heyvr/sdk-gameplay/dist";
User.isLoggedIn()
.then( () => console.log( 'User is authenticated!' ) )
.catch( () => console.warn( 'User is not logged in.' ) );

The package also includes a sandbox version. For detailed instructions on how to use the package, check out the documentation on NPM Package.