update `MouseControl` and remove event listener
This commit is contained in:
parent
79167ab0f8
commit
2725925fe4
|
|
@ -227,9 +227,9 @@ class SkinViewer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SkinControl {
|
class MouseControl {
|
||||||
constructor(skinViewer) {
|
constructor(skinViewer) {
|
||||||
this.enableAnimationControl = true;
|
this.enableMouseControl = true;
|
||||||
this.skinViewer = skinViewer;
|
this.skinViewer = skinViewer;
|
||||||
|
|
||||||
this.orbitControls = new OrbitControls(skinViewer.camera, skinViewer.renderer.domElement);
|
this.orbitControls = new OrbitControls(skinViewer.camera, skinViewer.renderer.domElement);
|
||||||
|
|
@ -238,20 +238,19 @@ class SkinControl {
|
||||||
this.orbitControls.minDistance = 10;
|
this.orbitControls.minDistance = 10;
|
||||||
this.orbitControls.maxDistance = 256;
|
this.orbitControls.maxDistance = 256;
|
||||||
this.orbitControls.update();
|
this.orbitControls.update();
|
||||||
|
}
|
||||||
|
|
||||||
this.animationPauseListener = e => {
|
enable() {
|
||||||
if (this.enableAnimationControl) {
|
this.enableMouseControl = this.orbitControls.enableRotate = this.orbitControls.enableZoom = true;
|
||||||
e.preventDefault();
|
}
|
||||||
this.skinViewer.animationPaused = !this.skinViewer.animationPaused;
|
|
||||||
}
|
disable() {
|
||||||
};
|
this.enableMouseControl = this.orbitControls.enableRotate = this.orbitControls.enableZoom = false;
|
||||||
this.skinViewer.domElement.addEventListener("contextmenu", this.animationPauseListener, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
this.skinViewer.domElement.removeEventListener("contextmenu", this.animationPauseListener, false);
|
|
||||||
this.orbitControls.dispose();
|
this.orbitControls.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { SkinViewer, SkinControl };
|
export { SkinViewer, MouseControl };
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ export class SkinViewer {
|
||||||
public dispose(): void;
|
public dispose(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SkinControl {
|
export class MouseControl {
|
||||||
public enableAnimationControl: boolean;
|
public enableMouseControl: boolean;
|
||||||
public readonly skinViewer: SkinViewer;
|
public readonly skinViewer: SkinViewer;
|
||||||
|
|
||||||
constructor(skinViewer: SkinViewer);
|
constructor(skinViewer: SkinViewer);
|
||||||
|
|
||||||
|
public enable(): void;
|
||||||
|
public disable(): void;
|
||||||
public dispose(): void;
|
public dispose(): void;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue