two.js
two.js copied to clipboard
In ZUI, surfaceToClient calculation does not take translateSurface into account.
Describe the bug surfaceToClient of ZUI does not get affected by prior translateSurface (aka. panning)
To Reproduce Steps to reproduce the behavior:
- Go to https://codepen.io/jonobr1/pen/PobMKwb
- Write
console.log(JSON.stringify(zui.surfaceToClient({x:10, y:10})))on line 62 (belowzui.translateSurface(dx, dy);) - Pan the surface with mouse
- Observe surfaceToClient calculation of x:10, y:10 is not affected by translateSurface on the new x, y coordinates on console
- 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):
- [X] 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)
Thanks for posting. This fixes that issue: https://github.com/jonobr1/two.js/pull/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 })));
omg, how did I not try that. Thanks. :)