Browse Source

fix .expandBySphere and .expand in Sphere3D

Alexander Rose 5 years ago
parent
commit
ee35e39611
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/mol-math/geometry/primitives/sphere3d.ts

+ 4 - 2
src/mol-math/geometry/primitives/sphere3d.ts

@@ -107,13 +107,15 @@ namespace Sphere3D {
     }
 
     /** Expand sphere radius by another sphere */
-    export function expandBySphere(out: Sphere3D, sphere: Sphere3D) {
-        out.radius = Math.max(out.radius, Vec3.distance(out.center, sphere.center) + sphere.radius)
+    export function expandBySphere(out: Sphere3D, sphere: Sphere3D, by: Sphere3D) {
+        Vec3.copy(out.center, sphere.center)
+        out.radius = Math.max(sphere.radius, Vec3.distance(sphere.center, by.center) + by.radius)
         return out
     }
 
     /** Expand sphere radius by delta */
     export function expand(out: Sphere3D, sphere: Sphere3D, delta: number): Sphere3D {
+        Vec3.copy(out.center, sphere.center)
         out.radius = sphere.radius + delta
         return out
     }