Creating a Cube
To create a cube, we can instantiate an Mx3dMkBox
object.
You can construct an Mx3dMkBox
object by providing two non-coincident geometric points of type Mx3dGePoint
.
typescript
// Get the document
const doc = mxcad3d.getDocument();
const pt1 = new Mx3dGePoint(5, 5, 5);
const pt2 = new Mx3dGePoint(15, 15, 15);
// Construct the BOX
const boxMaker = new Mx3dMkBox(pt1, pt2);
// Get the topological shape
const boxShape = boxMaker.Shape();
// Create a shape label in the document
const boxLabel = doc.addShapeLabel();
// Add the topological shape to the label
boxLabel.setShape(boxShape);
// Update the display (this will update the model shown in the canvas)
mxcad3d.update();
The above code constructs a cube with diagonal points at (5, 5, 5) and (15, 15, 15), aligned with the X, Y, and Z axes for length, width, and height, respectively.
Alternatively, you can create a cube by providing three values for x
, y
, and z
, which represent the dimensions along the X, Y, and Z axes, respectively. The cube's diagonal points will be (0, 0, 0) and (x, y, z).
typescript
// Cube with length 30, width 20, and height 15
const boxMaker = new Mx3dMkBox(30, 20, 15);
Note
GitHub and network connectivity issues may cause slow loading times, so please be patient.