Mouse-over on meshes with stereoscopic side by side parallel camera

I am loading a Babylon model (exported from Blender) with separate meshes, registering OnPointerOverTrigger/OnPointerOutTrigger actions with them for showing text labels and setting a basic ArcRotateCamera camera. So far so good, the labels show nicely when hovering the mesh(es) in the scene canvas. When I click an image button I want to switch to a stereoscopic sidebyside parallel view :

scene.activeCamera.setCameraRigMode(BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL, {interaxialDistance: 0.0637});
scene.activeCamera.attachControl(scene.canvas, true);
switch back to normal camera mode with same button : scene.activeCamera.setCameraRigMode(BABYLON.Camera.RIG_MODE_NONE, {interaxialDistance: 0} );

Switching works, in stereoscopic camera view mode the model is rendered nicely stereoscopic but mouse coordination + mouse-over is not properly aligned any more (off-target as if the mouse follows normal earlier arcrotate camera… I would like to use the 3D side by side modus on my monitor with passive 3D glasses and normal mouse if possible… Is there a simple way to get normal / correct mouse input, correctly aligned in the STEREOSCOPIC_SIDEBYSIDE_PARALLEL mode? Do I have to correct somewhere for the set interaxialDistance with this special camera setup to get correct actual mouse-over events on meshes in the scene in stereoscopic side-by-side mode?

1 Like

Hello and welcome!
I think I see what the problem is. The mouse has no idea that the screen is split so this could definitely be the root cause here

Would you mind reproduce your test in the playground? I’m gonna try to find a fix for you :wink:

Pinging @trevordev FYI

Thank you for the quick reply, I made a quick playground with just simple click event on mesh but got bit stuck as how to keep mouse cursor alive in the playground in full screen mode… : Babylon.js Playground

Might be handier to look at quick demo I made at 3D viewer
Here you can easily switch the camera back and forth to stereo with the glasses icon in top right corner. Normally I have anatomical models in the viewer with many meshes to easily switch on or off in the dropdown menu in 2,5 D, after that I like to demo them in Stereoscopic view .

@trevordev would you be ok to check next week?

No hurry. Just trying to see what is best possible approach for mouse-over (or other solution) for interacting in stereoscopic camera view.

Yea, this one might be tricky but luckily I think in your example there is not distortion in the view. I would try using the scene.onPointerObservable event to get the screen x/y position of the pointer and then transform the x (eg. valx2 for the left side of the screen and (val-screenWidth)x2 for the right side of the screen) then use scene.pick with those values instead and see if that works better.

Thanks for the good tips. It might take a while (busy with other projects and teaching now) but I will certainly try to test and implement a mouse solution this way in the stereoscopic view.

1 Like