Skip to content

Cylinder

The Cylinder is a 3D primitive with separate radiusTop and radiusBottom; give them different values and it draws a truncated cone. segments (default 16) sets the smoothness of the circular cross-section.

NOTE

For the full API, see the 3D API Reference.

Demo

Usage

ts
import {
    createCylinder,
} from '@ripl/3d';

const cylinder = createCylinder({
    radiusTop: 1,
    radiusBottom: 1,
    height: 2,
    segments: 16,
    fill: '#cc8844',
});

Properties

  • radiusTop: radius of the top cap
  • radiusBottom: radius of the bottom cap
  • height: height of the cylinder
  • segments: number of radial segments (default 16)
  • x / y / z: position in world space (default 0)
  • rotationX / rotationY / rotationZ: rotation around each axis in radians (default 0)
  • scaleX / scaleY / scaleZ: scale along each axis (default 1), or scale for all three
  • material: how the surface responds to light — see Materials

Type Guard

ts
import {
    elementIsCylinder,
} from '@ripl/3d';

if (elementIsCylinder(element)) {
    console.log(element.height);
}