diff --git a/src/runtime-three/runtime-host.js b/src/runtime-three/runtime-host.js index 2f656784..cc1d44b1 100644 --- a/src/runtime-three/runtime-host.js +++ b/src/runtime-three/runtime-host.js @@ -448,7 +448,7 @@ export class RuntimeHost { contactPatches, reflection: { texture: null, - enabled: faceId === "posY" && this.getWaterReflectionMode() !== "none" + enabled: faceId === "posY" } }); if (waterMaterial.animationUniform !== null) { @@ -591,7 +591,6 @@ export class RuntimeHost { const now = performance.now(); for (const binding of this.runtimeWaterContactUniforms) { if (reflectionMode === "none" || - binding.reflectionRenderTarget === null || binding.reflectionTextureUniform === null || binding.reflectionMatrixUniform === null || binding.reflectionEnabledUniform === null) { @@ -600,8 +599,11 @@ export class RuntimeHost { } continue; } + if (binding.reflectionRenderTarget === null) { + binding.reflectionRenderTarget = this.createWaterReflectionRenderTarget(); + } const canRenderReflection = updatePlanarReflectionCamera(binding.brush, this.camera, this.waterReflectionCamera, binding.reflectionMatrixUniform.value); - if (!canRenderReflection) { + if (!canRenderReflection || binding.reflectionRenderTarget === null) { binding.reflectionEnabledUniform.value = 0; continue; } diff --git a/src/runtime-three/runtime-host.ts b/src/runtime-three/runtime-host.ts index bc1c9749..9670cdad 100644 --- a/src/runtime-three/runtime-host.ts +++ b/src/runtime-three/runtime-host.ts @@ -657,7 +657,7 @@ export class RuntimeHost { contactPatches, reflection: { texture: null, - enabled: faceId === "posY" && this.getWaterReflectionMode() !== "none" + enabled: faceId === "posY" } }); @@ -833,7 +833,6 @@ export class RuntimeHost { for (const binding of this.runtimeWaterContactUniforms) { if ( reflectionMode === "none" || - binding.reflectionRenderTarget === null || binding.reflectionTextureUniform === null || binding.reflectionMatrixUniform === null || binding.reflectionEnabledUniform === null @@ -844,6 +843,10 @@ export class RuntimeHost { continue; } + if (binding.reflectionRenderTarget === null) { + binding.reflectionRenderTarget = this.createWaterReflectionRenderTarget(); + } + const canRenderReflection = updatePlanarReflectionCamera( binding.brush, this.camera, @@ -851,7 +854,7 @@ export class RuntimeHost { binding.reflectionMatrixUniform.value ); - if (!canRenderReflection) { + if (!canRenderReflection || binding.reflectionRenderTarget === null) { binding.reflectionEnabledUniform.value = 0; continue; }