Browse Source

Merge pull request #9598 from Popov72/fix-lensflare-rhs

Fix lens flares not working in right handed systems
David Catuhe 4 years ago
parent
commit
94f55b933a

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

@@ -72,6 +72,7 @@
 - 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))
+- Fix lens flares not working in right handed system ([Popov72](https://github.com/Popov72))
 
 ## Breaking changes
 

+ 4 - 1
src/LensFlares/lensFlareSystem.ts

@@ -196,7 +196,10 @@ export class LensFlareSystem {
             this._positionY += this.viewportBorder;
         }
 
-        if (position.z > 0) {
+        const rhs = this._scene.useRightHandedSystem;
+        const okZ = position.z > 0 && !rhs || position.z < 0 && rhs;
+
+        if (okZ) {
             if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
                 if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
                     return true;

+ 3 - 3
tests/validation/validation.js

@@ -104,12 +104,12 @@ async function evaluate(test, resultCanvas, result, renderImage, waitRing, done)
     var testRes = true;
 
     // gl check
-    var gl = engine._gl;
-    if (gl && gl.getError() !== 0) {
+    var gl = engine._gl, glError = gl.getError();
+    if (gl && glError !== 0) {
         result.classList.add("failed");
         result.innerHTML = "×";
         testRes = false;
-        console.log('%c failed (gl error)', 'color: red');
+        console.log(`%c failed (gl error: ${glError})`, 'color: red');
     } else {
 
         // Visual check