Jump to content

Selecting mesh without gamepads and controllers


oschakravarthi
 Share

Recommended Posts

Hi,

 

My application should be able to work just with a mobile in a simple cardboard which has no controllers, gamepads and buttons. The user should be able to select meshes. So, the only way to select a mesh is by not moving camera from it for some time (lets say 3 seconds). During this time, the gaze should show a progress bar or a rotating circle. 

How can I achieve this? Struggling for more than a week on this. In three.js it is just one line of code. Can you please help me on this?

Thanks in advance.

Link to comment
Share on other sites

See this playground https://www.babylonjs-playground.com/#Q1VRX3#12 . Getting the forward ray from the webVR helper is a little weird but after getting that you can check to see if an object his hit by the ray, if it is, start incrementing some value or starting a timer. When it reaches the timeout value run your click logic. Let me know if that doesn't work.

Link to comment
Share on other sites

This is a lot more than 1 line of code, but works well with cardboard.
https://www.babylonjs-playground.com/#ZGNHW1

That PG is from the very earliest days even before the VR Experience Helper.  From the reply from trevordev, it does not look like the VR Experience Helper has built-in support for cardboard gaze.  Also, the cardboard does have a button, at least the one from google :)

Link to comment
Share on other sites

Hi @Deltakosh

Thanks for your response.

I am doing something like this.

 

At the creation of the scene, I am creating rat target mesh.

I am creating vrExperienceHelper just to get the VR button in the bottom of the webpage to switch to VR mode. As I don't have any controllers or gamepads, I cannot perform anything more with vr helper.

 var rayTargetMesh = createRayTargetMesh();'

var vrHelper = scene.createDefaultVRExperience();
            vrHelper.enableInteractions(); // No controllers. so it is useless.
            vrHelper.displayLaserPointer = true;
            vrHelper.displayGaze = true;

 


function createRayTargetMesh() {
    var target = BABYLON.Mesh.CreatePlane("targetViewVR");
    var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateForMesh(target, 2048, 2048);
    var circle = new BABYLON.GUI.Ellipse();
    circle.width = "50px";
    circle.color = "white";
    circle.thickness = 15;
    circle.height = "50px";
    advancedTexture.addControl(circle);
    target.scaling = new BABYLON.Vector3(1, 1, 1);
    target.isPickable = false;
    return target;
}

//gui panel is of type BABYLON.GUI.CylinderPanel

//All the controls of this panel are of type BABYLON.GUI.HolographicButton

 

scene.registerBeforeRender(function () {

  var camera = vrHelper.currentVRCamera; //As we dont know which camera is active, I always set parent of my   rayTargetMesh to the current camera.
  rayTargetMesh.parent = camera;
  rayTargetMesh.position.z = 1.1;

 var ray = camera.getForwardRay();

if (guiPanel.children.length > 0) {
        guiPanel.children.forEach(function (c) {
            var pickingInfo = ray.intersectsMesh(c.mesh);
            if (pickingInfo.hit) {
                var pickedMesh = pickingInfo.pickedMesh;

                if (pickedMesh) {
                    ///Clicked on c
                    return;
                }
            }
        });
    }

});

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...