Browse Source

handle building GridLookup3D with zero cell size

Alexander Rose 2 years ago
parent
commit
3769da48a1
2 changed files with 4 additions and 3 deletions
  1. 1 0
      CHANGELOG.md
  2. 3 3
      src/mol-math/geometry/lookup3d/grid.ts

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf
 
 - Fix case handling of ``struct_conf`` mmCIF enumeration field (#425)
 - Fix ``FormatRegistry.isApplicable`` returning true for unregistered formats
+- Fix: handle building of ``GridLookup3D`` with zero cell size
 
 ## [v3.7.0] - 2022-04-13
 

+ 3 - 3
src/mol-math/geometry/lookup3d/grid.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -172,7 +172,7 @@ function build(data: PositionData, boundary: Boundary, cellSizeOrCount?: Vec3 |
     const expandedBox = Box3D.expand(Box3D(), boundary.box, Vec3.create(0.5, 0.5, 0.5));
     const { indices } = data;
 
-    const S = Box3D.size(Vec3.zero(), expandedBox);
+    const S = Box3D.size(Vec3(), expandedBox);
     let delta, size;
 
     const elementCount = OrderedSet.size(indices);
@@ -180,7 +180,7 @@ function build(data: PositionData, boundary: Boundary, cellSizeOrCount?: Vec3 |
     const cellCount = typeof cellSizeOrCount === 'number' ? cellSizeOrCount : 32;
     const cellSize = Array.isArray(cellSizeOrCount) && cellSizeOrCount;
 
-    if (cellSize) {
+    if (cellSize && !Vec3.isZero(cellSize)) {
         size = [Math.ceil(S[0] / cellSize[0]), Math.ceil(S[1] / cellSize[1]), Math.ceil(S[2] / cellSize[2])];
         delta = cellSize;
     } else if (elementCount > 0) {