# PlaneGeometry

Class · extends [`Geometry`](https://api.playcanvas.com/engine/classes/Geometry.md) · category: Graphics

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/scene/geometry/plane-geometry.js#L34

A procedural plane-shaped geometry.

Typically, you would:

1. Create a PlaneGeometry instance.
2. Generate a [Mesh](https://api.playcanvas.com/engine/classes/Mesh.md) from the geometry.
3. Create a [MeshInstance](https://api.playcanvas.com/engine/classes/MeshInstance.md) referencing the mesh.
4. Create an [Entity](https://api.playcanvas.com/engine/classes/Entity.md) with a [RenderComponent](https://api.playcanvas.com/engine/classes/RenderComponent.md) and assign the [MeshInstance](https://api.playcanvas.com/engine/classes/MeshInstance.md) to it.
5. Add the entity to the [Scene](https://api.playcanvas.com/engine/classes/Scene.md).

```javascript
// Create a mesh instance
const geometry = new PlaneGeometry();
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);
```

## Constructors

### constructor

```ts
new PlaneGeometry(opts?: object)
```

Create a new PlaneGeometry instance.

By default, the constructor creates a plane centered on the object space origin with a width
and length of 1 and 5 segments in either axis (50 triangles). The normal vector of the plane is
aligned along the positive Y axis. The plane is created with UVs in the range of 0 to 1.

**Parameters**

- `opts` (`object`, optional, default `{}`): Options object.
    - `opts.calculateTangents` (`boolean`, optional): Generate tangent information. Defaults to false.
    - `opts.halfExtents` ([`Vec2`](https://api.playcanvas.com/engine/classes/Vec2.md), optional): The half dimensions of the plane in the X and Z axes.
      Defaults to [0.5, 0.5].
    - `opts.lengthSegments` (`number`, optional): The number of divisions along the Z axis of the plane.
      Defaults to 5.
    - `opts.widthSegments` (`number`, optional): The number of divisions along the X axis of the plane.
      Defaults to 5.

**Example**

```ts
const geometry = new PlaneGeometry({
    halfExtents: new Vec2(1, 1),
    widthSegments: 10,
    lengthSegments: 10
});
```

## Inherited from [Geometry](https://api.playcanvas.com/engine/classes/Geometry.md)

- `blendIndices: ArrayLike<number> | undefined`
- `blendWeights: ArrayLike<number> | undefined`
- `colors: ArrayLike<number> | undefined`
- `tangents: ArrayLike<number> | undefined`
- `calculateNormals(): void`
- `calculateTangents(): void`
