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 capradiusBottom: radius of the bottom capheight: height of the cylindersegments: number of radial segments (default16)x/y/z: position in world space (default0)rotationX/rotationY/rotationZ: rotation around each axis in radians (default0)scaleX/scaleY/scaleZ: scale along each axis (default1), orscalefor all threematerial: how the surface responds to light — see Materials
Type Guard
ts
import {
elementIsCylinder,
} from '@ripl/3d';
if (elementIsCylinder(element)) {
console.log(element.height);
}