From 500475c3108950b518e16491585c7fef91d06a3c Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Wed, 28 Aug 2024 20:08:14 +0100 Subject: [PATCH] Fix 3D Gaussian Splat rendering in VR (#6896) --- src/scene/gsplat/gsplat-instance.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/scene/gsplat/gsplat-instance.js b/src/scene/gsplat/gsplat-instance.js index aff797406dd..2ffbc1e04e3 100644 --- a/src/scene/gsplat/gsplat-instance.js +++ b/src/scene/gsplat/gsplat-instance.js @@ -166,6 +166,16 @@ class GSplatInstance { const device = this.splat.device; viewport[0] = device.width; viewport[1] = device.height; + + // adjust viewport for stereoscopic VR sessions + if (this.cameras.length > 0) { + const camera = this.cameras[0]; + const xr = camera.xr; + if (xr && xr.active && xr.views.list.length === 2) { + viewport[0] /= 2; + } + } + this.material.setParameter('viewport', viewport); }