setTarget() and .position have no effect on DeviceOrientationCamera in WebXR immersive mode

Using: BabylonJS 4.2. Testing with Chrome with the WebXR emulator and with Oculus Go.

I’m creating a virtual art gallery. Each photo (plane) has an OnPickTrigger action manager set to reposition the camera (DeviceOrientationCamera) to view that photo dead-on from a comfortable distance. Basically, clicking on a photo should teleport the viewer in front of it.

// "photo" is a plane mesh with a photograph material 
photo.actionManager = new ActionManager(scene)
	new BABYLON.ExecuteCodeAction(
			trigger: BABYLON.ActionManager.OnPickTrigger,
		function () {
			//center camera in front of photo
			camera.position.y = photo.position.y
			camera.position.x = photo.position.x
			camera.position.z = photo.position.z - height * 1.5
			photo.position.x += 1

Everything is working great in Chrome in normal 2D mode, but both using the Chrome WebXR emulator and my Oculus Go, the clicking on the photo with the controller doesn’t change the camera direction or position.

That last line of the action is how I know the event is firing – it moves the photo over a bit each time I click on the photo.

My development server is using https, so head-tracking and whatnot are working fine, I just can’t seem to move and target the VR camera.

Is another camera object being created during the immersive session that I need to somehow get a reference to? Or is there something I need to do to temporarily override the camera being controlled by the headset telemetry?


Indeed, createDefaultXRExperienceAsync does create a new camera. I was able to switch to using scene.activeCamera (didn’t know about this property) in my actionManager functions, which seems to return the correct camera for both immersive and browser window modes.

1 Like