Files
esengine/source/src/Graphics/PostProcessing/PostProcessor.ts

36 lines
915 B
TypeScript
Raw Normal View History

class PostProcessor {
public enable: boolean;
public effect: egret.CustomFilter;
public scene: Scene;
public shape: egret.Shape;
constructor(effect: egret.CustomFilter = null){
2020-06-23 16:18:14 +08:00
this.enable = true;
this.effect = effect;
}
public onAddedToScene(scene: Scene){
this.scene = scene;
this.shape = new egret.Shape();
scene.addChild(this.shape);
}
public process(source: egret.DisplayObject){
this.drawFullscreenQuad(source, this.effect);
}
2020-06-23 16:18:14 +08:00
public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number){}
protected drawFullscreenQuad(texture: egret.DisplayObject, effect: egret.CustomFilter = null){
2020-06-23 16:18:14 +08:00
texture.filters = [effect];
}
public unload(){
if (this.effect){
this.effect = null;
}
this.scene.removeChild(this.shape);
2020-06-23 16:18:14 +08:00
this.scene = null;
}
}