WebGLRenderer.addBlendMode() returns the previous blend mode's index (v4)

Aperta
#7,413 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
46/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
frontend, game-dev

Direzione di ricerca

The issue points to WebGLRenderer.addBlendMode() and shows the faulty return expression, but gives no file path or test location. Start by locating that method and the tests for blend mode registration. Confirm the returned index addresses the newly added mode and that setting, updating, and removing it leave the built-in XOR mode unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version

  • Phaser Version: 4.2.1 (also 4.0.0 and master at 02d8931)
  • Operating system: any (WebGL renderer)
  • Browser: any

Description

addBlendMode() returns one less than the index of the blend mode it adds:

var index = this.blendModes.push(WebGLBlendParametersFactory.createCombined(...)) - 1;

return index - 1;

push() - 1 is already the new index, so the first custom mode returns 27 (the built-in XOR slot) instead of 28. v3.90 had push() followed by a single return index - 1, which was correct.

Effects:

  • setBlendMode(index) uses the previous mode, so the custom one never renders.
  • updateBlendMode(index, ...) / removeBlendMode(index) change or remove the built-in XOR mode instead of the new one.

Example Test Code

const r = this.renderer;
const gl = r.gl;
const before = r.blendModes.length;                  // 28
const index = r.addBlendMode([ gl.DST_ALPHA, gl.ZERO ], gl.FUNC_ADD);
console.log(index, before);                          // 27 28, so index points at XOR, not the new mode

Additional Information

The fix is to drop the second - 1. I have it ready with tests and can open a PR if that's welcome.

Lingua principale
JavaScript
Stelle
40.7k
Fork
7.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di phaserjs/phaser

Tutte le issue di phaserjs/phaser

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.