TilemapGPULayer is drawn at twice its x/y (position applied twice)
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 80/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
Hướng nghiên cứu
Mở src/renderer/webgl/renderNodes/submitter/SubmitterTilemapGPULayer.js và đọc run: ma trận sprite áp dụng vị trí của layer thông qua applyITRS, sau đó calcMatrix.setQuad(x, y, x + width, y + height, quad) dịch chuyển nó lần thứ hai. So sánh với đường đi TilemapLayer của Canvas/WebGL để xác nhận rằng gốc tọa độ chỉ nên đến từ ma trận, sau đó đổi quad để bắt đầu tại 0,0. Kiểm tra với demo trong issue, nơi layer GPU tại (100,160) phải nằm trên marker trắng của nó đúng như layer không phải GPU; cũng kiểm tra scaling và một tilemap có gốc khác 0.
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 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).
- 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
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của phaserjs/phaser
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Type definition for TilemapLayer.getTileAt is wrongCó thể đã có người làm @hkbughk đã nhận 34 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)Có thể đã có người làm @k1epg01ng129-eng đã nhận 32 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGLCó thể đã có người làm @SamuelMalmfors đã nhận 14 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
phaserjs/phaser#7392 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
flipY renders tile incorrectlyCó thể đã có người làm @vtxe02023274 đã nhận 26 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của phaserjs/phaser
Issue tương tự
-
Out of order / duplicate key error shows the key bytes as decimal or UTF-8, not hexCó thể đã có người làm @bardrop đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
-
`remix-hook-form/middleware` imports `unstable_createContext`, breaking on `react-router` >= 7.9.0Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
code-forge-io/remix-hook-form#189 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
webtorrent/webtorrent#3131 ·