diff --git a/packages/viewer-sandbox/src/Sandbox.ts b/packages/viewer-sandbox/src/Sandbox.ts index 5a447428aa..826fa445df 100644 --- a/packages/viewer-sandbox/src/Sandbox.ts +++ b/packages/viewer-sandbox/src/Sandbox.ts @@ -1192,6 +1192,13 @@ export default class Sandbox { .on('click', () => { this.viewer.getExtension(MeasurementsExtension).removeMeasurement() }) + container + .addButton({ + title: 'Delete All' + }) + .on('click', () => { + this.viewer.getExtension(MeasurementsExtension).clearMeasurements() + }) } private getBVHSize() { diff --git a/packages/viewer/src/modules/extensions/measurements/MeasurementsExtension.ts b/packages/viewer/src/modules/extensions/measurements/MeasurementsExtension.ts index 7182f2da89..35fa1e43bb 100644 --- a/packages/viewer/src/modules/extensions/measurements/MeasurementsExtension.ts +++ b/packages/viewer/src/modules/extensions/measurements/MeasurementsExtension.ts @@ -326,6 +326,15 @@ export class MeasurementsExtension extends Extension { } } + public clearMeasurements() { + this.removeMeasurement() + this.measurements.forEach((measurement: Measurement) => { + this.renderer.scene.remove(measurement) + }) + this.measurements = [] + this.viewer.requestRender() + } + protected flashMeasurement() { let flashCount = 0 const maxFlashCount = 5