소스 검색

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;