primitives-3d_sphere.js

import oc from "../opencascade/initializer";
import {Solid} from "../modeling";
import {Plane, Vector} from "../math";

/**
 * Creates a sphere based on the specified parameters.
 * @memberof primitives-3D
 * @alias Sphere
 * @param {Object} parameters - The parameters for the sphere.
 * @param {Plane} [parameters.plane=Plane.XY] - The plane in which the sphere is constructed.
 * @param {Vector} [parameters.center=Vector.ZERO] - The center of the sphere.
 * @param {number} parameters.radius - The radius of the sphere.
 * @returns {Solid} A `Solid` object representing the constructed sphere.
 */
const Sphere = ({plane = Plane.XY, center = Vector.ZERO, radius}) => {
  const axis = plane.wrapped.Position().Ax2();
  const localOffset = plane.toWorldCoordinates(center.wrapped);
  return new Solid(new oc.BRepPrimAPI_MakeSphere_9(axis, radius).Shape()).translate(new Vector({wrapped: localOffset}));
};

export {Sphere};