TilemapGPULayer is drawn at twice its x/y (position applied twice)
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 80/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
調査の方向性
src/renderer/webgl/renderNodes/submitter/SubmitterTilemapGPULayer.js を開いて run を読む: スプライト行列は applyITRS を介してレイヤーの位置を適用し、次に calcMatrix.setQuad(x, y, x + width, y + height, quad) がそれを2度目に平行移動する。Canvas/WebGL の TilemapLayer パスと比較して、原点は行列からのみ来るべきであることを確認し、次に quad が 0,0 から始まるように変更する。issue 内のデモで検証する。そこでは (100,160) の GPU レイヤーが非 GPU レイヤーとまったく同じように白いマーカーの上に位置するはずである。スケーリングと、原点がゼロでない tilemap も確認する。
索引モデルが issue の本文から書いたものです。
説明
Version
- Phaser Version: 4.2.1 (also on
mastertoday) - Operating system: Linux
- Browser: Chrome 149 (WebGL 2 via ANGLE)
Description
A TilemapGPULayer placed anywhere but 0,0 is drawn in the wrong place: its x/y are applied twice. Unscaled, a layer created at (100, 160) is drawn at (200, 320); with a scale it lands at x + scaleX * x, e.g. a layer at (300, 120) with scale 0.25 is drawn at (375, 150).
In SubmitterTilemapGPULayer.run (src/renderer/webgl/renderNodes/submitter/SubmitterTilemapGPULayer.js), the sprite matrix already translates by the layer's position:
spriteMatrix.applyITRS(x, y, 0, tilemapLayer.scaleX, tilemapLayer.scaleY);
calcMatrix.multiply(spriteMatrix);
and then the quad is built from the position again:
calcMatrix.setQuad(x, y, x + width, y + height, quad);
Expected: a TilemapGPULayer at (x, y) is drawn where a TilemapLayer at (x, y) is.
Actual: it's drawn at (x + scaleX·x, y + scaleY·y).
Fix (tested against the example below with a patched dist/phaser.js; the layer then lands on its marker):
calcMatrix.setQuad(0, 0, width, height, quad);
Example Test Code
A plain two-tile tileset (no margin or spacing). The white squares mark where each layer's top-left should be. The TilemapLayer (top) sits on its marker; the TilemapGPULayer (created at 100,160) is drawn at 200,320.
<!doctype html>
<html><body style="margin:0">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script>
<script>
class Demo extends Phaser.Scene {
create() {
const tex = this.textures.createCanvas('tiles', 64, 32);
const ctx = tex.getContext();
ctx.fillStyle = '#e33'; ctx.fillRect(0, 0, 32, 32);
ctx.fillStyle = '#36f'; ctx.fillRect(32, 0, 32, 32);
tex.refresh();
const data = [[0, 1, 0, 1]];
for (const [gpu, x, y] of [[false, 100, 60], [true, 100, 160]]) {
const map = this.make.tilemap({ data, tileWidth: 32, tileHeight: 32 });
map.createLayer(0, map.addTilesetImage('tiles'), x, y, gpu);
this.add.rectangle(x, y, 8, 8, 0xffffff);
}
}
}
new Phaser.Game({ type: Phaser.WEBGL, width: 600, height: 400, backgroundColor: '#222', scene: Demo });
</script>
</body></html>
Additional Information
Workaround: keep TilemapGPULayers at 0,0 (scaling about the origin is then fine).
- 主要言語
- JavaScript
- スター
- 40.7k
- フォーク
- 7.2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
phaserjs/phaser のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 3 日以内に返信
-
Type definition for TilemapLayer.getTileAt is wrong対応中かも @hkbughk が 34 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 3 日以内に返信
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)対応中かも @k1epg01ng129-eng が 32 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 3 日以内に返信
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGL対応中かも @SamuelMalmfors が 14 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
phaserjs/phaser#7392 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
flipY renders tile incorrectly対応中かも @vtxe02023274 が 26 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 3 日以内に返信
phaserjs/phaser の issue をすべて見る
似ている issue
-
Out of order / duplicate key error shows the key bytes as decimal or UTF-8, not hex対応中かも @bardrop が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
-
`remix-hook-form/middleware` imports `unstable_createContext`, breaking on `react-router` >= 7.9.0オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
code-forge-io/remix-hook-form#189 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
webtorrent/webtorrent#3131 ·