Explorar o código

fix Infinity in projection matrix

- ensure near and far are not identical
Alexander Rose %!s(int64=5) %!d(string=hai) anos
pai
achega
c39ffc0b0e
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  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;