Skip to content

Commit

Permalink
Merge pull request #2449 from apple502j/patch-13
Browse files Browse the repository at this point in the history
fix: wrapClamp direction during deserialization
  • Loading branch information
cwillisf authored Oct 17, 2023
2 parents 15cdd2f + bfbea42 commit 2ae6759
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/serialization/sb2.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,9 @@ const parseScratchObject = function (object, runtime, extensions, topLevel, zip,
target.y = object.scratchY;
}
if (object.hasOwnProperty('direction')) {
target.direction = object.direction;
// Sometimes the direction can be outside of the range: LLK/scratch-gui#5806
// wrapClamp it (like we do on RenderedTarget.setDirection)
target.direction = MathUtil.wrapClamp(object.direction, -179, 180);
}
if (object.hasOwnProperty('isDraggable')) {
target.draggable = object.isDraggable;
Expand Down
4 changes: 3 additions & 1 deletion src/serialization/sb3.js
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,9 @@ const parseScratchObject = function (object, runtime, extensions, zip, assets) {
target.y = object.y;
}
if (object.hasOwnProperty('direction')) {
target.direction = object.direction;
// Sometimes the direction can be outside of the range: LLK/scratch-gui#5806
// wrapClamp it (like we do on RenderedTarget.setDirection)
target.direction = MathUtil.wrapClamp(object.direction, -179, 180);
}
if (object.hasOwnProperty('size')) {
target.size = object.size;
Expand Down

0 comments on commit 2ae6759

Please sign in to comment.