Sphere
The Sphere is a 3D primitive tessellated from rings (default 12) and segments (default 16). Raising either smooths the surface and adds faces to sort and shade.
NOTE
For the full API, see the 3D API Reference.
Demo
Usage
ts
import {
createSphere,
} from '@ripl/3d';
const sphere = createSphere({
radius: 1,
segments: 16,
rings: 12,
fill: '#44cc88',
});Properties
radius: radius of the spheresegments: number of horizontal segments (default16)rings: number of vertical rings (default12)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 {
elementIsSphere,
} from '@ripl/3d';
if (elementIsSphere(element)) {
console.log(element.radius);
}