From 0624f2ae96fb7097ea97911ea348b58e968e0bbb Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 7 Apr 2026 06:42:36 +0200 Subject: [PATCH] Refactor water reflection target size calculation in viewport-host.ts --- src/viewport-three/viewport-host.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/viewport-three/viewport-host.ts b/src/viewport-three/viewport-host.ts index b9a8fcf2..fc97fecf 100644 --- a/src/viewport-three/viewport-host.ts +++ b/src/viewport-three/viewport-host.ts @@ -3019,14 +3019,18 @@ export class ViewportHost { } private createWaterReflectionRenderTarget() { - const width = Math.max(128, Math.round((this.container?.clientWidth ?? this.renderer.domElement.width || 512) * 0.5)); - const height = Math.max(128, Math.round((this.container?.clientHeight ?? this.renderer.domElement.height || 512) * 0.5)); + const canvasWidth = this.container?.clientWidth ?? this.renderer.domElement.width; + const canvasHeight = this.container?.clientHeight ?? this.renderer.domElement.height; + const width = Math.max(128, Math.round(Math.max(canvasWidth, 512) * 0.5)); + const height = Math.max(128, Math.round(Math.max(canvasHeight, 512) * 0.5)); return new WebGLRenderTarget(width, height); } private resizeWaterReflectionTargets() { - const width = Math.max(128, Math.round((this.container?.clientWidth ?? this.renderer.domElement.width || 512) * 0.5)); - const height = Math.max(128, Math.round((this.container?.clientHeight ?? this.renderer.domElement.height || 512) * 0.5)); + const canvasWidth = this.container?.clientWidth ?? this.renderer.domElement.width; + const canvasHeight = this.container?.clientHeight ?? this.renderer.domElement.height; + const width = Math.max(128, Math.round(Math.max(canvasWidth, 512) * 0.5)); + const height = Math.max(128, Math.round(Math.max(canvasHeight, 512) * 0.5)); for (const binding of this.viewportWaterSurfaceBindings) { binding.reflectionRenderTarget?.setSize(width, height);