TilemapGPULayer is drawn at twice its x/y (position applied twice)
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 80/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
Direzione di ricerca
Apri src/renderer/webgl/renderNodes/submitter/SubmitterTilemapGPULayer.js e leggi run: la matrice dello sprite applica la posizione del layer tramite applyITRS, poi calcMatrix.setQuad(x, y, x + width, y + height, quad) la trasla una seconda volta. Confronta con il percorso TilemapLayer di Canvas/WebGL per confermare che l'origine dovrebbe provenire solo dalla matrice, poi cambia il quad in modo che inizi a 0,0. Verifica con la demo nell'issue, dove il layer GPU a (100,160) dovrebbe trovarsi sul suo marker bianco esattamente come il layer non GPU; controlla anche lo scaling e una tilemap con origine diversa da zero.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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).
- Lingua principale
- JavaScript
- Stelle
- 40.7k
- Fork
- 7.2k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di phaserjs/phaser
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
I maintainer di solito rispondono entro 3 giorni
-
Type definition for TilemapLayer.getTileAt is wrongForse già presa @hkbughk l’ha presa 34 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 3 giorni
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)Forse già presa @k1epg01ng129-eng l’ha presa 32 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 3 giorni
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGLForse già presa @SamuelMalmfors l’ha presa 14 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
phaserjs/phaser#7392 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
flipY renders tile incorrectlyForse già presa @vtxe02023274 l’ha presa 26 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di phaserjs/phaser
Issue simili
-
enhancement ready
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
DCGM/semant-demo#708 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
agents area: runtime automation chore cli consistency dependencies developer-experience difficulty: easy documentation enhancement good first issue help wanted hygiene json-output priority: P3 starters tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the moduleForse già presa @MalithaPrabhashana l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
jaseci-labs/jac#10756 ·
I maintainer di solito rispondono entro 1 giorno