WebXR in the Apple Vision Pro

Hi!

I’ve seen some people here have success getting Babylon WebXR to work with the Apple Vision Pro. I’m just wondering if you need specific settings to do this, since I’ve not been able to get a playground to run yet
I’ve tried these two example projects: https://playground.babylonjs.com/#F41V6N#32 and Babylon.js Playground but both don’t give me the WebXR button I’ve seen others get:


If anyone knows what needs to be done or added to make this work let me know :smiley:

Thanks!

Woops, nevermind, turns out you have to enable that :smiley: :

https://developer.apple.com/forums/thread/732629

4 Likes

I assume that you are using immersive-vr not immersive-ar right? At least I didn’t manage to do that.

Yeah, Vision pro will only work with immersive-vr, despite Apple’s claims that it’s definitely for sure AR :woman_shrugging:

That’s ridiculous I’m frustrated so I cannot imagine @RaananW feelings about that after as much work.

I wouldn’t waste energy on that :smiley: they do seem to be working on actual AR but that’s not ready yet. I just view the Vision Pro as a step in that direction. Just in your mind view the Vision Pro as very fancy VR instead of AR

yeah, don’t get me started on this one :slight_smile:

i would expect the vision pro to deliver first-class AR support. It has everything you need for that to work wonderfully. But it’s sadly not my decision…

Using AVP, I enabled all the experimental WebXR features but was getting a crash:

TypeError: Cannot read properties of undefined (reading ‘addOnce’)
at StandardMaterial._checkScenePerformancePriority (material.ts:1751:1)
at StandardMaterial.isReadyForSubMesh (standardMaterial.ts:1498:1)
at Mesh.render (mesh.ts:2333:1)
at SubMesh.render (subMesh.ts:427:1)
at RenderingGroup._RenderSorted (renderingGroup.js:217:1)
at RenderingGroup._renderAlphaTestSorted (renderingGroup.js:170:1)
at RenderingGroup.render (renderingGroup.js:116:1)
at RenderingManager.render (renderingManager.js:89:1)
at Scene._renderForCamera (scene.js:3523:1)
at Scene._processSubCameras (scene.js:3557:1)

This is the Babylon code:

protected _checkScenePerformancePriority() {
if (this._scene.performancePriority !== ScenePerformancePriority.BackwardCompatible) {
this.checkReadyOnlyOnce = true;
// re-set the flag when the perf priority changes
const observer = this._scene.onScenePerformancePriorityChangedObservable.addOnce(() => {
this.checkReadyOnlyOnce = false;
});
// if this material is disposed before the scene is disposed, cleanup the observer
this.onDisposeObservable.add(() => {
this._scene.onScenePerformancePriorityChangedObservable.remove(observer);
});
}
}

Adding

scene.performancePriority = ScenePerformancePriority.BackwardCompatible;

to my code fixed the issue.

However, teleportation isn’t working, I get a ray from my eyes when I pinch, but no torus and long pinch does nothing. I’ve defined floor meshes and my app works on MQP. Any ideas? 7.10.3

Cheers,
Paul

This is probably unrelated to the device you are running on. Would be better to start a new thread for that, but anyhow - can you share a reproduction? this should, of course, not happened.
Are you changing the performance priority beforehand?
The scene’s onScenePerformancePriorityChangedObservable property is generated during construction, so i find it interesting that it fails.

A reproduction would be very beneficial :slight_smile: Playground or a simple project i can checkout and run

You are correct, I get the same crash in AVP, MQP and the XR Emulator. I have a fairly large V5 codebase and just ripped out V5 and upgraded to V7. Its fairly hard for me to do a repro but I thought I would post here in case others encountered it, at the time I was thinking it was AVP specific. I am not changing performance priority or anything like that. It is likely some old imports from legacy that is causing it.

The more I look at it, the more I am wondering what is going on here :slight_smile:

At first i thought you are not passing the right scene, or not the scene object. But then you said you solved it by setting the performance priority on the scene object itself. Unless this is not a scene, it makes no sense for me. Are you sure the scene object is actually a babylon scene?

Yes, the more I look at it I start thinking its a red herring. The old V5 code does this

import * as BABYLON from ‘@babylonjs/core/Legacy/legacy’;
const scene = load(…)
callback(scene: BABYLON.Scene)

then in callback

import { Scene } from ‘@babylonjs/core’;

export function callback(scene: any) { // To get it to compile
const xr = await scene.createDefaultXRExperienceAsync({
floorMeshes: floor,
uiOptions: {
sessionMode: ‘immersive-vr’
}
});
}

So its just legacy stuff. Sorry!

1 Like