Refactor water reflection target size calculation in viewport-host.ts
This commit is contained in:
@@ -3019,14 +3019,18 @@ export class ViewportHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private createWaterReflectionRenderTarget() {
|
private createWaterReflectionRenderTarget() {
|
||||||
const width = Math.max(128, Math.round((this.container?.clientWidth ?? this.renderer.domElement.width || 512) * 0.5));
|
const canvasWidth = this.container?.clientWidth ?? this.renderer.domElement.width;
|
||||||
const height = Math.max(128, Math.round((this.container?.clientHeight ?? this.renderer.domElement.height || 512) * 0.5));
|
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);
|
return new WebGLRenderTarget(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private resizeWaterReflectionTargets() {
|
private resizeWaterReflectionTargets() {
|
||||||
const width = Math.max(128, Math.round((this.container?.clientWidth ?? this.renderer.domElement.width || 512) * 0.5));
|
const canvasWidth = this.container?.clientWidth ?? this.renderer.domElement.width;
|
||||||
const height = Math.max(128, Math.round((this.container?.clientHeight ?? this.renderer.domElement.height || 512) * 0.5));
|
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) {
|
for (const binding of this.viewportWaterSurfaceBindings) {
|
||||||
binding.reflectionRenderTarget?.setSize(width, height);
|
binding.reflectionRenderTarget?.setSize(width, height);
|
||||||
|
|||||||
Reference in New Issue
Block a user