Problem with VrExperienceHelper and Camera

Hi there,
I have found a bug with setCamera().
https://www.babylonjs-playground.com/#14KRGG#174
In this playground , you will see that if I setTarget before the creation of the VrExperienceHelper, it’s working, but if I build the VrExperienceHelper before the function setCamera it’s not working.
I hope you will be able to fix that issue, because I would like to use the function setTarget many times and after the VrExperienceHelper :slight_smile:

@trevordev

Thank you, Take care

Hi @Mathieu

I guess it’s on mobile because I can’t reproduce it on desktop with Chrome or FireFox.

Euh on destop too :slight_smile: But yes my priority is on mobile, but I have the app on destop too, but this playground show you the problem, isn’t it ?

Adding @RaananW

Nop :frowning:
Calling setTarget before or after createDefaultVRExperience works for me. Chrome and Firefox.

which version of chrome are you using ? Because it’s not working for me and I have the last version :confused:
Doesn’t work on firefox too :confused:

Hi guys. What’s happening… is that createDefaultVRExperience is changing scene.activeCamera. It becomes a deviceOrientationCamera… and MAYBE devO cams have a .target… but I’m not sure. Either way… Mathieu would need to use scene.activeCamera.setTarget() or similar.

https://www.babylonjs-playground.com/#11GAIH#67
(At console, you can see the devO cam get installed in scene.activeCamera. I force it back to being mattcamm, and then stuff starts working.)

In docs - options… it states… createDeviceOrientationCamera(default: true): If the non-WebVR camera should be created. To use an existing camera, create it and then initialize the helper with this set to false in the constructor.

So… Mathieu needs to use: var vrHelper = scene.createDefaultVRExperience({createDeviceOrientationCamera: false});

https://www.babylonjs-playground.com/#11GAIH#68

Now we have good target-setting, because mattcamm stays installed as scene.activeCamera. No bug.

We COULD add an example of using constructor options… just below Options section of docs. :slight_smile:

Possibly… a console warning could be issued… from .setTarget method… IF user calls setTarget() on a cam that is not currently === scene.activeCamera. Just thinkin’. That might be a bad idea, though… as user/progger SHOULD freely be allowed to set targets on inactive cameras.

1 Like