centre x
centre y
centre z
sphere radius
OptionalcollisionOptionalcollisionOptional per-shape collision settings, honoured by Body#addShape
and defaulted there. Declared rather than initialized: the body writes
them when the shape joins it, so a class field here would emit an
undefined own property on every shape ever built. See addShape for
the table of defaults and what each one does.
Optionalisfalse takes this shape out of collision without removing it
Optionalistrue reports contacts but skips the position correction
Centre coordinates of the sphere (Y-down, +Z forward — Camera3d convention).
Sphere radius. Negative values are treated like their absolute value in Sphere.overlaps / Sphere.contains.
Shape tag, as the narrowphase's pair table keys on. That table is a string concat of the two shapes' types and a missing entry is a hard failure rather than a missed collision, so this has to match the entries registered in the detector exactly.
Reset the sphere to a zero-radius point at the origin.
Deep copy of this sphere. The clone shares NOTHING with the
original — independent pos Vector3d, independent AABB cache.
Pulls from spherePool so back-to-back clones are
allocation-free.
Test whether a point lies inside the sphere (boundary inclusive).
Squared-distance test — no sqrt on the hot path. Matches the
boundary convention of AABB3d.contains.
point x
point y
point z
Smallest AABB3d containing this sphere. The same instance
every time, refreshed from the current centre and radius on each
call, so it is never stale: as a body shape a sphere gets moved by
whoever owns it — directly through pos, not only through
Sphere.setShape — and a cache that only refreshed on
setShape reported the position the sphere was first asked about
for the rest of its life. Callers must not hold the instance across
a move and expect the old values.
Test whether this sphere overlaps another. Boundary inclusive (touching surfaces count as overlap), matching AABB3d.overlaps.
the other sphere
Test whether this sphere overlaps an axis-aligned box. Delegates to AABB3d.overlapsSphere so the two shapes agree on boundary semantics.
the box
Re-position and resize the sphere in one shot. Mirrors Ellipse.setShape.
centre x
centre y
centre z
sphere radius
this sphere for chaining
A 3D sphere —
{ centre, radius }. Sibling of Ellipse in the geometry surface; used by Octree /adapter.querySphereas the canonical 3D region-query shape, and by user code for any sphere-vs-sphere / sphere-vs-AABB collision check under Camera3d.Also a BODY SHAPE. A
Bodycarrying a Sphere is resolved by the builtin 3D narrowphase against another Sphere or a Box3d, which is what makes it the right primitive for anything that tumbles or is laid out over a curved surface: a Box3d is world-axis-aligned and cannot be oriented, so every object whose "up" points a different way needs a shape that has no "up" at all.Example