optimize: sepia application

This commit is contained in:
cha0s 2019-04-21 20:57:55 -05:00
parent 6a93555354
commit 53e1ecc595

View File

@ -66,7 +66,14 @@ export class App extends decorate(class {}) {
this.roomView = new RoomView(this.room, this.stage.renderer);
this.stage.addChild(this.roomView);
this.on('darknessChanged', this.applyLighting, this);
this.on('isFocusedChanged', this.applyLighting, this);
this.on('isFocusedChanged', () => {
if (this.isFocused) {
this.stage.removeAllFilters();
}
else {
this.stage.sepia();
}
})
// Listen for new entities.
this.room.on('entityAdded', this.onRoomEntityAdded, this);
// Input.
@ -100,7 +107,6 @@ export class App extends decorate(class {}) {
}
applyLighting() {
this.stage.removeAllFilters();
const roomView = this.roomView;
if (!roomView) {
return;
@ -128,9 +134,6 @@ export class App extends decorate(class {}) {
const layerContainer = layerView.layerContainer;
layerContainer.night(this.darkness);
}
if (!this.isFocused) {
this.stage.paused(this.darkness);
}
}
calculateDarkness() {