Skip to content

Commit

Permalink
Add option to skip changed signal on an orient event
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-daff-cresset committed Nov 1, 2024
1 parent 25d45d2 commit 4dddb98
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/controls/viewer-controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -121,17 +124,18 @@ 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
v.rotationGroup.setRotationFromQuaternion(tmpQ)
v.translationGroup.position.copy(tmpP)
v.cameraDistance = tmpS.z
v.updateZoom()
this.changed()
this.changed(skipSignal)
}

/**
Expand Down

0 comments on commit 4dddb98

Please sign in to comment.