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] 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;