src/collisions/contact-calculation/src/capsule-contact-calculation.js
function capsuleVsSphere(contactPoint, contactNormal, capsule, sphere) {
  const sphereCenter = sphere.centerOfVolume;
  findClosestPointOnSegmentToPoint(contactPoint, capsule.segment, sphereCenter);
  vec3.subtract(contactNormal, sphereCenter, contactPoint);
  vec3.normalize(contactNormal, contactNormal);
  vec3.scaleAndAdd(contactPoint, contactPoint, contactNormal, capsule.radius);
}
function capsuleVsSphere(contactPoint, contactNormal, capsule, sphere) {
  const sphereCenter = sphere.centerOfVolume;
  findClosestPointOnSegmentToPoint(contactPoint, capsule.segment, sphereCenter);
  vec3.subtract(contactNormal, sphereCenter, contactPoint);
  vec3.normalize(contactNormal, contactNormal);
  vec3.scaleAndAdd(contactPoint, contactPoint, contactNormal, capsule.radius);
}
function capsuleVsSphere ( contactPoint , contactNormal , capsule , sphere ) { const sphereCenter = sphere . centerOfVolume ; findClosestPointOnSegmentToPoint ( contactPoint , capsule . segment , sphereCenter ) ; vec3 . subtract ( contactNormal , sphereCenter , contactPoint ) ; vec3 . normalize ( contactNormal , contactNormal ) ; vec3 . scaleAndAdd ( contactPoint , contactPoint , contactNormal , capsule . radius ) ; }
Finds the closest point on the surface of the capsule to the sphere center.

@param {vec3} contactPoint Output param.
@param {vec3} contactNormal Output param.
@param {Capsule} capsule
@param {Sphere} sphere
Finds the closest point on the surface of the capsule to the sphere center .