Filters on game objects are misplaced when the camera is zoomed and its origin isn't 0.5
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 62/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
Start in src/gameobjects/components/Filters.js at the filter camera setup described in the suggested patch, then trace how the filter camera copies the main camera’s scroll, rotation, and zoom. Reproduce the reported case with zoom 2 and origin (0, 0), including a filtered object and a mask. Done when filtered objects and masks render in the correct position with non-default camera origins and zoom, while the reported working cases still work.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When a camera has a zoom other than 1 and an origin other than the default 0.5 (e.g. setOrigin(0, 0)), game objects with filters render in the wrong place, usually off screen. This applies to internal and external filters, and to masks as well as other filters. Without filters, the same objects render correctly. It also works correctly at zoom 1, or with the default camera origin.
Version
- Phaser Version:
Phaser 4.2.1, WebGL
-
Operating system:
Linux (CachyOS) -
Browser:
Chrome
Description
Example Test Code
class S extends Phaser.Scene {
create() {
const cam = this.cameras.main.setZoom(2).setOrigin(0, 0)
this.input.on('pointerdown', () => this.tweens.add({ targets: cam, zoom: cam.zoom > 1.5 ? 1 : 2, duration: 1000 }))
this.add.rectangle(20, 20, 80, 60, 0x3399ff).setOrigin(0, 0)
const filtered = this.add.rectangle(120, 20, 80, 60, 0x3399ff).setOrigin(0, 0)
filtered.enableFilters().filters.internal.addColorMatrix().colorMatrix.grayscale()
this.add.text(20, 90, 'Click to toggle the zoom', { fontSize: '10px' })
}
}
new Phaser.Game({ type: Phaser.WEBGL, width: 800, height: 400, scene: S })
Additional Information
Suggested patch by claude which fixes it on my side bellow. Not knowledgable enough about Phaser internals to be confident it's the proper fix.
diff --git a/dist/phaser.esm.js b/dist/phaser.esm.js
index 8c6521ac895c8ba041b6990573cdb38e7210fec6..943448f360e4408348a5c243d965b645843cd2fb 100644
--- a/dist/phaser.esm.js
+++ b/dist/phaser.esm.js
@@ -47759,6 +47759,8 @@ if (true)
this.filterCamera.setScroll(posX, posY);
this.filterCamera.setRotation(rotation);
this.filterCamera.setZoom(zoomX, zoomY);
+ this.filterCamera.setOrigin(camera.originX, camera.originY);
return this;
},
diff --git a/dist/phaser.js b/dist/phaser.js
index d5f7d60dd067d6a5b9d1fc2518b216f821f16e0c..0c53f1180482fb08a1e930fe08fc9db5164ef1db 100644
--- a/dist/phaser.js
+++ b/dist/phaser.js
@@ -47771,6 +47771,8 @@ if (true)
this.filterCamera.setScroll(posX, posY);
this.filterCamera.setRotation(rotation);
this.filterCamera.setZoom(zoomX, zoomY);
+ this.filterCamera.setOrigin(camera.originX, camera.originY);
return this;
},
diff --git a/src/gameobjects/components/Filters.js b/src/gameobjects/components/Filters.js
index ba66b79e12b686cdb3d7244dfcd2dd59389c3432..358c408247319d9448d2be243d9f839f951bad8a 100644
--- a/src/gameobjects/components/Filters.js
+++ b/src/gameobjects/components/Filters.js
@@ -549,6 +549,8 @@ if (typeof WEBGL_RENDERER)
this.filterCamera.setScroll(posX, posY);
this.filterCamera.setRotation(rotation);
this.filterCamera.setZoom(zoomX, zoomY);
+ this.filterCamera.setOrigin(camera.originX, camera.originY);
return this;
},
- 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
-
Độ khó 2/5 1-3 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
Tất cả issue của phaserjs/phaser
Issue tương tự
-
enhancement ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
DCGM/semant-demo#708 ·
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 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
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the moduleCó thể đã có người làm @MalithaPrabhashana đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
jaseci-labs/jac#10756 ·
Maintainer thường phản hồi trong vòng 1 ngày