@xeokit/xeokit-convert
Version:
JavaScript utilities to create .XKT files
61 lines (60 loc) • 1.99 kB
TypeScript
/**
* @desc Creates cylinder-shaped geometry arrays.
*
* ## Usage
*
* In the example below we'll create an {@link XKTModel}, then create an {@link XKTMesh} with a cylinder-shaped {@link XKTGeometry}.
*
* [[Run this example](http://xeokit.github.io/xeokit-sdk/examples/#geometry_builders_buildCylinderGeometry)]
*
* ````javascript
* const xktModel = new XKTModel();
*
* const cylinder = buildCylinderGeometry({
* center: [0,0,0],
* radiusTop: 2.0,
* radiusBottom: 2.0,
* height: 5.0,
* radialSegments: 20,
* heightSegments: 1,
* openEnded: false
* });
*
* const xktGeometry = xktModel.createGeometry({
* geometryId: "cylinderGeometry",
* primitiveType: cylinder.primitiveType,
* positions: cylinder.positions,
* normals: cylinder.normals,
* indices: cylinder.indices
* });
*
* const xktMesh = xktModel.createMesh({
* meshId: "redCylinderMesh",
* geometryId: "cylinderGeometry",
* position: [-4, -6, -4],
* scale: [1, 3, 1],
* rotation: [0, 0, 0],
* color: [1, 0, 0],
* opacity: 1
* });
*
* const xktEntity = xktModel.createEntity({
* entityId: "redCylinder",
* meshIds: ["redCylinderMesh"]
* });
*
* xktModel.finalize();
* ````
*
* @function buildCylinderGeometry
* @param {*} [cfg] Configs
* @param {Number[]} [cfg.center] 3D point indicating the center position.
* @param {Number} [cfg.radiusTop=1] Radius of top.
* @param {Number} [cfg.radiusBottom=1] Radius of bottom.
* @param {Number} [cfg.height=1] Height.
* @param {Number} [cfg.radialSegments=60] Number of horizontal segments.
* @param {Number} [cfg.heightSegments=1] Number of vertical segments.
* @param {Boolean} [cfg.openEnded=false] Whether or not the cylinder has solid caps on the ends.
* @returns {Object} Geometry arrays for {@link XKTModel#createGeometry} or {@link XKTModel#createMesh}.
*/
export function buildCylinderGeometry(cfg?: any): Object;