Reference cone()

cone()

Draws a cone.

A cone is a 3D shape with triangular faces that connect a flat bottom to a single point. Cones with few faces look like pyramids. Cones with many faces have smooth surfaces.

The first parameter, radius, is optional. If a Number is passed, as in cone(20), it sets the radius of the cone’s base. By default, radius is 50.

The second parameter, height, is also optional. If a Number is passed, as in cone(20, 30), it sets the cone’s height. By default, height is set to the cone’s radius.

The third parameter, detailX, is also optional. If a Number is passed, as in cone(20, 30, 5), it sets the number of edges used to form the cone's base. Using more edges makes the base look more like a circle. By default, detailX is 24.

The fourth parameter, detailY, is also optional. If a Number is passed, as in cone(20, 30, 5, 7), it sets the number of triangle subdivisions to use along the y-axis connecting the base to the tip. All 3D shapes are made by connecting triangles to form their surfaces. By default, detailY is 1.

The fifth parameter, cap, is also optional. If a false is passed, as in cone(20, 30, 5, 7, false) the cone’s base won’t be drawn. By default, cap is true.

Note: cone() can only be used in WebGL mode.

Examples

Syntax

cone([radius], [height], [detailX], [detailY], [cap])

Parameters

radius
Number:

radius of the cone's base. Defaults to 50.

height
Number:

height of the cone. Defaults to the value of radius.

detailX
Integer:

number of edges used to draw the base. Defaults to 24.

detailY
Integer:

number of triangle subdivisions along the y-axis. Defaults to 1.

cap
Boolean:

whether to draw the cone's base. Defaults to true.

Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/3d_primitives.js and open a pull request!

Related References