`Controller.paddingOverride` default prevents Glow filter from calculating framebuffer padding

オープン
#7,242 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
javascript
領域
game-dev

調査の方向性

src/filters/Controller.js の paddingOverride の初期化から始め、src/filters/Glow.js の Glow.getPadding() と比較してください。透明なスプライトを使った最小再現で、デフォルトでは Glow のパディングが距離から計算される一方、setPaddingOverride() によって明示的な上書きも引き続き可能であることを確認してください。Glow がスプライトの端からはみ出してもクリップされなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

Version

  • Phaser Version: 4.0.0 RC6
  • Operating system: Linux
  • Browser: Chrome 133

Description

The Controller base class initializes paddingOverride to new Rectangle() (Controller.js:67), which is a zero-valued but truthy object.

The Glow filter overrides getPadding() and checks if (this.paddingOverride) before falling through to its own distance-based padding calculation (Glow.js:218). Since paddingOverride is always truthy, the Glow's distance * scale calculation never executes, and the framebuffer gets zero extra padding.

Expected: Glow extends beyond the sprite outline by distance pixels, following the alpha edges of the opaque pixels.

Actual: Glow is confined within the sprite's rectangular bounds and abruptly cuts off at the frame edges. The effect looks like a square gradient that stops at the sprite frame boundary.

Example Test Code

// Minimal reproduction
const config = {
    type: Phaser.AUTO,
    width: 400,
    height: 300,
    backgroundColor: '#2d2d2d',
    scene: {
        preload: function () {
            // Use any sprite with transparency (non-rectangular shape)
            this.load.image('star', 'https://labs.phaser.io/assets/sprites/star.png');
        },
        create: function () {
            const sprite = this.add.sprite(200, 150, 'star');
            sprite.enableFilters();
            const glow = sprite.filters.internal.addGlow(0xffff00, 4, 0, 1, false, 10, 16);

            // BUG: glow is clipped to sprite's rectangular bounds
            // WORKAROUND: uncomment the next line to fix it
            // glow.setPaddingOverride(null);
        }
    }
};

new Phaser.Game(config);

Additional Information

Root cause: Controller.js:67 sets this.paddingOverride = new Rectangle(). This zero-valued Rectangle is always truthy, so when Glow.getPadding() checks if (this.paddingOverride), it always takes the override path and returns zero padding instead of calculating distance * scale.

Workaround:

glow.setPaddingOverride(null);

Suggested fix: In Controller.js:67, change:

this.paddingOverride = new Rectangle();

to:

this.paddingOverride = null;

This lets filters with custom getPadding() implementations (Glow, Blur) fall through to their own padding logic by default. setPaddingOverride() can still be called explicitly when an override is desired.

This likely affects any filter that overrides getPadding() with a truthy check on paddingOverride.

主要言語
JavaScript
スター
40.7k
フォーク
7.2k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

phaserjs/phaser のほかの issue

phaserjs/phaser の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。