diff --git a/src/cameras/2d/BaseCamera.js b/src/cameras/2d/BaseCamera.js index d0bbf1ecbb..5158720480 100644 --- a/src/cameras/2d/BaseCamera.js +++ b/src/cameras/2d/BaseCamera.js @@ -517,6 +517,22 @@ var BaseCamera = new Class({ * @since 3.60.0 */ this.isSceneCamera = true; + + /** + * Can this Camera render rounded pixel values? + * + * This property is updated during the `preRender` method and should not be + * set directly. It is set based on the `roundPixels` property of the Camera + * combined with the zoom level. If the zoom is an integer then the WebGL + * Renderer can apply rounding during rendering. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#renderRoundPixels + * @type {boolean} + * @readonly + * @default true + * @since 3.86.0 + */ + this.renderRoundPixels = true; }, /** diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index af31f577e8..bbd38e2e7f 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -501,6 +501,8 @@ var Camera = new Class({ var zoomY = this.zoomY; var matrix = this.matrix; + this.renderRoundPixels = (this.roundPixels && Number.isInteger(zoomX) && Number.isInteger(zoomY)); + var originX = width * this.originX; var originY = height * this.originY; @@ -589,7 +591,8 @@ var Camera = new Class({ Math.floor(this.x + originX + 0.5), Math.floor(this.y + originY + 0.5), this.rotation, - zoomX, zoomY); + zoomX, zoomY + ); matrix.translate(-originX, -originY);