Skip to content

The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.

601 B
Raw Blame
use crate::bounding_volume::Aabb;
use crate::math::{Pose, Vector};
use crate::shape::Capsule;

impl Capsule {
    /// The axis-aligned bounding box of this capsule.
    #[inline]
    pub fn aabb(&self, pos: &Pose) -> Aabb {
        self.transform_by(pos).local_aabb()
    }

    /// The axis-aligned bounding box of this capsule.
    #[inline]
    pub fn local_aabb(&self) -> Aabb {
        let a = self.segment.a;
        let b = self.segment.b;
        let mins = a.min(b) - Vector::splat(self.radius);
        let maxs = a.max(b) + Vector::splat(self.radius);
        Aabb::new(mins, maxs)
    }
}