> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ploterr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Roof

> Roof makes a flat, gable, hip or shed roof from one footprint.

## Import

```typescript theme={null}
import { Roof } from '@opengeometry/floorkit';
```

## Example

```typescript theme={null}
import { Roof, RoofType, Floorkit } from '@opengeometry/floorkit';

async function example(wasmURL: string): Promise<void> {
  await new Floorkit().setupOpenGeometry(wasmURL);
  const roof = new Roof({
    roofType: RoofType.GABLE,
    pitch: 30,
    overhang: 0.4,
    thickness: 0.2,
    elevation: 6,
    massStyle: false,
    profile: {
      outerRing: [
        [0, 0],
        [8, 0],
        [8, 5],
        [0, 5],
      ],
    },
  });
  try {
    roof.setOPConfig({ pitch: 35 });
    console.log(roof.toDrawing('top'), roof.getOPConfig());
  } finally {
    roof.dispose();
  }
}
```

## Notes

* Profile points are `[x, z]` in metres. `pitch` and `ridgeDirection` are in degrees. `elevation` is the height of the eave.
* A flat roof can have holes. A pitched roof cannot.
* A hip roof needs a convex footprint.
* `overhang` moves the roof edge outward. `thickness` is measured at a right angle to the roof plane.
* `massStyle` fills the volume below the roof planes.
* The `pitch` setter keeps the value between 5 and 75 degrees.
* Start the geometry kernel before you create this object. See [`Floorkit`](/floorkit/api/runtime/floorkit).
* This object is live geometry. To save a building, write it in a [building model](/floorkit/concepts/building-model).

**Inheritance:** `extends OPElement implements IShape, IPlaceable, PlanVectorExportable`

## Constructor

```typescript theme={null}
constructor(config?: Partial<RoofOptions>);
```

<ParamField path="config.ogid" type="string" />

<ParamField path="config.labelName" type="string" />

<ParamField path="config.type" type="ElementType.ROOF" />

<ParamField path="config.profile" type="PolygonProfile">
  Wall-line footprint in the world XZ plane (the eave ring is this ring offset outward by
  `overhang`). Holes are honored by FLAT only; pitched types throw on holes.
</ParamField>

<ParamField path="config.roofType" type="RoofType" />

<ParamField path="config.pitch" type="number">
  Slope in degrees from horizontal (GABLE/HIP/SHED). Clamped to 5–75.
</ParamField>

<ParamField path="config.overhang" type="number">
  Horizontal eave overhang beyond the footprint (m).
</ParamField>

<ParamField path="config.thickness" type="number">
  Plate thickness measured perpendicular to the roof plane (m).
</ParamField>

<ParamField path="config.elevation" type="number">
  World Y of the eave (wall plate top).
</ParamField>

<ParamField path="config.ridgeDirection" type="number">
  Plan direction of the ridge in degrees (GABLE: edges within 45° of this direction slope; SHED: the
  high side faces this direction's left). Defaults to the direction of the footprint's longest edge.
</ParamField>

<ParamField path="config.massStyle" type="boolean">
  When true, build the filled "attic mass" under the roof planes instead of a constant-thickness
  plate — half the boolean work, and exactly what massing shells need.
</ParamField>

<ParamField path="config.color" type="number" />

<ParamField path="config.material" type="RoofMaterial" />

<ParamField path="config.propertySets" type="PropertySets" />

## Properties

<ResponseField name="ogType" type="ElementType" />

<ResponseField name="ogid" type="string" />

<ResponseField name="subElements2D" type="Map<string, OPGeometry>" />

<ResponseField name="subElements3D" type="Map<string, OPGeometry>" />

<ResponseField name="selected" type="boolean" />

<ResponseField name="edit" type="boolean" />

<ResponseField name="locked" type="boolean" />

<ResponseField name="propertySet" type="RoofOptions" />

<ResponseField name="labelName" type="string" />

<ResponseField name="profile" type="RoofProfile" />

<ResponseField name="roofType" type="RoofType" />

<ResponseField name="pitch" type="number" />

<ResponseField name="overhang" type="number" />

<ResponseField name="roofThickness" type="number" />

<ResponseField name="elevation" type="number" />

<ResponseField name="ridgeDirection" type="number | undefined" />

<ResponseField name="massStyle" type="boolean" />

<ResponseField name="roofColor" type="number" />

<ResponseField name="roofMaterial" type="RoofMaterial" />

<ResponseField name="outline" type="boolean" />

<ResponseField name="profileView" type="boolean" />

<ResponseField name="modelView" type="boolean" />

## Methods

### editableSchema

```typescript theme={null}
static editableSchema(): OPEditableSchema;
```

Self-describing editable surface; a host inspector renders this generically.

### move

```typescript theme={null}
move(delta: Vec3): void;
```

Translate this element by `delta` (world-space, meters).

### rotate

```typescript theme={null}
rotate(angleDeg: number, axis?: Vec3, anchor?: Vec3): void;
```

Rotate this element by `angleDeg` around `axis` (default Y-up), pivoted at `anchor` (default the element's own centroid).

### setOPGeometry

```typescript theme={null}
setOPGeometry(): void;
```

### getExportRoots

```typescript theme={null}
getExportRoots(view: PlanExportView): THREE.Object3D[];
```

Vector-export roots (RFC §7).

### toDrawing

```typescript theme={null}
toDrawing(view: PlanExportView): DrawingPrimitive[];
```

Plan footprint region plus the ridge line (gable) / slope arrow (shed), emitted parametrically.

### setOPMaterial

```typescript theme={null}
setOPMaterial(): void;
```

### getOPConfig

```typescript theme={null}
getOPConfig(): RoofOptions;
```

### setOPConfig

```typescript theme={null}
setOPConfig(config: Partial<RoofOptions>): void;
```

### beginEdit

```typescript theme={null}
beginEdit(): void;
```

Start one live edit; a second `beginEdit` before `endEdit` keeps the first start.

### endEdit

```typescript theme={null}
endEdit(): {
    undo: () => void;
    redo: () => void;
} | undefined;
```

End the live edit; its exact undo and redo, or undefined when no option changed.

### getEditAnchors

```typescript theme={null}
getEditAnchors(): EditAnchor[];
```

Draggable handles: one grip per footprint vertex (move on the XZ plane) and an eave-elevation grip at the footprint centroid (raise/lower along +Y).

### applyEditAnchor

```typescript theme={null}
applyEditAnchor(id: string, position: [
    number,
    number,
    number
]): void;
```

### dispose

```typescript theme={null}
dispose(): void;
```

## Types

### RoofOptions

```typescript theme={null}
interface RoofOptions extends HasPropertySets {
  ogid?: string;
  labelName: string;
  type: ElementType.ROOF;
  profile: RoofProfile;
  roofType: RoofType;
  pitch: number;
  overhang: number;
  thickness: number;
  elevation: number;
  ridgeDirection?: number;
  massStyle: boolean;
  color: number;
  material: RoofMaterial;
}
```

### RoofProfile

Polygon profile for a Roof — alias of PolygonProfile.

```typescript theme={null}
type RoofProfile = PolygonProfile;
```

### RoofType

```typescript theme={null}
enum RoofType {
  FLAT = 'FLAT',
  GABLE = 'GABLE',
  HIP = 'HIP',
  SHED = 'SHED',
}
```

### RoofMaterial

```typescript theme={null}
enum RoofMaterial {
  TILE = 'TILE',
  METAL = 'METAL',
  MEMBRANE = 'MEMBRANE',
  SHINGLE = 'SHINGLE',
  OTHER = 'OTHER',
}
```

## Related

* [`OPElement`](/floorkit/api/architecture/op-element)
* [`DrawingPrimitive`](/floorkit/api/drawings/draw-project-view#drawingprimitive)
* [`EditAnchor`](/floorkit/api/architecture/op-element#editanchor)
* [`ElementType`](/floorkit/api/architecture/op-element#elementtype)
* [`HasPropertySets`](/floorkit/api/architecture/op-element#haspropertysets)
* [`IPlaceable`](/floorkit/api/architecture/op-element#iplaceable)
* [`IShape`](/floorkit/api/shapes/cuboid-shape#ishape)
* [`OPEditableSchema`](/floorkit/api/architecture/op-element#opeditableschema)
* [`OPGeometry`](/floorkit/api/architecture/opening#opgeometry)
* [`PlanExportView`](/floorkit/api/shapes/cylinder-shape#planexportview)
* [`PlanVectorExportable`](/floorkit/api/shapes/cylinder-shape#planvectorexportable)
* [`PolygonProfile`](/floorkit/api/primitives/polygon-maths#polygonprofile)
* [`Vec3`](/floorkit/api/architecture/wall#vec3)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.