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

Remove setRotationCenter API #581

Merged

Conversation

adroitwhiz
Copy link
Contributor

@adroitwhiz adroitwhiz commented Apr 2, 2020

Resolves

A step on the long-ish path towards fixing #550
Also a step towards fixing #570

Proposed Changes

This PR removes the API for setting a drawable's rotation center and the Skin.setRotationCenter function.

It does not remove the API for setting a skin's rotation center when setting its contents.

To fix unit tests which previously called Skin.setRotationCenter, it also adds a rotationCenter setter (plus corresponding getter) to MockSkin, which the unit tests now use.

I'm not expecting this to be merged right away--in case scratchfoundation/scratch-vm#2314 causes any regressions in the near future, it'll probably be beneficial to be able to revert that without having to re-add the rotation center API here as well.

Reason for Changes

In order to fix (no, GitHub, it doesn't close) #550, vector costumes' SVG viewboxes must depend on their rotation centers. Every time the viewbox of an SVG is set, its <img> must be updated as well, which is a fundamentally asynchronous operation.

As such, a synchronous API for setting a skin's rotation center after the skin is loaded is incompatible with the changes necessary for #550.

With scratchfoundation/scratch-vm#2314 merged, that synchronous API is no longer used and can be removed.

const changed = (
toFloat32(x) !== this._rotationCenter[0] ||
toFloat32(y) !== this._rotationCenter[1]);
if (!emptySkin && changed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1444,9 +1418,6 @@ class RenderWebGL extends EventEmitter {
if ('skinId' in properties) {
this.updateDrawableSkinId(drawableID, properties.skinId);
}
if ('rotationCenter' in properties) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to document the properties, but not necessarily in this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess if this function is going away it doesn't matter

Copy link
Contributor

@fsih fsih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@apple502j
Copy link

FYI test is falling because playwright only supports node 10+ but it's still node 8

@adroitwhiz adroitwhiz merged commit fcdcffe into scratchfoundation:develop Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants