浏览代码

Fix ortographic camera bug

If the values of (orthoLeft, orthoRight, orthoBottom, orthoTop) are explicitly set to 0, they are ignored currently.
This fix changes the logical OR (||) operator to the Nullish Coalescing coalescing operator (??), so 0 values are allowed.
Andrew 5 年之前
父节点
当前提交
140a176206
共有 1 个文件被更改,包括 8 次插入8 次删除
  1. 8 8
      src/Cameras/camera.ts

+ 8 - 8
src/Cameras/camera.ts

@@ -752,18 +752,18 @@ export class Camera extends Node {
             var halfWidth = engine.getRenderWidth() / 2.0;
             var halfHeight = engine.getRenderHeight() / 2.0;
             if (scene.useRightHandedSystem) {
-                Matrix.OrthoOffCenterRHToRef(this.orthoLeft || -halfWidth,
-                    this.orthoRight || halfWidth,
-                    this.orthoBottom || -halfHeight,
-                    this.orthoTop || halfHeight,
+                Matrix.OrthoOffCenterRHToRef(this.orthoLeft ?? -halfWidth,
+                    this.orthoRight ?? halfWidth,
+                    this.orthoBottom ?? -halfHeight,
+                    this.orthoTop ?? halfHeight,
                     this.minZ,
                     this.maxZ,
                     this._projectionMatrix);
             } else {
-                Matrix.OrthoOffCenterLHToRef(this.orthoLeft || -halfWidth,
-                    this.orthoRight || halfWidth,
-                    this.orthoBottom || -halfHeight,
-                    this.orthoTop || halfHeight,
+                Matrix.OrthoOffCenterLHToRef(this.orthoLeft ?? -halfWidth,
+                    this.orthoRight ?? halfWidth,
+                    this.orthoBottom ?? -halfHeight,
+                    this.orthoTop ?? halfHeight,
                     this.minZ,
                     this.maxZ,
                     this._projectionMatrix);