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

Translate pointer event coordinates to screen coordinates. #72

Merged
merged 2 commits into from Sep 10, 2018

Conversation

guillerodriguez
Copy link
Contributor

This fixes the case for layers that have transforms applied
(for example, rotations of 90, 180, 270 degrees)

This fixes the case for layers that have transforms applied
(for example, rotations of 90, 180, 270 degrees)
@samskivert
Copy link
Member

This seems weird. Pointer event coordinates are in screen coordinates, and in any case screen coordinates are presumably not what you want here because those reflect the physical orientation of the device, not your pseudo-rotated version.

It may be that the math is accidentally working out, but I think a more correct solution might be to have XYFlicker use the event.local coordinate which are the coordinates of the event translated into the coordinate space of the hit layer (which will account for whatever top-level rotation you have applied).

Can you try just changing:

        dest.set(-event.x(), -event.y());

to

        dest.set(-event.local.x, -event.local.y);

To see if that also fixes the problem? Because I think it should, and it makes more sense as the correct thing to do.

Pointer events are already in screen coordinates, and in any case
screen cordinates are not what we want here. Instead, use the "local"
event coordinates (translated to the hit layer's coordinate space).
@guillerodriguez
Copy link
Contributor Author

You are of course right. The math was working out because "translating the event to screen coordinates" was introducing a 90 deg rotation which "fixed" the behaviour in my use case. Should be fixed now.

(There's no event.local though, I assume you meant Interaction.local instead)

@samskivert samskivert merged commit b254cd2 into threerings:master Sep 10, 2018
@guillerodriguez guillerodriguez deleted the xyflicker_rotation branch September 10, 2018 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants