Просмотр исходного кода

Merge pull request #9571 from Popov72/fix-mirror-plane

Fix clip plane not reset to the right value when using mirrors
David Catuhe 4 лет назад
Родитель
Сommit
43fe1df04b
2 измененных файлов с 5 добавлено и 1 удалено
  1. 1 0
      dist/preview release/what's new.md
  2. 4 1
      src/Materials/Textures/mirrorTexture.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -69,6 +69,7 @@
 - Fix vertically interlaced stereoscopic rendering (`RIG_MODE_STEREOSCOPIC_INTERLACED`) not working (follow-up [#7425](https://github.com/BabylonJS/Babylon.js/issues/7425), [#8000](https://github.com/BabylonJS/Babylon.js/issues/8000)) ([foxxyz](https://github.com/foxxyz))
 - Fix accessibility of BaseCameraMouseWheelInput and BaseCameraPointersInput. They appear in documentation but were not available for include. ([mrdunk](https://github.com/mrdunk))
 - Fix function creation inside regularly called freeCameraMouseWheelInput method leading to excessive GC load. ([mrdunk](https://github.com/mrdunk))
+- Fix clip plane not reset to the rigth value when using mirrors ([Popov72](https://github.com/Popov72))
 
 ## Breaking changes
 

+ 4 - 1
src/Materials/Textures/mirrorTexture.ts

@@ -166,6 +166,8 @@ export class MirrorTexture extends RenderTargetTexture {
             engine._debugPopGroup(1);
         });
 
+        let saveClipPlane: Nullable<Plane>;
+
         this.onBeforeRenderObservable.add(() => {
             Matrix.ReflectionToRef(this.mirrorPlane, this._mirrorMatrix);
             this._savedViewMatrix = scene.getViewMatrix();
@@ -174,6 +176,7 @@ export class MirrorTexture extends RenderTargetTexture {
 
             scene.setTransformMatrix(this._transformMatrix, scene.getProjectionMatrix());
 
+            saveClipPlane = scene.clipPlane;
             scene.clipPlane = this.mirrorPlane;
 
             scene.getEngine().cullBackFaces = false;
@@ -186,7 +189,7 @@ export class MirrorTexture extends RenderTargetTexture {
             scene.getEngine().cullBackFaces = true;
             scene._mirroredCameraPosition = null;
 
-            scene.clipPlane = null;
+            scene.clipPlane = saveClipPlane;
         });
     }