Reference sphere()

sphere()

Draws a sphere.

A sphere is a 3D shape with triangular faces that connect to form a round surface. Spheres with few faces look like crystals. Spheres with many faces have smooth surfaces and look like balls.

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

The second parameter, detailX, is also optional. If a Number is passed, as in sphere(20, 5), it sets the number of triangle subdivisions to use along the x-axis. All 3D shapes are made by connecting triangles to form their surfaces. By default, detailX is 24.

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

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

Examples

Syntax

sphere([radius], [detailX], [detailY])

Parameters

radius
Number:

radius of the sphere. Defaults to 50.

detailX
Integer:

number of triangle subdivisions along the x-axis. Defaults to 24.

detailY
Integer:

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

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