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

    Class CapsuleGeometry

    A procedural capsule-shaped geometry.

    Typically, you would:

    1. Create a CapsuleGeometry 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.CapsuleGeometry();
    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 CapsuleGeometry instance.

      By default, the constructor creates a capsule standing vertically centered on the XZ-plane with a radius of 0.3, a height of 1.0, 1 height segment and 20 cap segments. The capsule is created with UVs in the range of 0 to 1.

      Parameters

      • Optionalopts: {
            calculateTangents?: boolean;
            height?: number;
            heightSegments?: number;
            radius?: number;
            sides?: number;
        } = {}

        Options object.

        • OptionalcalculateTangents?: boolean

          Generate tangent information. Defaults to false.

        • Optionalheight?: number

          The length of the body of the capsule from tip to tip. Defaults to 1.

        • OptionalheightSegments?: number

          The number of divisions along the tubular length of the capsule. Defaults to 1.

        • Optionalradius?: number

          The radius of the tube forming the body of the capsule. Defaults to 0.3.

        • Optionalsides?: number

          The number of divisions around the tubular body of the capsule. Defaults to 20.

      Returns CapsuleGeometry

      const geometry = new pc.CapsuleGeometry({
      radius: 1,
      height: 2,
      heightSegments: 2,
      sides: 20
      });

    Properties

    blendIndices: undefined | number[]

    Blend indices.

    blendWeights: undefined | number[]

    Blend weights.

    colors: undefined | number[]

    Colors.

    Methods