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

Abierto
#7,413 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
46/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
JavaScript
Estrellas
40.7k
Forks
7.2k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de phaserjs/phaser

Todos los issues de phaserjs/phaser

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.