Creating a Sphere
We can create a sphere by instantiating an Mx3dMkSphere object.
You can construct an Mx3dMkSphere object by providing a right-hand coordinate system Mx3dGeCSYSR and the radius of the sphere.
typescript
// Get the document
const doc = mxcad3d.getDocument();
// Create a right-hand coordinate system (default is aligned with the world coordinate system)
const csysr = new Mx3dGeCSYSR();
// Set the radius to 10
const sphereMaker = new Mx3dMkSphere(csysr, 10);
// Get the topological shape
const sphereShape = sphereMaker.Shape();
// Create a label in the document
const sphereLabel = doc.addShapeLabel();
// Set the shape of the label to the sphere shape
sphereLabel.setShape(sphereShape);
// Update the display (this will update the model displayed in the canvas)
mxcad3d.update();
The Mx3dMkSphere class has additional constructor overloads for creating incomplete spheres, but they are not covered here.
typescript
constructor(Axes: Mx3dGeCSYSR, R: number);
constructor(Axes: Mx3dGeCSYSR, R: number, angle: number);
constructor(Axes: Mx3dGeCSYSR, R: number, angle1: number, angle2: number);
constructor(Axes: Mx3dGeCSYSR, R: number, angle1: number, angle2: number, angle3: number);
Note
Loading from GitHub and the internet may be slow, so please allow a few minutes...