melonJS
    Preparing search index...

    Class Sphere

    A 3D sphere — { centre, radius }. Sibling of Ellipse in the geometry surface; used by Octree / adapter.querySphere as the canonical 3D region-query shape, and by user code for any sphere-vs-sphere / sphere-vs-AABB collision check under Camera3d.

    Not currently part of the BodyShape union — Body is 2D- only in melonJS today; Sphere is a math/geometry primitive that would slot in once a 3D physics adapter ships.

    import { Sphere } from "melonjs";

    const a = new Sphere(0, 0, 0, 10);
    const b = new Sphere(15, 0, 0, 10);
    a.overlaps(b); // true — surfaces touch at x = 5
    Index

    Constructors

    Properties

    Centre coordinates of the sphere (Y-down, +Z forward — Camera3d convention).

    radius: number

    Sphere radius. Negative values are treated like their absolute value in Sphere.overlaps / Sphere.contains.

    Methods