Engine API Reference - v2.7.3
    Preparing search index...

    Class TorusGeometry

    A procedural torus-shaped geometry.

    Typically, you would:

    1. Create a TorusGeometry instance.
    2. Generate a Mesh from the geometry.
    3. Create a MeshInstance referencing the mesh.
    4. Create an Entity with a RenderComponent and assign the MeshInstance to it.
    5. Add the entity to the Scene.
    // Create a mesh instance
    const geometry = new pc.TorusGeometry();
    const mesh = pc.Mesh.fromGeometry(app.graphicsDevice, geometry);
    const material = new pc.StandardMaterial();
    const meshInstance = new pc.MeshInstance(mesh, material);

    // Create an entity
    const entity = new pc.Entity();
    entity.addComponent('render', {
    meshInstances: [meshInstance]
    });

    // Add the entity to the scene hierarchy
    app.scene.root.addChild(entity);

    Hierarchy (View Summary)

    Index

    Constructors

    • Create a new TorusGeometry instance.

      By default, the constructor creates a torus in the XZ-plane with a tube radius of 0.2, a ring radius of 0.3, 30 segments and 20 sides. The torus is created with UVs in the range of 0 to 1.

      Parameters

      • Optionalopts: {
            calculateTangents?: boolean;
            ringRadius?: number;
            sectorAngle?: number;
            segments?: number;
            sides?: number;
            tubeRadius?: number;
        } = {}

        Options object.

        • OptionalcalculateTangents?: boolean

          Generate tangent information. Defaults to false.

        • OptionalringRadius?: number

          The radius from the centre of the torus to the centre of the tube. Defaults to 0.3.

        • OptionalsectorAngle?: number

          The sector angle in degrees of the ring of the torus. Defaults to 2 * Math.PI.

        • Optionalsegments?: number

          The number of radial divisions forming cross-sections of the torus ring. Defaults to 20.

        • Optionalsides?: number

          The number of divisions around the tubular body of the torus ring. Defaults to 30.

        • OptionaltubeRadius?: number

          The radius of the tube forming the body of the torus. Defaults to 0.2.

      Returns TorusGeometry

      const geometry = new pc.TorusGeometry({
      tubeRadius: 1,
      ringRadius: 2,
      sectorAngle: 360,
      segments: 30,
      sides: 20
      });

    Properties

    blendIndices: undefined | number[]

    Blend indices.

    blendWeights: undefined | number[]

    Blend weights.

    colors: undefined | number[]

    Colors.

    Methods