Emit changed flag on controls end event

feature/threejs-update
Robin Hawkes 2016-12-05 15:49:38 +00:00
rodzic bfbb6bba34
commit 6bd41dfe72
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 1EC4C2D6765FA8CF
1 zmienionych plików z 27 dodań i 1 usunięć

Wyświetl plik

@ -16,6 +16,10 @@ class Orbit extends EventEmitter {
// There's currently no distinction between pan, orbit and zoom events
_initEvents() {
this._controls.addEventListener('start', (event) => {
this.startPosition = this._controls.target.clone();
this.startPolar = this._controls.getPolarAngle();
this.startAzimuth = this._controls.getAzimuthalAngle();
this._world.emit('controlsMoveStart', event.target.target);
});
@ -24,7 +28,29 @@ class Orbit extends EventEmitter {
});
this._controls.addEventListener('end', (event) => {
this._world.emit('controlsMoveEnd', event.target.target);
var endPosition = this._controls.target.clone();
var endPolar = this._controls.getPolarAngle();
var endAzimuth = this._controls.getAzimuthalAngle();
// Did controls change?
var changed = false;
// Panned
if (Math.abs(endPosition.distanceTo(this.startPosition)) > 0) {
changed = true;
}
// Tilted
if (Math.abs(endPolar - this.startPolar) > 0) {
changed = true;
}
// Obited
if (Math.abs(endAzimuth - this.startAzimuth) > 0) {
changed = true;
}
this._world.emit('controlsMoveEnd', event.target.target, changed);
});
}