• Creates a procedural torus-shaped mesh.

    The size, shape and tesselation properties of the torus can be controlled via function parameters. By default, the function will create a torus in the XZ-plane with a tube radius of 0.2, a ring radius of 0.3, 20 segments and 30 sides.

    Note that the torus is created with UVs in the range of 0 to 1. Additionally, tangent information is generated into the vertex buffer of the torus's mesh.


    • device: GraphicsDevice

      The graphics device used to manage the mesh.

    • Optional opts: {
          calculateTangents: boolean;
          ringRadius: number;
          sectorAngle: number;
          segments: number;
          sides: number;
          tubeRadius: number;
      } = {}

      An object that specifies optional inputs for the function as follows:

      • calculateTangents: boolean

        Generate tangent information (defaults to false).

      • ringRadius: number

        The radius from the centre of the torus to the centre of the tube (defaults to 0.3).

      • sectorAngle: number

        The sector angle in degrees of the ring of the torus (defaults to 2 * Math.PI).

      • segments: number

        The number of radial divisions forming cross-sections of the torus ring (defaults to 20).

      • sides: number

        The number of divisions around the tubular body of the torus ring (defaults to 30).

      • tubeRadius: number

        The radius of the tube forming the body of the torus (defaults to 0.2).

    Returns Mesh

    A new torus-shaped mesh.