Updating lines in VR (they exist, but dynamically updating them...)

Hi There,

  1. BC I am semi-new to all this. Can you explain a little bit (or link to advice and/or documentation) about the the proper method (and/or just general suggestions) about how you make a playground from a large codebase? Maybe my codebase isn’t large in the scope of things, but to me, it feels large, which is why I have resisted playground-ifying it. I’m wondering if you think that making a playground also disentangles things that might be interfering with each other, and in that way it is a good exericise, and it might help someone figure out the problem they’re facing. <-- Did I get all this correct?

  2. Isn’t the reference to this “xr.baseExperience.camera._position._z” VR-y? It sounds like you’re saying if this is a regular camera, it would work the same way; so, in that way, it’s not VR-y. What’s so confusing to me about the behavior I’m witnessing is that:

(a.) I think I’m just setting the initial points on a line to the position of the VR camera, but I believe what I’m seeing is that somehow the + 0.5 is actually moving the VR camera, and I don’t understand why… (it’s almost like I wrote xr.baseExperience.camera._position._y = xr.baseExperience.camera._position._y + 0.5, that’s the kind of behavior I’m seeing).

And (b.) even though I offset the origination point of the lines by 0.5, they still appear to be coming directly out of my face in VR… (i.e. even though I change y, it doesn’t affect the origination point of the lines, e.g. I could write xr.baseExperience.camera._position._y + 100, and I’d still have lines coming out of my face…).

  1. Oh, thanks for that, I will change it.

  2. And yes, oops, minor error.

  3. Just by the way, I’m doing an intensive JS tutorial for myself on some things I’ve found confusing (like async f(x)'s) and I’m also looking for babylon tutoring (going back and forth with some community members now). Definitely super excited/committed to the framework/platform.

Thanks Again.

1 Like
//line origination point
            lineCollector[i][0].x = 0; //xr.baseExperience.camera.position.x;
            lineCollector[i][0].y = 0; //xr.baseExperience.camera.position.y - 0.5;
            lineCollector[i][0].z = 0; //xr.baseExperience.camera.position.z;

Yep, something is way off. On a hunch I set what I thought the originating point of my updateable lines should be to 0, expecting to see the lines all start at the center of the xyz axis; instead, it sets my viewport in VR to 0,0,0; so, now, I’m completely befuddled. Why is this variable re-setting my viewport, instead of my lines? @Evgeni_Popov maybe you have some thoughts.

UPDATE, I may have figured this out… forthcoming; I did something terribly dumb earlier up in the code… :rofl:

OK, I’m closer. So, from testing the hunch above, I realized I had to look at all of my lines code all over again (line by line) and I saw this:

    //playerBoidLine.push(xr.baseExperience.camera.position);
    //playerBoidLine.push(models[i].boid.position); //getBoundingInfo().boundingSphere.center);

When I initalized the lines and made a horrible horrible mistake. I reinitialized the lines to this:

    playerBoidLine.push(new BABYLON.Vector3(0,0,0));
    playerBoidLine.push(new BABYLON.Vector3(0,0,0));

And now it basically works.

Take a look at this video (aside from being really cool), lol, the lines work, I just have to figure out why they are disappearing when I am not looking down: https://www.instagram.com/p/CHjLtbGBbQS/ .

1 Like

My guess would be that their center is not in the camera’s frustum and they are not being rendered because of that. set them to always be active (mesh.alwaysSelectAsActiveMesh). Try that, might be the fix you were looking for :slight_smile:

1 Like

Yup, it works. This is all so fun and crazy. Thank you!

1 Like