Skip to content

Torus

The Torus is a ring-shaped 3D primitive: radius is the distance out to the tube's centre, tube its thickness, and radialSegments (default 12) and tubularSegments (default 24) its resolution.

NOTE

For the full API, see the 3D API Reference.

Demo

Usage

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

const torus = createTorus({
    radius: 2,
    tube: 0.5,
    radialSegments: 12,
    tubularSegments: 24,
    fill: '#8844cc',
});

Properties

  • radius: distance from center of torus to center of tube
  • tube: radius of the tube
  • radialSegments: number of segments around the tube cross-section (default 12)
  • tubularSegments: number of segments around the torus ring (default 24)
  • 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 {
    elementIsTorus,
} from '@ripl/3d';

if (elementIsTorus(element)) {
    console.log(element.tube);
}