This commit is contained in:
Richard Davey 2024-02-27 15:53:24 +00:00
parent 8acc797b64
commit 4f7445f8d7
15 changed files with 299946 additions and 550108 deletions

View file

@ -1,9 +1,14 @@
# Version 3.80.1 - Nino - 27 February 2024
# Version 3.80.1 - Nino - 27th February 2024
# Bug Fixes
## Bug Fixes
* Fix `RenderTexture` crashing in the presence of a light.
* Fix failure to restore compressed textures after WebGL context loss.
* Fix a single WebGL error, with no visual side-effects, from occurring while calling `Shader.setRenderToTexture()` after the game has started running. Actually, the root cause was leaving new WebGL textures bound after creation.
* Ensure that `TextureSource.setFlipY` always updates the texture.
* Remove unsynced `flipY` from render textures in `Shader` and `DynamicTexture`.
* Reverted a change made in `TouchManager` that would prevent clicks from outside the game window from being registered. Fix #6747 (thanks @ulsoftnaver @jaxtheking)
## Updates
* Modified `onMouseUpWindow` and `onMouseDownWindow` in the `MouseManager` so they now check for `sourceCapabilities.firesTouchEvents` and if found, abort registering the event. This new browser event property is designed to prevent you accidentally registering a Mouse Event when a Touch Event has just occurred (see https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceCapabilities/firesTouchEvents)

View file

@ -15691,7 +15691,7 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
VERSION: '3.80.0',
VERSION: '3.80.1',
BlendModes: __webpack_require__(10312),
@ -57420,17 +57420,15 @@ var Utils = __webpack_require__(70554);
/**
* @classdesc
* A 2D point light.
* A 2D Light.
*
* These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
* These are created by the {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
*
* Any Game Objects using the Light2D pipeline will then be affected by these Lights as long as they have a normal map.
*
* They can also simply be used to represent a point light for your own purposes.
*
* As of Phaser 3.60 this Game Object now has the Transform and Origin components. However, changing the scale,
* rotation or origin properties will not make any difference to the Light. They are simply present to allow you
* to add this Light to a Container, or enable it for Physics.
* Lights cannot be added to Containers. They are designed to exist in the root of a Scene.
*
* @class Light
* @extends Phaser.Geom.Circle
@ -57440,7 +57438,6 @@ var Utils = __webpack_require__(70554);
*
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {number} x - The horizontal position of the light.
@ -57458,7 +57455,6 @@ var Light = new Class({
Mixins: [
Components.Origin,
Components.ScrollFactor,
Components.Transform,
Components.Visible
],
@ -72754,7 +72750,7 @@ var Shader = new Class({
/**
* A reference to the Phaser.Textures.Texture that has been stored in the Texture Manager for this Shader.
*
* This property is only set if you have called `Shader.setRenderToTexture`, otherwise it is `null`.
* This property is only set if you have called `Shader.setRenderToTexture` with a key, otherwise it is `null`.
*
* @name Phaser.GameObjects.Shader#texture
* @type {Phaser.Textures.Texture}
@ -72844,8 +72840,6 @@ var Shader = new Class({
this.glTexture = renderer.createTextureFromSource(null, width, height, 0);
this.glTexture.flipY = flipY;
this.framebuffer = renderer.createFramebuffer(width, height, this.glTexture, false);
this._rendererWidth = width;
@ -73334,17 +73328,13 @@ var Shader = new Class({
return;
}
var gl = this.gl;
gl.activeTexture(gl.TEXTURE0 + this._textureCount);
gl.bindTexture(gl.TEXTURE_2D, uniform.value.webGLTexture);
// Extended texture data
var data = uniform.textureData;
if (data && !uniform.value.isRenderTexture)
{
var gl = this.gl;
var wrapper = uniform.value;
// https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D
@ -73358,6 +73348,10 @@ var Shader = new Class({
var wrapS = gl[GetFastValue(data, 'wrapS', 'repeat').toUpperCase()];
var wrapT = gl[GetFastValue(data, 'wrapT', 'repeat').toUpperCase()];
var format = gl[GetFastValue(data, 'format', 'rgba').toUpperCase()];
var flipY = GetFastValue(data, 'flipY', false);
var width = GetFastValue(data, 'width', wrapper.width);
var height = GetFastValue(data, 'height', wrapper.height);
var source = GetFastValue(data, 'source', wrapper.pixels);
if (data.repeat)
{
@ -73365,38 +73359,13 @@ var Shader = new Class({
wrapT = gl.REPEAT;
}
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, !!data.flipY);
if (data.width)
{
var width = GetFastValue(data, 'width', 512);
var height = GetFastValue(data, 'height', 2);
var border = GetFastValue(data, 'border', 0);
// texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels)
gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null);
wrapper.width = width;
wrapper.height = height;
}
else
{
// texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, ImageData? pixels)
gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, uniform.source);
// If the uniform has resolution, use a blank texture.
source = null;
}
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);
// Update texture wrapper.
wrapper.magFilter = magFilter;
wrapper.minFilter = minFilter;
wrapper.wrapS = wrapS;
wrapper.wrapT = wrapT;
wrapper.format = format;
wrapper.flipY = !!data.flipY;
wrapper.pixels = uniform.source;
wrapper.update(source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format);
}
this.renderer.setProgram(this.program);
@ -116500,6 +116469,11 @@ var MouseManager = new Class({
this.onMouseDownWindow = function (event)
{
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents)
{
return;
}
if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas)
{
// Only process the event if the target isn't the canvas
@ -116522,6 +116496,11 @@ var MouseManager = new Class({
this.onMouseUpWindow = function (event)
{
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents)
{
return;
}
if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas)
{
// Only process the event if the target isn't the canvas
@ -116995,11 +116974,6 @@ var TouchManager = new Class({
{
// Only process the event if the target isn't the canvas
manager.onTouchEnd(event);
if (_this.capture && event.cancelable)
{
event.preventDefault();
}
}
};
@ -161195,6 +161169,9 @@ var WebGLRenderer = new Class({
gl.disable(gl.DEPTH_TEST);
gl.enable(gl.CULL_FACE);
// Re-enable compressed texture formats.
_this.compression = _this.getCompressedTextures();
// Restore wrapped GL objects.
// Order matters, as some wrappers depend on others.
var wrapperCreateResource = function (wrapper)
@ -163326,13 +163303,37 @@ var WebGLRenderer = new Class({
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
if (!dstTexture)
{
return this.createCanvasTexture(srcCanvas, noRepeat, flipY);
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcCanvas, width, height, true, false, flipY);
}
else
{
return this.updateCanvasTexture(srcCanvas, dstTexture, flipY, noRepeat);
dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter, dstTexture.format);
return dstTexture;
}
},
@ -163353,29 +163354,7 @@ var WebGLRenderer = new Class({
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcCanvas, width, height, true, false, flipY);
return this.canvasToTexture(srcCanvas, null, noRepeat, flipY);
},
/**
@ -163396,46 +163375,25 @@ var WebGLRenderer = new Class({
if (flipY === undefined) { flipY = false; }
if (noRepeat === undefined) { noRepeat = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter);
return dstTexture;
return this.canvasToTexture(srcCanvas, dstTexture, noRepeat, flipY);
},
/**
* Creates a new WebGL Texture based on the given HTML Video Element.
* Creates or updates a WebGL Texture based on the given HTML Video Element.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#createVideoTexture
* @since 3.20.0
* If the `dstTexture` parameter is given, the WebGL Texture is updated, rather than created fresh.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#videoToTexture
* @since 3.90.0
*
* @param {HTMLVideoElement} srcVideo - The Video to create the WebGL Texture from
* @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [dstTexture] - The destination WebGLTextureWrapper to set.
* @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`?
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`?
*
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper.
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created, or updated, WebGLTextureWrapper.
*/
createVideoTexture: function (srcVideo, noRepeat, flipY)
videoToTexture: function (srcVideo, dstTexture, noRepeat, flipY)
{
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
@ -163462,7 +163420,36 @@ var WebGLRenderer = new Class({
magFilter = gl.LINEAR;
}
if (!dstTexture)
{
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcVideo, width, height, true, true, flipY);
}
else
{
dstTexture.update(srcVideo, width, height, flipY, wrapping, wrapping, minFilter, magFilter, dstTexture.format);
return dstTexture;
}
},
/**
* Creates a new WebGL Texture based on the given HTML Video Element.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#createVideoTexture
* @since 3.20.0
*
* @param {HTMLVideoElement} srcVideo - The Video to create the WebGL Texture from
* @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`?
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`?
*
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper.
*/
createVideoTexture: function (srcVideo, noRepeat, flipY)
{
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
return this.videoToTexture(srcVideo, null, noRepeat, flipY);
},
/**
@ -163483,31 +163470,7 @@ var WebGLRenderer = new Class({
if (flipY === undefined) { flipY = false; }
if (noRepeat === undefined) { noRepeat = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcVideo.videoWidth;
var height = srcVideo.videoHeight;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
dstTexture.update(srcVideo, width, height, flipY, wrapping, wrapping, minFilter, magFilter);
return dstTexture;
return this.videoToTexture(srcVideo, dstTexture, noRepeat, flipY);
},
/**
@ -166180,7 +166143,7 @@ var LightPipeline = new Class({
if (!gameObject)
{
return this.renderer.normalMap;
return this.renderer.normalTexture;
}
else if (gameObject.displayTexture)
{
@ -166204,7 +166167,7 @@ var LightPipeline = new Class({
if (!normalMap)
{
return this.renderer.normalMap;
return this.renderer.normalTexture;
}
return normalMap.glTexture;
@ -166845,9 +166808,7 @@ var MultiPipeline = new Class({
flipX = -1;
}
// Auto-invert the flipY if this is coming from a GL RenderTexture
if (gameObject.flipY || (frame.source.isGLTexture && frame.source.isRenderTexture && !texture.flipY))
if (gameObject.flipY)
{
if (!customPivot)
{
@ -174507,11 +174468,81 @@ var WebGLTextureWrapper = new Class({
var texture = gl.createTexture();
// Set Spector metadata.
// eslint-disable-next-line camelcase
texture.__SPECTOR_Metadata = this.__SPECTOR_Metadata;
// Assign the texture to our wrapper.
this.webGLTexture = texture;
this._processTexture();
},
/**
* Updates the WebGLTexture from an updated source.
*
* This should only be used when the source is a Canvas or Video element.
*
* @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#update
* @since 3.80.0
*
* @param {?object} source - The source to update the WebGLTexture with.
* @param {number} width - The new width of the WebGLTexture.
* @param {number} height - The new height of the WebGLTexture.
* @param {boolean} flipY - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`?
* @param {number} wrapS - The new wrapping mode for the WebGLTexture.
* @param {number} wrapT - The new wrapping mode for the WebGLTexture.
* @param {number} minFilter - The new minification filter for the WebGLTexture.
* @param {number} magFilter - The new magnification filter for the WebGLTexture.
* @param {number} format - The new format for the WebGLTexture.
*/
update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format)
{
if (width === 0 || height === 0)
{
return;
}
// Assume that the source might change.
this.pixels = source;
this.width = width;
this.height = height;
this.flipY = flipY;
this.wrapS = wrapS;
this.wrapT = wrapT;
this.minFilter = minFilter;
this.magFilter = magFilter;
this.format = format;
var gl = this.gl;
if (gl.isContextLost())
{
// GL state can't be updated right now.
// `createResource` will run when the context is restored.
return;
}
this._processTexture();
},
/**
* Set all parameters of this WebGLTexture per the stored values.
*
* @function Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#_processTexture
* @protected
* @since 3.90.0
* @ignore
*/
_processTexture: function ()
{
var gl = this.gl;
gl.activeTexture(gl.TEXTURE0);
var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter);
@ -174519,11 +174550,7 @@ var WebGLTextureWrapper = new Class({
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma);
if (this.flipY)
{
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
}
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this.flipY);
var pixels = this.pixels;
var mipLevel = this.mipLevel;
@ -174553,6 +174580,8 @@ var WebGLTextureWrapper = new Class({
else if (pixels instanceof Uint8Array)
{
gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, pixels);
generateMipmap = IsSizePowerOfTwo(width, height);
}
else
{
@ -174572,90 +174601,14 @@ var WebGLTextureWrapper = new Class({
gl.generateMipmap(gl.TEXTURE_2D);
}
// Set Spector metadata.
// eslint-disable-next-line camelcase
texture.__SPECTOR_Metadata = this.__SPECTOR_Metadata;
// Restore previous texture bind.
if (currentTexture)
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
}
// Assign the texture to our wrapper.
this.webGLTexture = texture;
},
/**
* Updates the WebGLTexture from an updated source.
*
* This should only be used when the source is a Canvas or Video element.
*
* @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#update
* @since 3.80.0
*
* @param {HTMLCanvasElement|HTMLVideoElement} source - The source to update the WebGLTexture with.
* @param {number} width - The new width of the WebGLTexture.
* @param {number} height - The new height of the WebGLTexture.
* @param {boolean} flipY - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`?
* @param {number} wrapS - The new wrapping mode for the WebGLTexture.
* @param {number} wrapT - The new wrapping mode for the WebGLTexture.
* @param {number} minFilter - The new minification filter for the WebGLTexture.
* @param {number} magFilter - The new magnification filter for the WebGLTexture.
*/
update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter)
else
{
if (width === 0 || height === 0)
{
return;
}
// Assume that the source might change.
this.pixels = source;
this.width = width;
this.height = height;
this.flipY = flipY;
this.wrapS = wrapS;
this.wrapT = wrapT;
this.minFilter = minFilter;
this.magFilter = magFilter;
var gl = this.gl;
if (gl.isContextLost())
{
// GL state can't be updated right now.
// `createResource` will run when the context is restored.
return;
}
gl.activeTexture(gl.TEXTURE0);
var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this.wrapS);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
// Should we generate mipmaps?
var pixels = this.pixels;
if (IsSizePowerOfTwo(width, height) && !pixels.compressed && !(pixels instanceof Uint8Array))
{
gl.generateMipmap(gl.TEXTURE_2D);
}
// Restore previous texture bind.
if (currentTexture)
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
gl.bindTexture(gl.TEXTURE_2D, null);
}
},
@ -193359,7 +193312,6 @@ var DynamicTexture = new Class({
source.isGLTexture = true;
source.glTexture = renderTarget.texture;
source.glTexture.flipY = true;
return this;
},
@ -198129,7 +198081,10 @@ var TextureSource = new Class({
{
if (value === undefined) { value = true; }
if (value === this.flipY) { return this; }
this.flipY = value;
this.update();
return this;
},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

393
dist/phaser-ie9.js vendored
View file

@ -15691,7 +15691,7 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
VERSION: '3.80.0',
VERSION: '3.80.1',
BlendModes: __webpack_require__(10312),
@ -57420,17 +57420,15 @@ var Utils = __webpack_require__(70554);
/**
* @classdesc
* A 2D point light.
* A 2D Light.
*
* These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
* These are created by the {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
*
* Any Game Objects using the Light2D pipeline will then be affected by these Lights as long as they have a normal map.
*
* They can also simply be used to represent a point light for your own purposes.
*
* As of Phaser 3.60 this Game Object now has the Transform and Origin components. However, changing the scale,
* rotation or origin properties will not make any difference to the Light. They are simply present to allow you
* to add this Light to a Container, or enable it for Physics.
* Lights cannot be added to Containers. They are designed to exist in the root of a Scene.
*
* @class Light
* @extends Phaser.Geom.Circle
@ -57440,7 +57438,6 @@ var Utils = __webpack_require__(70554);
*
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {number} x - The horizontal position of the light.
@ -57458,7 +57455,6 @@ var Light = new Class({
Mixins: [
Components.Origin,
Components.ScrollFactor,
Components.Transform,
Components.Visible
],
@ -72754,7 +72750,7 @@ var Shader = new Class({
/**
* A reference to the Phaser.Textures.Texture that has been stored in the Texture Manager for this Shader.
*
* This property is only set if you have called `Shader.setRenderToTexture`, otherwise it is `null`.
* This property is only set if you have called `Shader.setRenderToTexture` with a key, otherwise it is `null`.
*
* @name Phaser.GameObjects.Shader#texture
* @type {Phaser.Textures.Texture}
@ -72844,8 +72840,6 @@ var Shader = new Class({
this.glTexture = renderer.createTextureFromSource(null, width, height, 0);
this.glTexture.flipY = flipY;
this.framebuffer = renderer.createFramebuffer(width, height, this.glTexture, false);
this._rendererWidth = width;
@ -73334,17 +73328,13 @@ var Shader = new Class({
return;
}
var gl = this.gl;
gl.activeTexture(gl.TEXTURE0 + this._textureCount);
gl.bindTexture(gl.TEXTURE_2D, uniform.value.webGLTexture);
// Extended texture data
var data = uniform.textureData;
if (data && !uniform.value.isRenderTexture)
{
var gl = this.gl;
var wrapper = uniform.value;
// https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D
@ -73358,6 +73348,10 @@ var Shader = new Class({
var wrapS = gl[GetFastValue(data, 'wrapS', 'repeat').toUpperCase()];
var wrapT = gl[GetFastValue(data, 'wrapT', 'repeat').toUpperCase()];
var format = gl[GetFastValue(data, 'format', 'rgba').toUpperCase()];
var flipY = GetFastValue(data, 'flipY', false);
var width = GetFastValue(data, 'width', wrapper.width);
var height = GetFastValue(data, 'height', wrapper.height);
var source = GetFastValue(data, 'source', wrapper.pixels);
if (data.repeat)
{
@ -73365,38 +73359,13 @@ var Shader = new Class({
wrapT = gl.REPEAT;
}
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, !!data.flipY);
if (data.width)
{
var width = GetFastValue(data, 'width', 512);
var height = GetFastValue(data, 'height', 2);
var border = GetFastValue(data, 'border', 0);
// texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels)
gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null);
wrapper.width = width;
wrapper.height = height;
}
else
{
// texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, ImageData? pixels)
gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, uniform.source);
// If the uniform has resolution, use a blank texture.
source = null;
}
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);
// Update texture wrapper.
wrapper.magFilter = magFilter;
wrapper.minFilter = minFilter;
wrapper.wrapS = wrapS;
wrapper.wrapT = wrapT;
wrapper.format = format;
wrapper.flipY = !!data.flipY;
wrapper.pixels = uniform.source;
wrapper.update(source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format);
}
this.renderer.setProgram(this.program);
@ -116500,6 +116469,11 @@ var MouseManager = new Class({
this.onMouseDownWindow = function (event)
{
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents)
{
return;
}
if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas)
{
// Only process the event if the target isn't the canvas
@ -116522,6 +116496,11 @@ var MouseManager = new Class({
this.onMouseUpWindow = function (event)
{
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents)
{
return;
}
if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas)
{
// Only process the event if the target isn't the canvas
@ -116995,11 +116974,6 @@ var TouchManager = new Class({
{
// Only process the event if the target isn't the canvas
manager.onTouchEnd(event);
if (_this.capture && event.cancelable)
{
event.preventDefault();
}
}
};
@ -179690,6 +179664,9 @@ var WebGLRenderer = new Class({
gl.disable(gl.DEPTH_TEST);
gl.enable(gl.CULL_FACE);
// Re-enable compressed texture formats.
_this.compression = _this.getCompressedTextures();
// Restore wrapped GL objects.
// Order matters, as some wrappers depend on others.
var wrapperCreateResource = function (wrapper)
@ -181821,13 +181798,37 @@ var WebGLRenderer = new Class({
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
if (!dstTexture)
{
return this.createCanvasTexture(srcCanvas, noRepeat, flipY);
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcCanvas, width, height, true, false, flipY);
}
else
{
return this.updateCanvasTexture(srcCanvas, dstTexture, flipY, noRepeat);
dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter, dstTexture.format);
return dstTexture;
}
},
@ -181848,29 +181849,7 @@ var WebGLRenderer = new Class({
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcCanvas, width, height, true, false, flipY);
return this.canvasToTexture(srcCanvas, null, noRepeat, flipY);
},
/**
@ -181891,46 +181870,25 @@ var WebGLRenderer = new Class({
if (flipY === undefined) { flipY = false; }
if (noRepeat === undefined) { noRepeat = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter);
return dstTexture;
return this.canvasToTexture(srcCanvas, dstTexture, noRepeat, flipY);
},
/**
* Creates a new WebGL Texture based on the given HTML Video Element.
* Creates or updates a WebGL Texture based on the given HTML Video Element.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#createVideoTexture
* @since 3.20.0
* If the `dstTexture` parameter is given, the WebGL Texture is updated, rather than created fresh.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#videoToTexture
* @since 3.90.0
*
* @param {HTMLVideoElement} srcVideo - The Video to create the WebGL Texture from
* @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [dstTexture] - The destination WebGLTextureWrapper to set.
* @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`?
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`?
*
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper.
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created, or updated, WebGLTextureWrapper.
*/
createVideoTexture: function (srcVideo, noRepeat, flipY)
videoToTexture: function (srcVideo, dstTexture, noRepeat, flipY)
{
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
@ -181957,7 +181915,36 @@ var WebGLRenderer = new Class({
magFilter = gl.LINEAR;
}
if (!dstTexture)
{
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcVideo, width, height, true, true, flipY);
}
else
{
dstTexture.update(srcVideo, width, height, flipY, wrapping, wrapping, minFilter, magFilter, dstTexture.format);
return dstTexture;
}
},
/**
* Creates a new WebGL Texture based on the given HTML Video Element.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#createVideoTexture
* @since 3.20.0
*
* @param {HTMLVideoElement} srcVideo - The Video to create the WebGL Texture from
* @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`?
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`?
*
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper.
*/
createVideoTexture: function (srcVideo, noRepeat, flipY)
{
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
return this.videoToTexture(srcVideo, null, noRepeat, flipY);
},
/**
@ -181978,31 +181965,7 @@ var WebGLRenderer = new Class({
if (flipY === undefined) { flipY = false; }
if (noRepeat === undefined) { noRepeat = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcVideo.videoWidth;
var height = srcVideo.videoHeight;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
dstTexture.update(srcVideo, width, height, flipY, wrapping, wrapping, minFilter, magFilter);
return dstTexture;
return this.videoToTexture(srcVideo, dstTexture, noRepeat, flipY);
},
/**
@ -184675,7 +184638,7 @@ var LightPipeline = new Class({
if (!gameObject)
{
return this.renderer.normalMap;
return this.renderer.normalTexture;
}
else if (gameObject.displayTexture)
{
@ -184699,7 +184662,7 @@ var LightPipeline = new Class({
if (!normalMap)
{
return this.renderer.normalMap;
return this.renderer.normalTexture;
}
return normalMap.glTexture;
@ -185340,9 +185303,7 @@ var MultiPipeline = new Class({
flipX = -1;
}
// Auto-invert the flipY if this is coming from a GL RenderTexture
if (gameObject.flipY || (frame.source.isGLTexture && frame.source.isRenderTexture && !texture.flipY))
if (gameObject.flipY)
{
if (!customPivot)
{
@ -193002,11 +192963,81 @@ var WebGLTextureWrapper = new Class({
var texture = gl.createTexture();
// Set Spector metadata.
// eslint-disable-next-line camelcase
texture.__SPECTOR_Metadata = this.__SPECTOR_Metadata;
// Assign the texture to our wrapper.
this.webGLTexture = texture;
this._processTexture();
},
/**
* Updates the WebGLTexture from an updated source.
*
* This should only be used when the source is a Canvas or Video element.
*
* @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#update
* @since 3.80.0
*
* @param {?object} source - The source to update the WebGLTexture with.
* @param {number} width - The new width of the WebGLTexture.
* @param {number} height - The new height of the WebGLTexture.
* @param {boolean} flipY - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`?
* @param {number} wrapS - The new wrapping mode for the WebGLTexture.
* @param {number} wrapT - The new wrapping mode for the WebGLTexture.
* @param {number} minFilter - The new minification filter for the WebGLTexture.
* @param {number} magFilter - The new magnification filter for the WebGLTexture.
* @param {number} format - The new format for the WebGLTexture.
*/
update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format)
{
if (width === 0 || height === 0)
{
return;
}
// Assume that the source might change.
this.pixels = source;
this.width = width;
this.height = height;
this.flipY = flipY;
this.wrapS = wrapS;
this.wrapT = wrapT;
this.minFilter = minFilter;
this.magFilter = magFilter;
this.format = format;
var gl = this.gl;
if (gl.isContextLost())
{
// GL state can't be updated right now.
// `createResource` will run when the context is restored.
return;
}
this._processTexture();
},
/**
* Set all parameters of this WebGLTexture per the stored values.
*
* @function Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#_processTexture
* @protected
* @since 3.90.0
* @ignore
*/
_processTexture: function ()
{
var gl = this.gl;
gl.activeTexture(gl.TEXTURE0);
var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter);
@ -193014,11 +193045,7 @@ var WebGLTextureWrapper = new Class({
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma);
if (this.flipY)
{
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
}
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this.flipY);
var pixels = this.pixels;
var mipLevel = this.mipLevel;
@ -193048,6 +193075,8 @@ var WebGLTextureWrapper = new Class({
else if (pixels instanceof Uint8Array)
{
gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, pixels);
generateMipmap = IsSizePowerOfTwo(width, height);
}
else
{
@ -193067,90 +193096,14 @@ var WebGLTextureWrapper = new Class({
gl.generateMipmap(gl.TEXTURE_2D);
}
// Set Spector metadata.
// eslint-disable-next-line camelcase
texture.__SPECTOR_Metadata = this.__SPECTOR_Metadata;
// Restore previous texture bind.
if (currentTexture)
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
}
// Assign the texture to our wrapper.
this.webGLTexture = texture;
},
/**
* Updates the WebGLTexture from an updated source.
*
* This should only be used when the source is a Canvas or Video element.
*
* @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#update
* @since 3.80.0
*
* @param {HTMLCanvasElement|HTMLVideoElement} source - The source to update the WebGLTexture with.
* @param {number} width - The new width of the WebGLTexture.
* @param {number} height - The new height of the WebGLTexture.
* @param {boolean} flipY - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`?
* @param {number} wrapS - The new wrapping mode for the WebGLTexture.
* @param {number} wrapT - The new wrapping mode for the WebGLTexture.
* @param {number} minFilter - The new minification filter for the WebGLTexture.
* @param {number} magFilter - The new magnification filter for the WebGLTexture.
*/
update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter)
else
{
if (width === 0 || height === 0)
{
return;
}
// Assume that the source might change.
this.pixels = source;
this.width = width;
this.height = height;
this.flipY = flipY;
this.wrapS = wrapS;
this.wrapT = wrapT;
this.minFilter = minFilter;
this.magFilter = magFilter;
var gl = this.gl;
if (gl.isContextLost())
{
// GL state can't be updated right now.
// `createResource` will run when the context is restored.
return;
}
gl.activeTexture(gl.TEXTURE0);
var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this.wrapS);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
// Should we generate mipmaps?
var pixels = this.pixels;
if (IsSizePowerOfTwo(width, height) && !pixels.compressed && !(pixels instanceof Uint8Array))
{
gl.generateMipmap(gl.TEXTURE_2D);
}
// Restore previous texture bind.
if (currentTexture)
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
gl.bindTexture(gl.TEXTURE_2D, null);
}
},
@ -211854,7 +211807,6 @@ var DynamicTexture = new Class({
source.isGLTexture = true;
source.glTexture = renderTarget.texture;
source.glTexture.flipY = true;
return this;
},
@ -216624,7 +216576,10 @@ var TextureSource = new Class({
{
if (value === undefined) { value = true; }
if (value === this.flipY) { return this; }
this.flipY = value;
this.update();
return this;
},

File diff suppressed because one or more lines are too long

393
dist/phaser.esm.js vendored
View file

@ -15679,7 +15679,7 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
VERSION: '3.80.0',
VERSION: '3.80.1',
BlendModes: __webpack_require__(10312),
@ -57408,17 +57408,15 @@ var Utils = __webpack_require__(70554);
/**
* @classdesc
* A 2D point light.
* A 2D Light.
*
* These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
* These are created by the {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
*
* Any Game Objects using the Light2D pipeline will then be affected by these Lights as long as they have a normal map.
*
* They can also simply be used to represent a point light for your own purposes.
*
* As of Phaser 3.60 this Game Object now has the Transform and Origin components. However, changing the scale,
* rotation or origin properties will not make any difference to the Light. They are simply present to allow you
* to add this Light to a Container, or enable it for Physics.
* Lights cannot be added to Containers. They are designed to exist in the root of a Scene.
*
* @class Light
* @extends Phaser.Geom.Circle
@ -57428,7 +57426,6 @@ var Utils = __webpack_require__(70554);
*
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {number} x - The horizontal position of the light.
@ -57446,7 +57443,6 @@ var Light = new Class({
Mixins: [
Components.Origin,
Components.ScrollFactor,
Components.Transform,
Components.Visible
],
@ -72742,7 +72738,7 @@ var Shader = new Class({
/**
* A reference to the Phaser.Textures.Texture that has been stored in the Texture Manager for this Shader.
*
* This property is only set if you have called `Shader.setRenderToTexture`, otherwise it is `null`.
* This property is only set if you have called `Shader.setRenderToTexture` with a key, otherwise it is `null`.
*
* @name Phaser.GameObjects.Shader#texture
* @type {Phaser.Textures.Texture}
@ -72832,8 +72828,6 @@ var Shader = new Class({
this.glTexture = renderer.createTextureFromSource(null, width, height, 0);
this.glTexture.flipY = flipY;
this.framebuffer = renderer.createFramebuffer(width, height, this.glTexture, false);
this._rendererWidth = width;
@ -73322,17 +73316,13 @@ var Shader = new Class({
return;
}
var gl = this.gl;
gl.activeTexture(gl.TEXTURE0 + this._textureCount);
gl.bindTexture(gl.TEXTURE_2D, uniform.value.webGLTexture);
// Extended texture data
var data = uniform.textureData;
if (data && !uniform.value.isRenderTexture)
{
var gl = this.gl;
var wrapper = uniform.value;
// https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D
@ -73346,6 +73336,10 @@ var Shader = new Class({
var wrapS = gl[GetFastValue(data, 'wrapS', 'repeat').toUpperCase()];
var wrapT = gl[GetFastValue(data, 'wrapT', 'repeat').toUpperCase()];
var format = gl[GetFastValue(data, 'format', 'rgba').toUpperCase()];
var flipY = GetFastValue(data, 'flipY', false);
var width = GetFastValue(data, 'width', wrapper.width);
var height = GetFastValue(data, 'height', wrapper.height);
var source = GetFastValue(data, 'source', wrapper.pixels);
if (data.repeat)
{
@ -73353,38 +73347,13 @@ var Shader = new Class({
wrapT = gl.REPEAT;
}
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, !!data.flipY);
if (data.width)
{
var width = GetFastValue(data, 'width', 512);
var height = GetFastValue(data, 'height', 2);
var border = GetFastValue(data, 'border', 0);
// texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels)
gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null);
wrapper.width = width;
wrapper.height = height;
}
else
{
// texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, ImageData? pixels)
gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, uniform.source);
// If the uniform has resolution, use a blank texture.
source = null;
}
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);
// Update texture wrapper.
wrapper.magFilter = magFilter;
wrapper.minFilter = minFilter;
wrapper.wrapS = wrapS;
wrapper.wrapT = wrapT;
wrapper.format = format;
wrapper.flipY = !!data.flipY;
wrapper.pixels = uniform.source;
wrapper.update(source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format);
}
this.renderer.setProgram(this.program);
@ -116487,6 +116456,11 @@ var MouseManager = new Class({
this.onMouseDownWindow = function (event)
{
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents)
{
return;
}
if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas)
{
// Only process the event if the target isn't the canvas
@ -116509,6 +116483,11 @@ var MouseManager = new Class({
this.onMouseUpWindow = function (event)
{
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents)
{
return;
}
if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas)
{
// Only process the event if the target isn't the canvas
@ -116982,11 +116961,6 @@ var TouchManager = new Class({
{
// Only process the event if the target isn't the canvas
manager.onTouchEnd(event);
if (_this.capture && event.cancelable)
{
event.preventDefault();
}
}
};
@ -179140,6 +179114,9 @@ var WebGLRenderer = new Class({
gl.disable(gl.DEPTH_TEST);
gl.enable(gl.CULL_FACE);
// Re-enable compressed texture formats.
_this.compression = _this.getCompressedTextures();
// Restore wrapped GL objects.
// Order matters, as some wrappers depend on others.
var wrapperCreateResource = function (wrapper)
@ -181271,13 +181248,37 @@ var WebGLRenderer = new Class({
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
if (!dstTexture)
{
return this.createCanvasTexture(srcCanvas, noRepeat, flipY);
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcCanvas, width, height, true, false, flipY);
}
else
{
return this.updateCanvasTexture(srcCanvas, dstTexture, flipY, noRepeat);
dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter, dstTexture.format);
return dstTexture;
}
},
@ -181298,29 +181299,7 @@ var WebGLRenderer = new Class({
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcCanvas, width, height, true, false, flipY);
return this.canvasToTexture(srcCanvas, null, noRepeat, flipY);
},
/**
@ -181341,46 +181320,25 @@ var WebGLRenderer = new Class({
if (flipY === undefined) { flipY = false; }
if (noRepeat === undefined) { noRepeat = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter);
return dstTexture;
return this.canvasToTexture(srcCanvas, dstTexture, noRepeat, flipY);
},
/**
* Creates a new WebGL Texture based on the given HTML Video Element.
* Creates or updates a WebGL Texture based on the given HTML Video Element.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#createVideoTexture
* @since 3.20.0
* If the `dstTexture` parameter is given, the WebGL Texture is updated, rather than created fresh.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#videoToTexture
* @since 3.90.0
*
* @param {HTMLVideoElement} srcVideo - The Video to create the WebGL Texture from
* @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [dstTexture] - The destination WebGLTextureWrapper to set.
* @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`?
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`?
*
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper.
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created, or updated, WebGLTextureWrapper.
*/
createVideoTexture: function (srcVideo, noRepeat, flipY)
videoToTexture: function (srcVideo, dstTexture, noRepeat, flipY)
{
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
@ -181407,7 +181365,36 @@ var WebGLRenderer = new Class({
magFilter = gl.LINEAR;
}
if (!dstTexture)
{
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcVideo, width, height, true, true, flipY);
}
else
{
dstTexture.update(srcVideo, width, height, flipY, wrapping, wrapping, minFilter, magFilter, dstTexture.format);
return dstTexture;
}
},
/**
* Creates a new WebGL Texture based on the given HTML Video Element.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#createVideoTexture
* @since 3.20.0
*
* @param {HTMLVideoElement} srcVideo - The Video to create the WebGL Texture from
* @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`?
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`?
*
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper.
*/
createVideoTexture: function (srcVideo, noRepeat, flipY)
{
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
return this.videoToTexture(srcVideo, null, noRepeat, flipY);
},
/**
@ -181428,31 +181415,7 @@ var WebGLRenderer = new Class({
if (flipY === undefined) { flipY = false; }
if (noRepeat === undefined) { noRepeat = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcVideo.videoWidth;
var height = srcVideo.videoHeight;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
dstTexture.update(srcVideo, width, height, flipY, wrapping, wrapping, minFilter, magFilter);
return dstTexture;
return this.videoToTexture(srcVideo, dstTexture, noRepeat, flipY);
},
/**
@ -184125,7 +184088,7 @@ var LightPipeline = new Class({
if (!gameObject)
{
return this.renderer.normalMap;
return this.renderer.normalTexture;
}
else if (gameObject.displayTexture)
{
@ -184149,7 +184112,7 @@ var LightPipeline = new Class({
if (!normalMap)
{
return this.renderer.normalMap;
return this.renderer.normalTexture;
}
return normalMap.glTexture;
@ -184790,9 +184753,7 @@ var MultiPipeline = new Class({
flipX = -1;
}
// Auto-invert the flipY if this is coming from a GL RenderTexture
if (gameObject.flipY || (frame.source.isGLTexture && frame.source.isRenderTexture && !texture.flipY))
if (gameObject.flipY)
{
if (!customPivot)
{
@ -192452,11 +192413,81 @@ var WebGLTextureWrapper = new Class({
var texture = gl.createTexture();
// Set Spector metadata.
// eslint-disable-next-line camelcase
texture.__SPECTOR_Metadata = this.__SPECTOR_Metadata;
// Assign the texture to our wrapper.
this.webGLTexture = texture;
this._processTexture();
},
/**
* Updates the WebGLTexture from an updated source.
*
* This should only be used when the source is a Canvas or Video element.
*
* @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#update
* @since 3.80.0
*
* @param {?object} source - The source to update the WebGLTexture with.
* @param {number} width - The new width of the WebGLTexture.
* @param {number} height - The new height of the WebGLTexture.
* @param {boolean} flipY - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`?
* @param {number} wrapS - The new wrapping mode for the WebGLTexture.
* @param {number} wrapT - The new wrapping mode for the WebGLTexture.
* @param {number} minFilter - The new minification filter for the WebGLTexture.
* @param {number} magFilter - The new magnification filter for the WebGLTexture.
* @param {number} format - The new format for the WebGLTexture.
*/
update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format)
{
if (width === 0 || height === 0)
{
return;
}
// Assume that the source might change.
this.pixels = source;
this.width = width;
this.height = height;
this.flipY = flipY;
this.wrapS = wrapS;
this.wrapT = wrapT;
this.minFilter = minFilter;
this.magFilter = magFilter;
this.format = format;
var gl = this.gl;
if (gl.isContextLost())
{
// GL state can't be updated right now.
// `createResource` will run when the context is restored.
return;
}
this._processTexture();
},
/**
* Set all parameters of this WebGLTexture per the stored values.
*
* @function Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#_processTexture
* @protected
* @since 3.90.0
* @ignore
*/
_processTexture: function ()
{
var gl = this.gl;
gl.activeTexture(gl.TEXTURE0);
var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter);
@ -192464,11 +192495,7 @@ var WebGLTextureWrapper = new Class({
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma);
if (this.flipY)
{
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
}
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this.flipY);
var pixels = this.pixels;
var mipLevel = this.mipLevel;
@ -192498,6 +192525,8 @@ var WebGLTextureWrapper = new Class({
else if (pixels instanceof Uint8Array)
{
gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, pixels);
generateMipmap = IsSizePowerOfTwo(width, height);
}
else
{
@ -192517,90 +192546,14 @@ var WebGLTextureWrapper = new Class({
gl.generateMipmap(gl.TEXTURE_2D);
}
// Set Spector metadata.
// eslint-disable-next-line camelcase
texture.__SPECTOR_Metadata = this.__SPECTOR_Metadata;
// Restore previous texture bind.
if (currentTexture)
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
}
// Assign the texture to our wrapper.
this.webGLTexture = texture;
},
/**
* Updates the WebGLTexture from an updated source.
*
* This should only be used when the source is a Canvas or Video element.
*
* @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#update
* @since 3.80.0
*
* @param {HTMLCanvasElement|HTMLVideoElement} source - The source to update the WebGLTexture with.
* @param {number} width - The new width of the WebGLTexture.
* @param {number} height - The new height of the WebGLTexture.
* @param {boolean} flipY - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`?
* @param {number} wrapS - The new wrapping mode for the WebGLTexture.
* @param {number} wrapT - The new wrapping mode for the WebGLTexture.
* @param {number} minFilter - The new minification filter for the WebGLTexture.
* @param {number} magFilter - The new magnification filter for the WebGLTexture.
*/
update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter)
else
{
if (width === 0 || height === 0)
{
return;
}
// Assume that the source might change.
this.pixels = source;
this.width = width;
this.height = height;
this.flipY = flipY;
this.wrapS = wrapS;
this.wrapT = wrapT;
this.minFilter = minFilter;
this.magFilter = magFilter;
var gl = this.gl;
if (gl.isContextLost())
{
// GL state can't be updated right now.
// `createResource` will run when the context is restored.
return;
}
gl.activeTexture(gl.TEXTURE0);
var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this.wrapS);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
// Should we generate mipmaps?
var pixels = this.pixels;
if (IsSizePowerOfTwo(width, height) && !pixels.compressed && !(pixels instanceof Uint8Array))
{
gl.generateMipmap(gl.TEXTURE_2D);
}
// Restore previous texture bind.
if (currentTexture)
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
gl.bindTexture(gl.TEXTURE_2D, null);
}
},
@ -211304,7 +211257,6 @@ var DynamicTexture = new Class({
source.isGLTexture = true;
source.glTexture = renderTarget.texture;
source.glTexture.flipY = true;
return this;
},
@ -216074,7 +216026,10 @@ var TextureSource = new Class({
{
if (value === undefined) { value = true; }
if (value === this.flipY) { return this; }
this.flipY = value;
this.update();
return this;
},

File diff suppressed because one or more lines are too long

393
dist/phaser.js vendored
View file

@ -15691,7 +15691,7 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
VERSION: '3.80.0',
VERSION: '3.80.1',
BlendModes: __webpack_require__(10312),
@ -57420,17 +57420,15 @@ var Utils = __webpack_require__(70554);
/**
* @classdesc
* A 2D point light.
* A 2D Light.
*
* These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
* These are created by the {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`.
*
* Any Game Objects using the Light2D pipeline will then be affected by these Lights as long as they have a normal map.
*
* They can also simply be used to represent a point light for your own purposes.
*
* As of Phaser 3.60 this Game Object now has the Transform and Origin components. However, changing the scale,
* rotation or origin properties will not make any difference to the Light. They are simply present to allow you
* to add this Light to a Container, or enable it for Physics.
* Lights cannot be added to Containers. They are designed to exist in the root of a Scene.
*
* @class Light
* @extends Phaser.Geom.Circle
@ -57440,7 +57438,6 @@ var Utils = __webpack_require__(70554);
*
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {number} x - The horizontal position of the light.
@ -57458,7 +57455,6 @@ var Light = new Class({
Mixins: [
Components.Origin,
Components.ScrollFactor,
Components.Transform,
Components.Visible
],
@ -72754,7 +72750,7 @@ var Shader = new Class({
/**
* A reference to the Phaser.Textures.Texture that has been stored in the Texture Manager for this Shader.
*
* This property is only set if you have called `Shader.setRenderToTexture`, otherwise it is `null`.
* This property is only set if you have called `Shader.setRenderToTexture` with a key, otherwise it is `null`.
*
* @name Phaser.GameObjects.Shader#texture
* @type {Phaser.Textures.Texture}
@ -72844,8 +72840,6 @@ var Shader = new Class({
this.glTexture = renderer.createTextureFromSource(null, width, height, 0);
this.glTexture.flipY = flipY;
this.framebuffer = renderer.createFramebuffer(width, height, this.glTexture, false);
this._rendererWidth = width;
@ -73334,17 +73328,13 @@ var Shader = new Class({
return;
}
var gl = this.gl;
gl.activeTexture(gl.TEXTURE0 + this._textureCount);
gl.bindTexture(gl.TEXTURE_2D, uniform.value.webGLTexture);
// Extended texture data
var data = uniform.textureData;
if (data && !uniform.value.isRenderTexture)
{
var gl = this.gl;
var wrapper = uniform.value;
// https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D
@ -73358,6 +73348,10 @@ var Shader = new Class({
var wrapS = gl[GetFastValue(data, 'wrapS', 'repeat').toUpperCase()];
var wrapT = gl[GetFastValue(data, 'wrapT', 'repeat').toUpperCase()];
var format = gl[GetFastValue(data, 'format', 'rgba').toUpperCase()];
var flipY = GetFastValue(data, 'flipY', false);
var width = GetFastValue(data, 'width', wrapper.width);
var height = GetFastValue(data, 'height', wrapper.height);
var source = GetFastValue(data, 'source', wrapper.pixels);
if (data.repeat)
{
@ -73365,38 +73359,13 @@ var Shader = new Class({
wrapT = gl.REPEAT;
}
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, !!data.flipY);
if (data.width)
{
var width = GetFastValue(data, 'width', 512);
var height = GetFastValue(data, 'height', 2);
var border = GetFastValue(data, 'border', 0);
// texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView? pixels)
gl.texImage2D(gl.TEXTURE_2D, 0, format, width, height, border, format, gl.UNSIGNED_BYTE, null);
wrapper.width = width;
wrapper.height = height;
}
else
{
// texImage2D(GLenum target, GLint level, GLenum internalformat, GLenum format, GLenum type, ImageData? pixels)
gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, uniform.source);
// If the uniform has resolution, use a blank texture.
source = null;
}
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);
// Update texture wrapper.
wrapper.magFilter = magFilter;
wrapper.minFilter = minFilter;
wrapper.wrapS = wrapS;
wrapper.wrapT = wrapT;
wrapper.format = format;
wrapper.flipY = !!data.flipY;
wrapper.pixels = uniform.source;
wrapper.update(source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format);
}
this.renderer.setProgram(this.program);
@ -116500,6 +116469,11 @@ var MouseManager = new Class({
this.onMouseDownWindow = function (event)
{
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents)
{
return;
}
if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas)
{
// Only process the event if the target isn't the canvas
@ -116522,6 +116496,11 @@ var MouseManager = new Class({
this.onMouseUpWindow = function (event)
{
if (event.sourceCapabilities && event.sourceCapabilities.firesTouchEvents)
{
return;
}
if (!event.defaultPrevented && _this.enabled && manager && manager.enabled && event.target !== canvas)
{
// Only process the event if the target isn't the canvas
@ -116995,11 +116974,6 @@ var TouchManager = new Class({
{
// Only process the event if the target isn't the canvas
manager.onTouchEnd(event);
if (_this.capture && event.cancelable)
{
event.preventDefault();
}
}
};
@ -179248,6 +179222,9 @@ var WebGLRenderer = new Class({
gl.disable(gl.DEPTH_TEST);
gl.enable(gl.CULL_FACE);
// Re-enable compressed texture formats.
_this.compression = _this.getCompressedTextures();
// Restore wrapped GL objects.
// Order matters, as some wrappers depend on others.
var wrapperCreateResource = function (wrapper)
@ -181379,13 +181356,37 @@ var WebGLRenderer = new Class({
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
if (!dstTexture)
{
return this.createCanvasTexture(srcCanvas, noRepeat, flipY);
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcCanvas, width, height, true, false, flipY);
}
else
{
return this.updateCanvasTexture(srcCanvas, dstTexture, flipY, noRepeat);
dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter, dstTexture.format);
return dstTexture;
}
},
@ -181406,29 +181407,7 @@ var WebGLRenderer = new Class({
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcCanvas, width, height, true, false, flipY);
return this.canvasToTexture(srcCanvas, null, noRepeat, flipY);
},
/**
@ -181449,46 +181428,25 @@ var WebGLRenderer = new Class({
if (flipY === undefined) { flipY = false; }
if (noRepeat === undefined) { noRepeat = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcCanvas.width;
var height = srcCanvas.height;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
dstTexture.update(srcCanvas, width, height, flipY, wrapping, wrapping, minFilter, magFilter);
return dstTexture;
return this.canvasToTexture(srcCanvas, dstTexture, noRepeat, flipY);
},
/**
* Creates a new WebGL Texture based on the given HTML Video Element.
* Creates or updates a WebGL Texture based on the given HTML Video Element.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#createVideoTexture
* @since 3.20.0
* If the `dstTexture` parameter is given, the WebGL Texture is updated, rather than created fresh.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#videoToTexture
* @since 3.90.0
*
* @param {HTMLVideoElement} srcVideo - The Video to create the WebGL Texture from
* @param {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} [dstTexture] - The destination WebGLTextureWrapper to set.
* @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`?
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`?
*
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper.
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created, or updated, WebGLTextureWrapper.
*/
createVideoTexture: function (srcVideo, noRepeat, flipY)
videoToTexture: function (srcVideo, dstTexture, noRepeat, flipY)
{
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
@ -181515,7 +181473,36 @@ var WebGLRenderer = new Class({
magFilter = gl.LINEAR;
}
if (!dstTexture)
{
return this.createTexture2D(0, minFilter, magFilter, wrapping, wrapping, gl.RGBA, srcVideo, width, height, true, true, flipY);
}
else
{
dstTexture.update(srcVideo, width, height, flipY, wrapping, wrapping, minFilter, magFilter, dstTexture.format);
return dstTexture;
}
},
/**
* Creates a new WebGL Texture based on the given HTML Video Element.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#createVideoTexture
* @since 3.20.0
*
* @param {HTMLVideoElement} srcVideo - The Video to create the WebGL Texture from
* @param {boolean} [noRepeat=false] - Should this canvas be allowed to set `REPEAT`?
* @param {boolean} [flipY=false] - Should the WebGL Texture set `UNPACK_MULTIPLY_FLIP_Y`?
*
* @return {Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper} The newly created WebGLTextureWrapper.
*/
createVideoTexture: function (srcVideo, noRepeat, flipY)
{
if (noRepeat === undefined) { noRepeat = false; }
if (flipY === undefined) { flipY = false; }
return this.videoToTexture(srcVideo, null, noRepeat, flipY);
},
/**
@ -181536,31 +181523,7 @@ var WebGLRenderer = new Class({
if (flipY === undefined) { flipY = false; }
if (noRepeat === undefined) { noRepeat = false; }
var gl = this.gl;
var minFilter = gl.NEAREST;
var magFilter = gl.NEAREST;
var width = srcVideo.videoWidth;
var height = srcVideo.videoHeight;
var wrapping = gl.CLAMP_TO_EDGE;
var pow = IsSizePowerOfTwo(width, height);
if (!noRepeat && pow)
{
wrapping = gl.REPEAT;
}
if (this.config.antialias)
{
minFilter = (pow && this.mipmapFilter) ? this.mipmapFilter : gl.LINEAR;
magFilter = gl.LINEAR;
}
dstTexture.update(srcVideo, width, height, flipY, wrapping, wrapping, minFilter, magFilter);
return dstTexture;
return this.videoToTexture(srcVideo, dstTexture, noRepeat, flipY);
},
/**
@ -184233,7 +184196,7 @@ var LightPipeline = new Class({
if (!gameObject)
{
return this.renderer.normalMap;
return this.renderer.normalTexture;
}
else if (gameObject.displayTexture)
{
@ -184257,7 +184220,7 @@ var LightPipeline = new Class({
if (!normalMap)
{
return this.renderer.normalMap;
return this.renderer.normalTexture;
}
return normalMap.glTexture;
@ -184898,9 +184861,7 @@ var MultiPipeline = new Class({
flipX = -1;
}
// Auto-invert the flipY if this is coming from a GL RenderTexture
if (gameObject.flipY || (frame.source.isGLTexture && frame.source.isRenderTexture && !texture.flipY))
if (gameObject.flipY)
{
if (!customPivot)
{
@ -192560,11 +192521,81 @@ var WebGLTextureWrapper = new Class({
var texture = gl.createTexture();
// Set Spector metadata.
// eslint-disable-next-line camelcase
texture.__SPECTOR_Metadata = this.__SPECTOR_Metadata;
// Assign the texture to our wrapper.
this.webGLTexture = texture;
this._processTexture();
},
/**
* Updates the WebGLTexture from an updated source.
*
* This should only be used when the source is a Canvas or Video element.
*
* @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#update
* @since 3.80.0
*
* @param {?object} source - The source to update the WebGLTexture with.
* @param {number} width - The new width of the WebGLTexture.
* @param {number} height - The new height of the WebGLTexture.
* @param {boolean} flipY - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`?
* @param {number} wrapS - The new wrapping mode for the WebGLTexture.
* @param {number} wrapT - The new wrapping mode for the WebGLTexture.
* @param {number} minFilter - The new minification filter for the WebGLTexture.
* @param {number} magFilter - The new magnification filter for the WebGLTexture.
* @param {number} format - The new format for the WebGLTexture.
*/
update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter, format)
{
if (width === 0 || height === 0)
{
return;
}
// Assume that the source might change.
this.pixels = source;
this.width = width;
this.height = height;
this.flipY = flipY;
this.wrapS = wrapS;
this.wrapT = wrapT;
this.minFilter = minFilter;
this.magFilter = magFilter;
this.format = format;
var gl = this.gl;
if (gl.isContextLost())
{
// GL state can't be updated right now.
// `createResource` will run when the context is restored.
return;
}
this._processTexture();
},
/**
* Set all parameters of this WebGLTexture per the stored values.
*
* @function Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#_processTexture
* @protected
* @since 3.90.0
* @ignore
*/
_processTexture: function ()
{
var gl = this.gl;
gl.activeTexture(gl.TEXTURE0);
var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter);
@ -192572,11 +192603,7 @@ var WebGLTextureWrapper = new Class({
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma);
if (this.flipY)
{
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
}
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this.flipY);
var pixels = this.pixels;
var mipLevel = this.mipLevel;
@ -192606,6 +192633,8 @@ var WebGLTextureWrapper = new Class({
else if (pixels instanceof Uint8Array)
{
gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, pixels);
generateMipmap = IsSizePowerOfTwo(width, height);
}
else
{
@ -192625,90 +192654,14 @@ var WebGLTextureWrapper = new Class({
gl.generateMipmap(gl.TEXTURE_2D);
}
// Set Spector metadata.
// eslint-disable-next-line camelcase
texture.__SPECTOR_Metadata = this.__SPECTOR_Metadata;
// Restore previous texture bind.
if (currentTexture)
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
}
// Assign the texture to our wrapper.
this.webGLTexture = texture;
},
/**
* Updates the WebGLTexture from an updated source.
*
* This should only be used when the source is a Canvas or Video element.
*
* @method Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper#update
* @since 3.80.0
*
* @param {HTMLCanvasElement|HTMLVideoElement} source - The source to update the WebGLTexture with.
* @param {number} width - The new width of the WebGLTexture.
* @param {number} height - The new height of the WebGLTexture.
* @param {boolean} flipY - Should the WebGLTexture set `UNPACK_MULTIPLY_FLIP_Y`?
* @param {number} wrapS - The new wrapping mode for the WebGLTexture.
* @param {number} wrapT - The new wrapping mode for the WebGLTexture.
* @param {number} minFilter - The new minification filter for the WebGLTexture.
* @param {number} magFilter - The new magnification filter for the WebGLTexture.
*/
update: function (source, width, height, flipY, wrapS, wrapT, minFilter, magFilter)
else
{
if (width === 0 || height === 0)
{
return;
}
// Assume that the source might change.
this.pixels = source;
this.width = width;
this.height = height;
this.flipY = flipY;
this.wrapS = wrapS;
this.wrapT = wrapT;
this.minFilter = minFilter;
this.magFilter = magFilter;
var gl = this.gl;
if (gl.isContextLost())
{
// GL state can't be updated right now.
// `createResource` will run when the context is restored.
return;
}
gl.activeTexture(gl.TEXTURE0);
var currentTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
gl.bindTexture(gl.TEXTURE_2D, this.webGLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, this.wrapS);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, this.wrapT);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.pma);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
// Should we generate mipmaps?
var pixels = this.pixels;
if (IsSizePowerOfTwo(width, height) && !pixels.compressed && !(pixels instanceof Uint8Array))
{
gl.generateMipmap(gl.TEXTURE_2D);
}
// Restore previous texture bind.
if (currentTexture)
{
gl.bindTexture(gl.TEXTURE_2D, currentTexture);
gl.bindTexture(gl.TEXTURE_2D, null);
}
},
@ -211412,7 +211365,6 @@ var DynamicTexture = new Class({
source.isGLTexture = true;
source.glTexture = renderTarget.texture;
source.glTexture.flipY = true;
return this;
},
@ -216182,7 +216134,10 @@ var TextureSource = new Class({
{
if (value === undefined) { value = true; }
if (value === this.flipY) { return this; }
this.flipY = value;
this.update();
return this;
},

2
dist/phaser.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,6BAA6B;AAC7B,qCAAkC;AAElC,SAAgB,OAAO,CAAC,IAAS,EAAE,IAAS;IACxC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACtC,sBAAsB;IACtB,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,yBAAyB;IACzB,IAAI,CAAC,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACjD,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IAEhC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QAClC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAClC;IAED,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEhD,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC,CAAC;IAElE,IAAI,GAAG,GAAG,IAAI,eAAM,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAE1C,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC,CAAC;AACtE,CAAC;AAvBD,0BAuBC;AAAA,CAAC"}
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,6BAA6B;AAC7B,qCAAkC;AAElC,SAAgB,OAAO,CAAC,IAAS,EAAE,IAAS;IACxC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACtC,sBAAsB;IACtB,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,yBAAyB;IACzB,IAAI,CAAC,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACjD,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IAEhC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QACnC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEhD,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC,CAAC;IAElE,IAAI,GAAG,GAAG,IAAI,eAAM,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAE1C,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC,CAAC;AACtE,CAAC;AAvBD,0BAuBC;AAAA,CAAC"}

33006
types/phaser.d.ts vendored

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long