How to use the api ConeElement or CylinderElement to create some cone or cylinder esc?

hello, teacher:

There are some class: coneelement or cylinderelement, i want to create some geometry in the webviewer model, how to do this ?
the example “gemomety_inserting” desribed how to create mesh, but it is created some triangle.

Can i directly create a cone or cylinder or cube using the api not the triangle?

thanks

Please see generateConeCylinderMeshData and generateSphereMeshData.

Once the mesh is created, you can apply a scale and translation matrix to control the desired size and position.

Hello, tino

what’s Util? How to excute the generateConeCylinderMeshData to create a ConeCylinder?
Ande, are there other api, for example : Cube or Cuboid etc.

can you give me any examples?

Thanks a lot!

Best wishes!

jenson

Below is an example of generating a cylinder, a cone and a combination of the two:

await hwv.model.clear();

let cylinderMeshData = Communicator.Util.generateConeCylinderMeshData(2, 24, 5, 0, 0, 0);
let cylinderMeshId = await hwv.model.createMesh(cylinderMeshData);

let meshInstanceData = new Communicator.MeshInstanceData(cylinderMeshId);
meshInstanceData.setFaceColor(Communicator.Color.green());
let nodeCyclinder = hwv.model.createNode(hwv.model.getAbsoluteRootNode(), "node cylinder");
let cylinderMeshNode = await hwv.model.createMeshInstance(meshInstanceData, nodeCyclinder);


let coneMeshData = Communicator.Util.generateConeCylinderMeshData(0, 24, 0, 3, 5, 0);
let coneMeshId = await hwv.model.createMesh(coneMeshData);

meshInstanceData = new Communicator.MeshInstanceData(coneMeshId);
meshInstanceData.setFaceColor(Communicator.Color.red());
let nodeCone = hwv.model.createNode(hwv.model.getAbsoluteRootNode(), "node cone");
let coneMeshNode = await hwv.model.createMeshInstance(meshInstanceData, nodeCone);
let matrix = new Communicator.Matrix();
matrix.setTranslationComponent(10, 0, 0);
await hwv.model.setNodeMatrix(coneMeshNode, matrix);


let coneCylinderMeshData = Communicator.Util.generateConeCylinderMeshData(2, 24, 5, 3, 5, 0);
let coneCyclinderMeshId = await hwv.model.createMesh(coneCylinderMeshData);

meshInstanceData = new Communicator.MeshInstanceData(coneCyclinderMeshId);
meshInstanceData.setFaceColor(Communicator.Color.blue());
let nodeConeCyclinder = hwv.model.createNode(hwv.model.getAbsoluteRootNode(), "node cone cylinder");
let coneCylinderMeshNode = await hwv.model.createMeshInstance(meshInstanceData, nodeConeCyclinder);
matrix.setTranslationComponent(20, 0, 0);
await hwv.model.setNodeMatrix(coneCylinderMeshNode, matrix);

await hwv.view.fitWorld();

For creating cubes, please see this example in our docs:

hello tino

Thank you very much!

Additionally, I would like to discuss with you whether it is possible to achieve this: by extruding the surface, a rectangular plane can be extruded into a cuboid along the normal direction, and modifications can also be made through dragging, just like in some common 3D software.

I believe this is going to be a really fun thing!

Best Wishes!

Jenson

Communicator is primarily a 3D viewer and visualization SDK for engineering and CAD-centric models. As such, it is not really a modelling application.

OK. Thank you very much for your help! Let me have a deeper understanding of the “communicator” concept.
Welcome to China for an exploration trip!