Sign in to follow this  
brianzinn

Highlighter not working in VR

Recommended Posts

I have the highlighter working in a regular scene.  In the VR scene the highlight is not appearing where the mesh is and with left/right eye it is in different positions.  Is this a bug or is using the Highlighter not supported with VR cameras?

Share this post


Link to post
Share on other sites

@DeltakoshThe bug is related to specifying a VR camera in highlighter options.
https://www.babylonjs-playground.com/#1KUJ0A#84

If I comment out line 39 (camera option) then the highlighter works as expected.  Additionally, if I am using a regular FreeCamera then it also works as expected.

I think the issue is here (and on line 430):

https://github.com/BabylonJS/Babylon.js/blob/2c0fa2446981bfb173cb7dca0fd76891e1b6e9be/src/Materials/Textures/babylon.renderTargetTexture.ts#L356

The cameras are the "same" camera, but not seen as the "same".  Their ids are: "WebVRCamera_L" and "WebVRCamera".

This code will fix the left camera to be working, but not right.

if (this.activeCamera !== scene.activeCamera &&
    (this.activeCamera.leftCamera && this.activeCamera.leftCamera !== scene.activeCamera)) {
    scene.setTransformMatrix(
        this.activeCamera.getViewMatrix(), 
        this.activeCamera.getProjectionMatrix(true)
    );
}

I think though, a better check would involve checking RigMode and a way on the camera classes themselves to determine equality. So, maybe better for someone more familiar with this code? I'm probably going to switch my highlighter code to GUI anyway, but wanted to share the cause + resolution.

Share this post


Link to post
Share on other sites

yes, as I said it works if you don't specify a camera.  I was just adding that the highlight layer would also work if RenderTargetTexture was updated to understand VR cameras, which seems more like an expected behaviour.  marking as solved!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.