From 4dddb982b3e87e696bf8d5d01b9812e14669a5a7 Mon Sep 17 00:00:00 2001 From: Tom Daff Date: Fri, 1 Nov 2024 15:25:28 +0000 Subject: [PATCH] Add option to skip changed signal on an orient event --- src/controls/viewer-controls.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/controls/viewer-controls.ts b/src/controls/viewer-controls.ts index e32dfdbe..56e2e5f9 100644 --- a/src/controls/viewer-controls.ts +++ b/src/controls/viewer-controls.ts @@ -66,12 +66,15 @@ class ViewerControls { /** * Trigger render and emit changed event + * @param {boolean} skipSignal - don't dispatch signal for a change * @emits {ViewerControls.signals.changed} * @return {undefined} */ - changed () { + changed (skipSignal: boolean = false) { this.viewer.requestRender() - this.signals.changed.dispatch() + if (!skipSignal) { + this.signals.changed.dispatch() + } } getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) { @@ -121,9 +124,10 @@ class ViewerControls { /** * set scene orientation * @param {OrientationMatrix|Array} orientation - scene orientation + * @param {boolean} skipSignal - do not trigger a change signal when orienting * @return {undefined} */ - orient (orientation?: Matrix4) { + orient (orientation?: Matrix4, skipSignal?: boolean) { ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS) const v = this.viewer @@ -131,7 +135,7 @@ class ViewerControls { v.translationGroup.position.copy(tmpP) v.cameraDistance = tmpS.z v.updateZoom() - this.changed() + this.changed(skipSignal) } /**