Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In ZUI, surfaceToClient calculation does not take translateSurface into account. #659

Open
1 of 3 tasks
alper-batioglu opened this issue Aug 16, 2022 · 2 comments
Open
1 of 3 tasks
Labels

Comments

@alper-batioglu
Copy link
Contributor

alper-batioglu commented Aug 16, 2022

Describe the bug
surfaceToClient of ZUI does not get affected by prior translateSurface (aka. panning)

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codepen.io/jonobr1/pen/PobMKwb
  2. Write console.log(JSON.stringify(zui.surfaceToClient({x:10, y:10}))) on line 62 (below zui.translateSurface(dx, dy);)
  3. Pan the surface with mouse
  4. Observe surfaceToClient calculation of x:10, y:10 is not affected by translateSurface on the new x, y coordinates on console
  5. Also observe how zoom-in and zoom-out by mouse wheel affects surfaceToClient calculation. (zoom-in and then pan the surface)

Expected behavior
surfaceToClient calculation should be affected by translateSurface (aka. panning)

Environment (please select one):

  • Code executes in browser (e.g: using script tag to load library)
  • Packaged software (e.g: ES6 imports, react, angular, vue.js)
  • Running headless (usually Node.js)

Desktop (please complete the following information):

  • OS: Mac Os Monterey 12.4
  • Browser: Microsoft Edge
  • Version: 104.0.1293.54 (Official build) (arm64)
@jonobr1
Copy link
Owner

jonobr1 commented Aug 16, 2022

Thanks for posting. This fixes that issue: #661

If you're using an NPM version of Two.js. An interim fix you can make on your end (until the latest version is published to NPM) is to also pass a z component where z = 1.

E.g: console.log(JSON.stringify(zui.surfaceToClient({ x: 10, y: 10, z: 1 })));

@alper-batioglu
Copy link
Contributor Author

omg, how did I not try that. Thanks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants