scratchfoundation / scratch-render

WebGL-based rendering engine for Scratch 3.0
BSD 3-Clause "New" or "Revised" License
260 stars 332 forks source link

Drawable's rotation is not 0 when the drawable is not rotated #688

Open fsih opened 4 years ago

fsih commented 4 years ago

Expected Behavior

The drawable's rotation should be 0 by default

Actual Behavior

The stage, shouldn't be able to be moved, scaled, or rotated in any way. Its matrix should be the identity, and hence its inverse matrix should be the identity. However, you can see here that some of the entries that are supposed to be 0 are as large as -.002, which is a pretty high error.

Screen Shot 2020-08-13 at 00 31 13

Here's another time where I ran it on the same machine, but the results were different 🤔

Screen Shot 2020-08-27 at 16 41 24

The result of this is that calculations are slightly wrong. For instance, here, the localPosition[0] calculation should come out to 0, but it's negative, which caused the touching white issue here: https://github.com/LLK/scratch-render/pull/676#issuecomment-673036391

Screen Shot 2020-08-13 at 00 29 05

Having a 1e-6 error margin is kind of large and feels rather hacky at https://github.com/LLK/scratch-render/pull/686/commits/ffa53a66df60c025a22a5f0dc73329587c08135f, so ideally we would fix the underlying math

Steps to Reproduce

Check drawable._inverseMatrix on the stage and see that it's not the identity

Operating System and Browser

any

BryceLTaylor commented 3 years ago

@fsih What is the user facing problem with this?