Shifting VRPOV from player to VRBoids

do you mind pointing to me where in the docs you can change the position of the camera; e.g., the camera has no .setPosition method, or whatever

also, do you mind pointing me to this “teleportation” call thing?

I’m going to spend a bunch of hours on this this week, will probably log what I find here

also I’m now here, trying to figure out what’s what WebXR Device API

function initBoids() {
  boxes = loadCubes(20);
  xrCamera = new BABYLON.WebXRCamera("boidPOV", scene, xr.baseExperience.sessionManager);
  xrCamera.parent = models[0];          
  //I think that this is putting me into the boids POV for one frame
  xr.baseExperience.camera = xrCamera;
  console.log(xrCamera);
}
function camBoids() {
  //do I need to keep teleporting to the position of the boids?
  //well, I am at least calling the camera
  //xrCamera.cameraRotation.x = xrCamera.rotation.x + .0001;
  //console.log("hello");
  xr.baseExperience.camera = xrCamera;
}
xr.baseExperience.sessionManager.onXRSessionInit.add(initBoids);
xr.baseExperience.sessionManager.onXRFrameObservable.add(camBoids);

I guess it’s just highly mysterious to me that this doesn’t work; on going into XR I definitely pop into the POV of the boid, but it’s only for one frame. So, I got the other observable that calls every frame to fire off, thinking, maybe I just need to call xr.baseExperience.camera = xrCamera every frame, but that doesn’t do it.

I also just started manipulating the xrCamera for the first time:

function camBoids() {
          //do I need to keep teleporting to the position of the boids?
          //well, I am at least calling the camera
          xrCamera.cameraRotation.x = xrCamera.rotation.x + .0001;
          //console.log("hello");
          xr.baseExperience.camera = xrCamera;
        }
        xr.baseExperience.sessionManager.onXRSessionInit.add(initBoids);
        xr.baseExperience.sessionManager.onXRFrameObservable.add(camBoids);

So, at least I know how to mess with the camera a little bit now; it’s a start.

Have you went through our webxr documentation? Introduction to WebXR - Babylon.js Documentation

Everything is explained there. and if it isn’t, or something not clear, I usually update it a day after. The camera is explained in detail - The WebXR Camera - Babylon.js Documentation

I have but let me do it again and see if I can find more specific questions and/or if I missed something.

Thank you!

I also definitely missed this on my first time around: WebXR Selected Features - Babylon.js Documentation

er… why does this come up empty

console.log(xr.baseExperience.sessionManager.currentFrame.XRFrame.device.position);

“undefined” when I can navigate to the “emulatedXR device” in the console?

I’m going to try to control the XRFrame position, and pin that to a boid’s position

bc it looks like the position is set by XRFrame, not the XRCamera

The frame’s position comes from the device itself. You can’t control it nor can you ask for it the way you do. Check the WebXR draft if you want to understand how it works.

The camera’s position is set by the xrframe, but you can still change its position and it will update the offset of the XR scene.

I can now rotate and transform the xr camera; I’m not sure why the hell I didn’t put that together-- sighs.

      //rotating camera
      //xr.baseExperience.camera.cameraRotation.y = xr.baseExperience.camera.cameraRotation.y +.005;
      xr.baseExperience.camera._position._y = xr.baseExperience.camera._position._y +.005;

I’m learning more about what I can specifically control, upvector, direction, yada yada, in order to associatie it with the boid, so, some progress.

      xr.baseExperience.camera._position._x = models[0].boid.position._x;
      xr.baseExperience.camera._position._y = models[0].boid.position._y;
      xr.baseExperience.camera._position._z = models[0].boid.position._z;

I am now tracking the position of a boid in xyz space

I now have to mimic it’s direction, get the camera looking in the front

So, on my way; ps, this is insane.

actually realized that doesn’t make sense bc you can look anywhere… so I think I’ve achieved my objective.

thank you so much for your help and the documentation