playcanvas / playcanvas/engine

Camera worldToScreen wrong results with fixed resolution

Open
#5,274 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: graphics
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

This came up in a client's project, when using a fixed resolution in the project settings the camera world to screen method returns a wrong position.

The issue seems to be because it's using the device.clientRect instead of the device width and height.

Here is a sample project that reproduces that, together with two temp workarounds:

https://playcanvas.com/editor/scene/1728110

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the camera worldToScreen implementation and compare its use of device.clientRect with the device width and height. Reproduce the issue using the linked sample project with a fixed resolution, then verify that the returned screen position is correct under that setting.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.