Skip to content

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 sphere
  • segments: number of horizontal segments (default 16)
  • rings: number of vertical rings (default 12)
  • x / y / z: position in world space (default 0)
  • rotationX / rotationY / rotationZ: rotation around each axis in radians (default 0)
  • scaleX / scaleY / scaleZ: scale along each axis (default 1), or scale for all three
  • material: how the surface responds to light — see Materials

Type Guard ​

ts
import {
    elementIsSphere,
} from '@ripl/3d';

if (elementIsSphere(element)) {
    console.log(element.radius);
}