From f2f278d09c494c42b8096d98090bcf922774042e Mon Sep 17 00:00:00 2001 From: Alexandru Popovici Date: Fri, 9 Feb 2024 20:33:02 +0200 Subject: [PATCH] Added clearMeasurements functionality to the measurements extension (#2028) --- packages/viewer-sandbox/src/Sandbox.ts | 7 +++++++ .../extensions/measurements/MeasurementsExtension.ts | 9 +++++++++ 2 files changed, 16 insertions(+) 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