Reference ellipsoid()

ellipsoid()

Draws an ellipsoid.

An ellipsoid is a 3D shape with triangular faces that connect to form a round surface. Ellipsoids with few faces look like crystals. Ellipsoids with many faces have smooth surfaces and look like eggs. ellipsoid() defines a shape by its radii. This is different from ellipse() which uses diameters (width and height).

The first parameter, radiusX, is optional. If a Number is passed, as in ellipsoid(20), it sets the radius of the ellipsoid along the x-axis. By default, radiusX is 50.

The second parameter, radiusY, is also optional. If a Number is passed, as in ellipsoid(20, 30), it sets the ellipsoid’s radius along the y-axis. By default, radiusY is set to the ellipsoid’s radiusX.

The third parameter, radiusZ, is also optional. If a Number is passed, as in ellipsoid(20, 30, 40), it sets the ellipsoid’s radius along the z-axis. By default, radiusZ is set to the ellipsoid’s radiusY.

The fourth parameter, detailX, is also optional. If a Number is passed, as in ellipsoid(20, 30, 40, 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 fifth parameter, detailY, is also optional. If a Number is passed, as in ellipsoid(20, 30, 40, 5, 7), 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: ellipsoid() can only be used in WebGL mode.

Examples

Syntax

ellipsoid([radiusX], [radiusY], [radiusZ], [detailX], [detailY])

Parameters

radiusX

radius of the ellipsoid along the x-axis. Defaults to 50.

radiusY

radius of the ellipsoid along the y-axis. Defaults to radiusX.

radiusZ

radius of the ellipsoid along the z-axis. Defaults to radiusY.

detailX

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

detailY

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