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

Đang mở
#7,413 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
46/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
frontend, game-dev

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
JavaScript
Star
40.7k
Fork
7.2k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của phaserjs/phaser

Tất cả issue của phaserjs/phaser

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.