Added new Projection Update event and respond to it

This commit is contained in:
Richard Davey 2020-12-10 18:07:25 +00:00
parent 4f5cedde03
commit 7acbd816f3
4 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,19 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Renderer Projection Update Event.
*
* This event is dispatched by the Phaser Renderer when the global Projection Matrix
* is updated.
*
* @event Phaser.Renderer.Events#PROJECTION
* @since 3.50.0
*
* @param {number} width - The new width of the renderer.
* @param {number} height - The new height of the renderer.
*/
module.exports = 'projection';

View file

@ -12,6 +12,7 @@ module.exports = {
POST_RENDER: require('./POST_RENDER_EVENT'),
PRE_RENDER: require('./PRE_RENDER_EVENT'),
PROJECTION: require('./PROJECTION_EVENT'),
RENDER: require('./RENDER_EVENT'),
RESIZE: require('./RESIZE_EVENT')

View file

@ -466,6 +466,7 @@ var WebGLPipeline = new Class({
renderer.on(RendererEvents.PRE_RENDER, this.onPreRender, this);
renderer.on(RendererEvents.RENDER, this.onRender, this);
renderer.on(RendererEvents.POST_RENDER, this.onPostRender, this);
renderer.on(RendererEvents.PROJECTION, this.setProjectionMatrix, this);
this.emit(Events.BOOT, this);
@ -2038,6 +2039,7 @@ var WebGLPipeline = new Class({
renderer.off(RendererEvents.PRE_RENDER, this.onPreRender, this);
renderer.off(RendererEvents.RENDER, this.onRender, this);
renderer.off(RendererEvents.POST_RENDER, this.onPostRender, this);
renderer.off(RendererEvents.PROJECTION, this.setProjectionMatrix, this);
this.removeAllListeners();

View file

@ -897,6 +897,8 @@ var WebGLRenderer = new Class({
this.renderTarget.bind(true, width, height);
this.emit(Events.PROJECTION, width, height);
this.resetTextures();
},
@ -915,6 +917,8 @@ var WebGLRenderer = new Class({
{
this.renderTarget.unbind(true);
this.emit(Events.PROJECTION, this.width, this.height);
return this.renderTarget;
},