全部移动至es模块
This commit is contained in:
@@ -1,58 +1,60 @@
|
||||
class PostProcessor {
|
||||
public enabled: boolean;
|
||||
public effect: egret.Filter;
|
||||
public scene: Scene;
|
||||
public shape: egret.Shape;
|
||||
module es {
|
||||
export class PostProcessor {
|
||||
public enabled: boolean;
|
||||
public effect: egret.Filter;
|
||||
public scene: Scene;
|
||||
public shape: egret.Shape;
|
||||
|
||||
public static default_vert = "attribute vec2 aVertexPosition;\n" +
|
||||
"attribute vec2 aTextureCoord;\n" +
|
||||
"attribute vec2 aColor;\n" +
|
||||
|
||||
"uniform vec2 projectionVector;\n" +
|
||||
//"uniform vec2 offsetVector;\n" +
|
||||
public static default_vert = "attribute vec2 aVertexPosition;\n" +
|
||||
"attribute vec2 aTextureCoord;\n" +
|
||||
"attribute vec2 aColor;\n" +
|
||||
|
||||
"varying vec2 vTextureCoord;\n" +
|
||||
"varying vec4 vColor;\n" +
|
||||
"uniform vec2 projectionVector;\n" +
|
||||
//"uniform vec2 offsetVector;\n" +
|
||||
|
||||
"const vec2 center = vec2(-1.0, 1.0);\n" +
|
||||
"varying vec2 vTextureCoord;\n" +
|
||||
"varying vec4 vColor;\n" +
|
||||
|
||||
"void main(void) {\n" +
|
||||
"gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" +
|
||||
"vTextureCoord = aTextureCoord;\n" +
|
||||
"vColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n" +
|
||||
"}";
|
||||
"const vec2 center = vec2(-1.0, 1.0);\n" +
|
||||
|
||||
constructor(effect: egret.Filter = null){
|
||||
this.enabled = true;
|
||||
this.effect = effect;
|
||||
}
|
||||
"void main(void) {\n" +
|
||||
"gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" +
|
||||
"vTextureCoord = aTextureCoord;\n" +
|
||||
"vColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n" +
|
||||
"}";
|
||||
|
||||
public onAddedToScene(scene: Scene){
|
||||
this.scene = scene;
|
||||
this.shape = new egret.Shape();
|
||||
this.shape.graphics.beginFill(0xFFFFFF, 1);
|
||||
this.shape.graphics.drawRect(0, 0, SceneManager.stage.stageWidth, SceneManager.stage.stageHeight);
|
||||
this.shape.graphics.endFill();
|
||||
scene.addChild(this.shape);
|
||||
}
|
||||
|
||||
public process(){
|
||||
this.drawFullscreenQuad();
|
||||
}
|
||||
|
||||
public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number){}
|
||||
|
||||
protected drawFullscreenQuad(){
|
||||
this.scene.filters = [this.effect];
|
||||
// this.shape.filters = [this.effect];
|
||||
}
|
||||
|
||||
public unload(){
|
||||
if (this.effect){
|
||||
this.effect = null;
|
||||
constructor(effect: egret.Filter = null){
|
||||
this.enabled = true;
|
||||
this.effect = effect;
|
||||
}
|
||||
|
||||
this.scene.removeChild(this.shape);
|
||||
this.scene = null;
|
||||
public onAddedToScene(scene: Scene){
|
||||
this.scene = scene;
|
||||
this.shape = new egret.Shape();
|
||||
this.shape.graphics.beginFill(0xFFFFFF, 1);
|
||||
this.shape.graphics.drawRect(0, 0, SceneManager.stage.stageWidth, SceneManager.stage.stageHeight);
|
||||
this.shape.graphics.endFill();
|
||||
scene.addChild(this.shape);
|
||||
}
|
||||
|
||||
public process(){
|
||||
this.drawFullscreenQuad();
|
||||
}
|
||||
|
||||
public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number){}
|
||||
|
||||
protected drawFullscreenQuad(){
|
||||
this.scene.filters = [this.effect];
|
||||
// this.shape.filters = [this.effect];
|
||||
}
|
||||
|
||||
public unload(){
|
||||
if (this.effect){
|
||||
this.effect = null;
|
||||
}
|
||||
|
||||
this.scene.removeChild(this.shape);
|
||||
this.scene = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
class GaussianBlurPostProcessor extends PostProcessor {
|
||||
public onAddedToScene(scene: Scene){
|
||||
super.onAddedToScene(scene);
|
||||
this.effect = new GaussianBlurEffect();
|
||||
module es {
|
||||
export class GaussianBlurPostProcessor extends PostProcessor {
|
||||
public onAddedToScene(scene: Scene){
|
||||
super.onAddedToScene(scene);
|
||||
this.effect = new GaussianBlurEffect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user