In portrait mode, the perspective of AR marker content doesn’t quite line up with the real world camera. Augmented objects skew out of alignment one way or another when the phone is moved. Switching the phone to landscape and viewing it that way produces correct results. So it seems the game content and video are being scaled differently in portrait mode, but correctly in landscape.
I tried adjusting a few things in the scene rendering and camera settings. These changes either didn’t work or caused other problems. Is there some other setting or something in the script I should be looking for?
Edit: Found the orientation code. Maybe the FOV isn’t actually being set properly here?
ArCamera.prototype.onResize = function () {
if (!this.arController) return;
var device = this.app.graphicsDevice;
var cw = device.width;
var ch = device.height;
var vw = this.video.videoWidth;
var vh = this.video.videoHeight;
// Resize the video texture
if (this.entity.model && this.entity.model.model) {
var material = this.entity.model.model.meshInstances[0].material;
material.setParameter('uVideoSize', new Float32Array([vw, vh]));
material.setParameter('uCanvasSize', new Float32Array([cw, ch]));
}
// Resize the 3D camera frustum (via the fov)
var camMatrix = this.arController.getCameraMatrix();
var fovy = 2 * Math.atan(1 / camMatrix[5]) * 180 / Math.PI;
this.arController.orientation = (vw < vh) ? 'portrait' : 'landscape';
if (vw < vh) {
this.entity.camera.fov = Math.abs(fovy) * (vh / vw);
} else {
if (cw / ch > vw / vh) {
// Video Y FOV is limited so we must limit 3D camera FOV to match
this.entity.camera.fov = Math.abs(fovy) * (vw / vh) / (cw / ch);
} else {
// Video Y FOV is limited so we must limit 3D camera FOV to match
this.entity.camera.fov = Math.abs(fovy);
}
}
};
Edit: Screenshots attached to demonstrate the problem. It’s more obvious when you move around to different vantage points where the object is always slightly too close to the camera, misaligned from surrounding lines of perspective, and seeming like it’s dipping into the ground away from the camera. Meanwhile in landscape mode, it’s consistently lines up with the marker’s transformation from any angle.