mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
Finished documentation and added destroy method
This commit is contained in:
parent
5805925cc6
commit
42610c4fa6
1 changed files with 289 additions and 1 deletions
|
@ -14,6 +14,12 @@ var Utils = require('../Utils');
|
|||
|
||||
/**
|
||||
* @classdesc
|
||||
* The FXPipeline is a built-in pipeline that controls the application of FX Controllers during
|
||||
* the rendering process. It maintains all of the FX shaders, instances of Post FX Pipelines and
|
||||
* is responsible for rendering.
|
||||
*
|
||||
* You should rarely interact with this pipeline directly. Instead, use the FX Controllers that
|
||||
* is part of the Game Object class in order to manage the effects.
|
||||
*
|
||||
* @class FXPipeline
|
||||
* @extends Phaser.Renderer.WebGL.Pipelines.PreFXPipeline
|
||||
|
@ -55,15 +61,94 @@ var FXPipeline = new Class({
|
|||
|
||||
var game = this.game;
|
||||
|
||||
/**
|
||||
* An instance of the Glow Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#glow
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.GlowFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.glow = new FX.Glow(game);
|
||||
|
||||
/**
|
||||
* An instance of the Shadow Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#shadow
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.ShadowFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.shadow = new FX.Shadow(game);
|
||||
|
||||
/**
|
||||
* An instance of the Pixelate Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#pixelate
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.PixelateFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.pixelate = new FX.Pixelate(game);
|
||||
|
||||
/**
|
||||
* An instance of the Vignette Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#vignette
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.VignetteFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.vignette = new FX.Vignette(game);
|
||||
|
||||
/**
|
||||
* An instance of the Shine Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#shine
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.ShineFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.shine = new FX.Shine(game);
|
||||
|
||||
/**
|
||||
* An instance of the Gradient Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#gradient
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.GradientFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.gradient = new FX.Gradient(game);
|
||||
|
||||
/**
|
||||
* An instance of the Circle Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#circle
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.CircleFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.circle = new FX.Circle(game);
|
||||
|
||||
/**
|
||||
* An instance of the Barrel Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#barrel
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.BarrelFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.barrel = new FX.Barrel(game);
|
||||
|
||||
/**
|
||||
* An instance of the Wipe Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#wipe
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.WipeFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.wipe = new FX.Wipe(game);
|
||||
|
||||
/**
|
||||
* An instance of the Bokeh Post FX Pipeline.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#bokeh
|
||||
* @type {Phaser.Renderer.WebGL.Pipelines.FX.BokehFXPipeline}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.bokeh = new FX.Bokeh(game);
|
||||
|
||||
// This array is intentionally sparse. Do not adjust.
|
||||
|
@ -84,13 +169,58 @@ var FXPipeline = new Class({
|
|||
fxHandlers[FX_CONST.WIPE] = this.onWipe;
|
||||
fxHandlers[FX_CONST.BOKEH] = this.onBokeh;
|
||||
|
||||
/**
|
||||
* An array containing references to the methods that map to the FX CONSTs.
|
||||
*
|
||||
* This array is intentionally sparse. Do not adjust.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#glow
|
||||
* @type {function[]}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.fxHandlers = fxHandlers;
|
||||
|
||||
/**
|
||||
* The source Render Target.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#source
|
||||
* @type {Phaser.Renderer.WebGL.RenderTarget}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.source;
|
||||
|
||||
/**
|
||||
* The target Render Target.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#target
|
||||
* @type {Phaser.Renderer.WebGL.RenderTarget}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.target;
|
||||
|
||||
/**
|
||||
* The swap Render Target.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.Pipelines.FXPipeline#swap
|
||||
* @type {Phaser.Renderer.WebGL.RenderTarget}
|
||||
* @since 3.60.0
|
||||
*/
|
||||
this.swap;
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes the currently bound Game Object and runs all of its pre-render effects,
|
||||
* using the given Render Target as the source.
|
||||
*
|
||||
* Finally calls `drawToGame` to copy the result to the Game Canvas.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onDraw
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.Renderer.WebGL.RenderTarget} target1 - The source Render Target.
|
||||
* @param {Phaser.Renderer.WebGL.RenderTarget} target2 - The target Render Target.
|
||||
* @param {Phaser.Renderer.WebGL.RenderTarget} target3 - The swap Render Target.
|
||||
*/
|
||||
onDraw: function (target1, target2, target3)
|
||||
{
|
||||
this.source = target1;
|
||||
|
@ -121,6 +251,14 @@ var FXPipeline = new Class({
|
|||
this.drawToGame(this.source);
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes the source and target and runs a copy from source to target.
|
||||
*
|
||||
* This will use the current shader and pipeline.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#runDraw
|
||||
* @since 3.60.0
|
||||
*/
|
||||
runDraw: function ()
|
||||
{
|
||||
var source = this.source;
|
||||
|
@ -132,6 +270,16 @@ var FXPipeline = new Class({
|
|||
this.target = source;
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Glow FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onGlow
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Glow} config - The Glow FX controller.
|
||||
* @param {number} width - The width of the target.
|
||||
* @param {number} height - The height of the target.
|
||||
*/
|
||||
onGlow: function (config, width, height)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.GLOW];
|
||||
|
@ -143,6 +291,14 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Shadow FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onShadow
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Shadow} config - The Shadow FX controller.
|
||||
*/
|
||||
onShadow: function (config)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.SHADOW];
|
||||
|
@ -154,6 +310,16 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Pixelate FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onPixelate
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Pixelate} config - The Pixelate FX controller.
|
||||
* @param {number} width - The width of the target.
|
||||
* @param {number} height - The height of the target.
|
||||
*/
|
||||
onPixelate: function (config, width, height)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.PIXELATE];
|
||||
|
@ -165,6 +331,14 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Vignette FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onVignette
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Vignette} config - The Vignette FX controller.
|
||||
*/
|
||||
onVignette: function (config)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.VIGNETTE];
|
||||
|
@ -176,6 +350,16 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Shine FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onShine
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Shine} config - The Shine FX controller.
|
||||
* @param {number} width - The width of the target.
|
||||
* @param {number} height - The height of the target.
|
||||
*/
|
||||
onShine: function (config, width, height)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.SHINE];
|
||||
|
@ -187,6 +371,16 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Blur FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onBlur
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Blur} config - The Blur FX controller.
|
||||
* @param {number} width - The width of the target.
|
||||
* @param {number} height - The height of the target.
|
||||
*/
|
||||
onBlur: function (config, width, height)
|
||||
{
|
||||
var quality = GetFastValue(config, 'quality');
|
||||
|
@ -214,6 +408,14 @@ var FXPipeline = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Gradient FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onGradient
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Gradient} config - The Gradient FX controller.
|
||||
*/
|
||||
onGradient: function (config)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.GRADIENT];
|
||||
|
@ -225,6 +427,16 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Bloom FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onBloom
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Bloom} config - The Bloom FX controller.
|
||||
* @param {number} width - The width of the target.
|
||||
* @param {number} height - The height of the target.
|
||||
*/
|
||||
onBloom: function (config, width, height)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.BLOOM];
|
||||
|
@ -254,6 +466,14 @@ var FXPipeline = new Class({
|
|||
this.copySprite(this.target, this.source);
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the ColorMatrix FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onColorMatrix
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.ColorMatrix} config - The ColorMatrix FX controller.
|
||||
*/
|
||||
onColorMatrix: function (config)
|
||||
{
|
||||
this.setShader(this.colorMatrixShader);
|
||||
|
@ -264,6 +484,16 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Circle FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onCircle
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Circle} config - The Circle FX controller.
|
||||
* @param {number} width - The width of the target.
|
||||
* @param {number} height - The height of the target.
|
||||
*/
|
||||
onCircle: function (config, width, height)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.CIRCLE];
|
||||
|
@ -275,6 +505,14 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Barrel FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onBarrel
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Barrel} config - The Barrel FX controller.
|
||||
*/
|
||||
onBarrel: function (config)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.BARREL];
|
||||
|
@ -286,6 +524,14 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Displacement FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onDisplacement
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Displacement} config - The Displacement FX controller.
|
||||
*/
|
||||
onDisplacement: function (config)
|
||||
{
|
||||
this.setShader(this.shaders[FX_CONST.DISPLACEMENT]);
|
||||
|
@ -298,6 +544,14 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Wipe FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onWipe
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Wipe} config - The Wipe FX controller.
|
||||
*/
|
||||
onWipe: function (config)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.WIPE];
|
||||
|
@ -309,6 +563,14 @@ var FXPipeline = new Class({
|
|||
this.runDraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* Runs the Bokeh FX controller.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#onBokeh
|
||||
* @since 3.60.0
|
||||
*
|
||||
* @param {Phaser.FX.Controller.Bokeh} config - The Bokeh FX controller.
|
||||
*/
|
||||
onBokeh: function (config, width, height)
|
||||
{
|
||||
var shader = this.shaders[FX_CONST.BOKEH];
|
||||
|
@ -318,8 +580,34 @@ var FXPipeline = new Class({
|
|||
this.bokeh.onPreRender(config, shader, width, height);
|
||||
|
||||
this.runDraw();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys all shader instances, removes all object references and nulls all external references.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.Pipelines.FXPipeline#destroy
|
||||
* @since 3.60.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.glow.destroy();
|
||||
this.shadow.destroy();
|
||||
this.pixelate.destroy();
|
||||
this.vignette.destroy();
|
||||
this.shine.destroy();
|
||||
this.gradient.destroy();
|
||||
this.circle.destroy();
|
||||
this.barrel.destroy();
|
||||
this.wipe.destroy();
|
||||
this.bokeh.destroy();
|
||||
|
||||
this.fxHandlers = null;
|
||||
this.source = null;
|
||||
this.target = null;
|
||||
this.swap = null;
|
||||
|
||||
PreFXPipeline.prototype.destroy.call(this);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = FXPipeline;
|
||||
|
|
Loading…
Reference in a new issue