Skip to content

Commit 86a0197

Browse files
authored
Gsplat viewport size fix (#7425)
1 parent b56a3d5 commit 86a0197

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/scene/gsplat/gsplat-instance.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,18 @@ class GSplatInstance {
166166
}
167167
}
168168

169-
updateViewport() {
170-
// TODO: improve, needs to handle render targets of different sizes
171-
const device = this.splat.device;
172-
viewport[0] = device.width;
173-
viewport[1] = device.height;
169+
updateViewport(cameraNode) {
170+
const camera = cameraNode?.camera;
171+
const renderTarget = camera?.renderTarget;
172+
const { width, height } = renderTarget ?? this.splat.device;
173+
174+
viewport[0] = width;
175+
viewport[1] = height;
174176

175177
// adjust viewport for stereoscopic VR sessions
176-
if (this.cameras.length > 0) {
177-
const camera = this.cameras[0];
178-
const xr = camera.xr;
179-
if (xr && xr.active && xr.views.list.length === 2) {
180-
viewport[0] /= 2;
181-
}
178+
const xr = camera?.xr;
179+
if (xr?.active && xr.views.list.length === 2) {
180+
viewport[0] *= 0.5;
182181
}
183182

184183
this.material.setParameter('viewport', viewport);
@@ -207,7 +206,7 @@ class GSplatInstance {
207206
}
208207
}
209208

210-
this.updateViewport();
209+
this.updateViewport(cameraNode);
211210
}
212211

213212
update() {

0 commit comments

Comments
 (0)