The `allStacksAndOwnersDo` function in Scratch 2.0 runtime iterates
targets in reverse and projects sometimes rely on that for correct
initialization. If, for example, each sprite runs a "go back 999 layers"
or "go to front" block as its first action, the order of execution will
determine the ordering of the layers.
This change makes Scratch 3.0 match the Scratch 2.0 execution order.
The previous configuration mixed Webpack output with static content in
order to create the playground. This change moves that static content
from `/playground/` into `/src/playground/` and adds a Webpack rule to
copy it into the playground as part of the build.
On the surface this might seem unnecessary, but it provides at least two
benefits:
- It's no longer possible to accidentally load stale build output
through `webpack-dev-server` in the event of a misconfiguration. This
was very easy in the previous configuration, and might in fact be the
only way that `webpack-dev-server` ever worked for this repository.
- It's simpler to ensure that various rules apply to the hand-authored
content and not build outputs. This includes lint rules, `.gitignore`,
IDE symbol search paths, etc.
Disable use of more accurate timer temporarilly due to performance.
However, with the rearrange and introduction of the 'nowObj' it turns
out most of the delay is in resolving 'self.performance'... so keeping
this cached in nowObj actually mitigates most of the delay.
Changed mathop to call new math util
Changed sin & cos to round correctly (to get 0)
Added testing for the new math util function
Added testing for the new mathop functions
This saves popping, destroying, recreating, and pushing the stack frame,
and then reassigning the warp mode attribute for every block to block
step in the execution.
Run-time Optimisation
The thread.stackFrames array is accessed all the time to retrieve the
'parent' stack frame. This is done using as index of [this.stack.length
- 1]. However, a lot of the time this evaluated to [-1]. Although this
results in null, which is fine, to get to this javascript actually
defers from a numeric array lookup to an object lookup using the string
"-1". This is roughly 100 times slower to compute and so a simple catch
for negative indexes is well worth the extra check.
When popping down the stack frame it is assumed that you keep using the
previous warp state rather than looking at the warp state of the level
you just popped out to. This causes the loss of screen updates if the
warping block was the last statement in a loop as the loop does not obey
it's 'non warp' status.
Had to update the test scripts to handle the alpha channel, also I note
that all the hex tests are using CSS notation, not scratch notation
(which is 0x not #)