瀏覽代碼

fix Infinity in projection matrix

- ensure near and far are not identical
Alexander Rose 5 年之前
父節點
當前提交
c39ffc0b0e
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/mol-canvas3d/camera.ts

+ 5 - 0
src/mol-canvas3d/camera.ts

@@ -290,6 +290,11 @@ function updateClip(camera: Camera) {
         far = Math.max(0, far)
     }
 
+    if (near === far) {
+        // make sure near and far are not identical to avoid Infinity in the projection matrix
+        far = near + 0.01
+    }
+
     camera.near = near;
     camera.far = far;
     camera.fogNear = fogNear;