Skip to content

Commit

Permalink
Fix camera flickering when "pixel rounding" is enabled (#5907)
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H authored Nov 16, 2023
1 parent c2dfe57 commit 425a0e9
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions GDJS/Runtime/pixi-renderers/layer-pixi-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,32 @@ namespace gdjs {
// onScreenPosition = floor(980.75 - 200)
// onScreenPosition = floor(780.75)
// onScreenPosition = 780
this._pixiContainer.position.x = Math.ceil(
this._pixiContainer.position.x
);
this._pixiContainer.position.y = Math.ceil(
this._pixiContainer.position.y
);

if (
this._layer
.getRuntimeScene()
.getGame()
.getRenderer()
.getPIXIRenderer() instanceof PIXI.Renderer
) {
// TODO Revert from `round` to `ceil` when the issue is fixed in Pixi.
// Since the upgrade to Pixi 7, sprites are rounded with `round`
// instead of `floor`.
// https://github.com/pixijs/pixijs/issues/9868
this._pixiContainer.position.x = Math.round(
this._pixiContainer.position.x
);
this._pixiContainer.position.y = Math.round(
this._pixiContainer.position.y
);
} else {
this._pixiContainer.position.x = Math.ceil(
this._pixiContainer.position.x
);
this._pixiContainer.position.y = Math.ceil(
this._pixiContainer.position.y
);
}
}

if (this._threeCamera) {
Expand Down

0 comments on commit 425a0e9

Please sign in to comment.