navigator.xr.requestSession
call after the page initialization is finished.init.js
, at the end of the init
function definition:export async function init(setupScene = () => {}, onFrame = () => {}) {
// Other setup code...
if (navigator.xr && navigator.xr.isSessionSupported) {
navigator.xr.isSessionSupported('immersive-vr').then((supported) => {
if (supported && navigator.xr.requestSession) {
navigator.xr.requestSession('immersive-vr', {
optionalFeatures: ['REQUIRED_FEATURES'],
})
.then((session) => {renderer.xr.setSession(session);});
}
});
}
}
<script type="text/javascript">
const scene = document.querySelector('a-scene');
if (scene.hasLoaded) {
run();
} else {
scene.addEventListener('renderstart', run);
}
function run() {
scene.enterVR();
}
</script>
manifest.webmanifest
”, and copy the following contents to the file:
{
"short_name": "PWA Name",
"name": "Full name of your PWA",
"icons": [
{
"src": "/images/icons-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/images/icons-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "https://domain.com/startpage/",
"scope": "https://domain.com/",
}
Name | Required / Optional | Description |
---|---|---|
Required | The name of your PWA. Currently we only support left-to-right languages for the name. | |
Optional | A shorter version of the app name, if needed. | |
Optional | You can specify a starting URL to load. If not provided, this will be derived from the web-manifest-url . The start page for your PWA should provide direct access to your App’s functionality or a login screen that proceeds to your App’s functionality. It should not be a marketing or information page. At least one of the start_url and web-manifest-url must be provided (both cannot be missing). | |
Optional | This field allows you to specify what URL or paths should be considered as part of your app. It’s not required and you don’t need to put a value unless you have specific requirements, such as excluding portions of your website from your PWA. If not provided, this will be derived from the start_url field or the web-manifest-url parameter (whichever is provided, see information on those fields). | |
Optional | It is used to specify one or more image files that define the icons to represent your web application. The icon image is going to be used by the UI bar in Meta Horizon OS. |
requestSession
API?requestSession
after the page load only in a PWA?requestSession
to make sure you are under a PWA scope.if (window.getDigitalGoodsService !== undefined) {
// Add your requestSession related logic here
}
chrome://inspect
after your WebXR PWA is launched. Click inspect to start debugging that tab in Browser.