From 1012a2aa61ad8fe455113f0b4688576e4c3eff6c Mon Sep 17 00:00:00 2001 From: apple502j <33279053+apple502j@users.noreply.github.com> Date: Sat, 30 May 2020 21:54:14 +0900 Subject: [PATCH 1/2] wrapClamp direction during sb/sb2 deserialization --- src/serialization/sb2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/serialization/sb2.js b/src/serialization/sb2.js index b3dc19eef..2f7556341 100644 --- a/src/serialization/sb2.js +++ b/src/serialization/sb2.js @@ -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; From bfbea4266a40f67ea5b3e959c7d2bc13fccb4732 Mon Sep 17 00:00:00 2001 From: apple502j <33279053+apple502j@users.noreply.github.com> Date: Sat, 30 May 2020 21:58:14 +0900 Subject: [PATCH 2/2] wrapClamp direction during sb3 deserialization --- src/serialization/sb3.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/serialization/sb3.js b/src/serialization/sb3.js index d49365671..99efd2c0b 100644 --- a/src/serialization/sb3.js +++ b/src/serialization/sb3.js @@ -1043,7 +1043,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;