Browse Source

fix Infinity in projection matrix

- ensure near and far are not identical
Alexander Rose 5 years ago
parent
commit
c39ffc0b0e
1 changed files with 5 additions and 0 deletions
  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;