Skip to content

Commit

Permalink
fix: remove keydown bindings for ArcballControls (fixes #110) (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornstar authored Jan 21, 2022
1 parent 5ec51f7 commit d21d57c
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/controls/ArcballControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ class ArcballControls extends EventDispatcher {

if (this.domElement) this.connect(this.domElement)

window.addEventListener('keydown', this.onKeyDown)
window.addEventListener('resize', this.onWindowResize)
}

Expand Down Expand Up @@ -758,18 +757,6 @@ class ArcballControls extends EventDispatcher {
}
}

private onKeyDown = (event: KeyboardEvent): void => {
if (event.key == 'c') {
if (event.ctrlKey || event.metaKey) {
this.copyState()
}
} else if (event.key == 'v') {
if (event.ctrlKey || event.metaKey) {
this.pasteState()
}
}
}

private onSinglePanStart = (event: PointerEvent, operation: Operation): void => {
if (this.enabled && this.domElement) {
this.dispatchEvent(_startEvent)
Expand Down Expand Up @@ -1831,7 +1818,6 @@ class ArcballControls extends EventDispatcher {
window.removeEventListener('pointerup', this.onPointerUp)

window.removeEventListener('resize', this.onWindowResize)
window.addEventListener('keydown', this.onKeyDown)

this.scene?.remove(this._gizmos)
this.disposeGrid()
Expand Down Expand Up @@ -2195,7 +2181,7 @@ class ArcballControls extends EventDispatcher {
return _transformation
}

private copyState = (): void => {
public copyState = (): void => {
if (this.camera) {
const state = JSON.stringify(
this.camera?.type === 'OrthographicCamera'
Expand Down Expand Up @@ -2226,15 +2212,15 @@ class ArcballControls extends EventDispatcher {
}
}

private pasteState = (): void => {
public pasteState = (): void => {
const self = this
navigator.clipboard.readText().then(function resolved(value) {
self.setStateFromJSON(value)
})
}

/**
* Save the current state of the control. This can later be recover with .reset
* Save the current state of the control. This can later be recovered with .reset
*/
public saveState = (): void => {
if (!this.camera) return
Expand Down

1 comment on commit d21d57c

@vercel
Copy link

@vercel vercel bot commented on d21d57c Jan 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.