Merge pull request #2449 from apple502j/patch-13

fix: wrapClamp direction during deserialization
This commit is contained in:
Christopher Willis-Ford 2023-10-17 13:01:20 -07:00 committed by GitHub
commit 2ae67598ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

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

View file

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