# Add measurement controls — Dnalogel

Start, finish, undo, cancel, and switch units using the published MeasurePlugin controller.

Canonical: https://developer.realsee.ai/docs/dnalogel/measure
Source: https://developer.realsee.ai/docs/dnalogel/measure.md
Language: en

[Download examples](https://developer.realsee.ai/starters/react-five/1.3.0/starter.zip)

Use `MeasurePlugin` for interactive measurements on the loaded scene. The [quickstart](https://developer.realsee.ai/docs/dnalogel/quickstart) registers it with metric units and two decimal places. It is a different controller from `PanoMeasurePlugin`; their methods are not interchangeable.

## Connect your controls

```ts title="examples/sdk-guides/src/dnalogel/measure.ts"
import type { MeasurePlugin } from '@realsee/dnalogel'

type MeasureController = ReturnType<typeof MeasurePlugin>

export function bindMeasurement(
  measure: MeasureController,
  report: (result: { reason: string; pointCount: number }) => void
) {
  const stop = measure.on('measureEnd', (reason, points) => report({ reason, pointCount: points.length }))
  return {
    start() { measure.measure() },
    finish() { measure.endMeasure() },
    undo() { measure.undo() },
    cancel() { measure.cancel() },
    metric() { measure.setUnit('m'); measure.setPrecision(2) },
    imperial() { measure.setUnit('ft'); measure.setPrecision(8) },
    clear() { measure.clear() },
    dispose() { stop(); measure.cancel() }
  }
}
```

Call `bindMeasurement(result.measure, report)` after the scene is ready. Connect its returned methods to your Start, Finish, Undo, Cancel, Units, and Clear buttons. The report callback receives an end reason and point count; it does not claim to be a persisted measurement result.

`measure.on('measureEnd', ...)` is the event surface for this controller. Unlike `PanoTagPlugin`, it does not use a `.hooks` property for this subscription.

## Understand precision and completion

| Setting | Meaning |
| --- | --- |
| Unit `m`, precision `2` | Two decimal places for lengths |
| Unit `ft`, precision `8` | Eighth-inch length precision |
| Area display | Fixed two decimal places |

The published completion reasons include `enter`, `escape`, `polygon`, `mode_change`, `pano_move`, `floor_change`, `points_insufficient`, and `external`. A finished interaction is not always a usable polygon or a saved result. Decide what your product accepts before storing selected points on your backend.

## Verify

Start a measurement, add points, undo, and finish. Repeat with cancellation and a panorama or mode change. Switch units without recreating the plugin. Confirm the display and report callback agree with the performed action, then clean up the binding and scene.

Test measurement behavior and accuracy on your captured scene in the browser. This example does not provide a surveying accuracy guarantee.

[Published configuration](https://unpkg.com/@realsee/dnalogel@3.81.10/libs/MeasurePlugin/index.d.ts) · [Controller and completion reasons](https://unpkg.com/@realsee/dnalogel@3.81.10/libs/MeasurePlugin/Controller.d.ts)
