Babylon.js icon indicating copy to clipboard operation
Babylon.js copied to clipboard

[XR] Add ability to toggle Spectator Mode and provide configurable frame rate

Open darkverse opened this issue 4 years ago • 2 comments

Spectator Mode in XR has been recently added however there is no method to disable the spectator mode once it is enabled (apart from manually clearing the activeCameras array). I have a situation where I am streaming the spectator view to a monitoring (peer) app and, for performance reasons, I would like to be able to toggle the spectator mode on/off as required.

As mentioned, I would like to be able to toggle the spectator mode on/off so perhaps provide a parameter to the helper function to specify whether to enable/disable. In addition, because the user experience in the headset is a priority and the monitor spectator view is low priority perhaps being able to specify a lower frame rate for the spectator mode, ie it is not required to run at the full frame rate of the user in XR. So perhaps something like enableSpectatorMode(enable=false, options={}) where options can contain options.fps and the spectator canvas is only updated according to that frame rate.

Discussed with @RaananW here https://forum.babylonjs.com/t/webxr-render-canvas-and-streaming/20893/33

darkverse avatar Aug 09 '21 06:08 darkverse

I am going to help work on this. If there is a spectator mode demo from Babylon.js, that would be a big help.

daoshengmu avatar Jan 25 '22 09:01 daoshengmu

Spectator mode is being enabled using the experience helper. It is a single call to this function:

https://github.com/BabylonJS/Babylon.js/blob/master/src/XR/webXRExperienceHelper.ts#L218

Options variable can be added to this function, i guess?

RaananW avatar Jan 25 '22 18:01 RaananW