Skip to content
On this page

In MXCAD3D, you can set the material of models you create. In the natural world, there are various types of materials such as metals (copper, iron, etc.), plastics, wood, stone, and more. MXCAD3D provides predefined materials for these common types. The visual appearance of materials is determined by factors such as glossiness, reflection, refraction, transparency, and other properties related to light. MXCAD3D allows you to adjust the visual representation of models by modifying these material properties.

Material

typescript
const csysr = new Mx3dGeCSYSR();
const cylinderMaker = new Mx3dMkCylinder(csysr, 15, 60, Math.PI * 3 / 2);
const cylinderShape1 = cylinderMaker.Shape();
const cylinderShape2 = cylinderShape1.TranslatedByVec(60, 0, 0);
// Built-in glass material, which is inherently transparent
const glassMat = new Mx3dGeMaterial(MdGe.MxNameOfMaterial.Material_NOM_Glass);
// Create a default material
const anyMat = new Mx3dGeMaterial();
// Set the transparency of the default material to 0.5
// Without this transparency setting, anyMat would be an opaque material
anyMat.SetTransparency(0.5);
// Get the document
const doc = mxcad3d.getDocument();
// Add shape labels
const cylinderLabel1 = doc.addShapeLabel();
const cylinderLabel2 = doc.addShapeLabel();
// Set shapes and materials for the labels
cylinderLabel1.setShape(cylinderShape1);
cylinderLabel1.setMaterial(glassMat);
cylinderLabel2.setShape(cylinderShape2);
cylinderLabel2.setMaterial(anyMat);
// Update the display
mxcad3d.update();

The materials are saved in the document.