Engine API Reference - v2.24.0-beta.28
    Preparing search index...

    Class RoundedBoxGeometry

    A procedural box-shaped geometry with rounded edges and corners.

    Typically, you would:

    1. Create a RoundedBoxGeometry 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 RoundedBoxGeometry();
    const mesh = Mesh.fromGeometry(app.graphicsDevice, geometry);
    const material = new StandardMaterial();
    const meshInstance = new MeshInstance(mesh, material);

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

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

    Hierarchy (View Summary)

    Index
    • Create a new RoundedBoxGeometry instance.

      By default, the constructor creates a box centered on the object space origin with a width, length and height of 1 unit, edges and corners rounded with a radius of 0.1 and 8 segments across each rounded edge. The faces are laid out as in BoxGeometry, each with UVs in the range of 0 to 1. Each face also takes half of each rounded edge next to it, so neighboring faces meet half way around the rounded edge.

      Parameters

      • Optionalopts: {
            calculateTangents?: boolean;
            halfExtents?: Vec3;
            heightSegments?: number;
            lengthSegments?: number;
            radius?: number;
            radiusSegments?: number;
            widthSegments?: number;
            yOffset?: number;
        } = {}

        Options object.

        • OptionalcalculateTangents?: boolean

          Generate tangent information. Defaults to false.

        • OptionalhalfExtents?: Vec3

          The half dimensions of the box in each axis. Defaults to [0.5, 0.5, 0.5].

        • OptionalheightSegments?: number

          The number of divisions of the flat part of the box along the Y axis. Defaults to 1.

        • OptionallengthSegments?: number

          The number of divisions of the flat part of the box along the Z axis. Defaults to 1.

        • Optionalradius?: number

          The radius of the rounded edges and corners. It is clamped to the smallest half extent, where the box becomes fully rounded in that axis. A radius of 0 generates a box identical to BoxGeometry. Defaults to 0.1.

        • OptionalradiusSegments?: number

          The number of segments across each rounded edge, which turns through 90 degrees. Must be even, as neighboring faces meet half way around the edge, so an odd value is rounded up. Defaults to 8.

        • OptionalwidthSegments?: number

          The number of divisions of the flat part of the box along the X axis. Defaults to 1.

        • OptionalyOffset?: number

          Move the box vertically by given offset in local space. Pass 0.5 to generate the box with pivot point at the bottom face. Defaults to 0.

      Returns RoundedBoxGeometry

      const geometry = new RoundedBoxGeometry({
      halfExtents: new Vec3(1, 0.5, 0.5),
      radius: 0.2,
      radiusSegments: 12
      });
    blendIndices: ArrayLike<number> | undefined

    Blend indices.

    blendWeights: ArrayLike<number> | undefined

    Blend weights.

    colors: ArrayLike<number> | undefined

    Colors.

    tangents: ArrayLike<number> | undefined

    Tangents.