Fix importing of frames

This commit is contained in:
Skyler Lehmkuhl 2025-01-05 16:52:36 -05:00
parent a731ef12fb
commit 24c89c2915
1 changed files with 13 additions and 2 deletions

View File

@ -2016,6 +2016,9 @@ class Frame {
return newFrame; return newFrame;
} }
static fromJSON(json) { static fromJSON(json) {
if (!json) {
return undefined
}
const frame = new Frame(json.frameType, json.idx); const frame = new Frame(json.frameType, json.idx);
frame.keys = json.keys; frame.keys = json.keys;
for (let i in json.shapes) { for (let i in json.shapes) {
@ -2109,7 +2112,11 @@ class Layer {
layer.frames.push(Frame.fromJSON(frame)); layer.frames.push(Frame.fromJSON(frame));
} }
for (let frame in layer.frames) { for (let frame in layer.frames) {
layer.updateFrameNextAndPrev(frame, layer.frames[frame].frameType); if (layer.frames[frame]) {
if (["motion", "shape"].indexOf(layer.frames[frame].frameType) != -1) {
layer.updateFrameNextAndPrev(frame, layer.frames[frame].frameType);
}
}
} }
layer.visible = json.visible; layer.visible = json.visible;
layer.audible = json.audible; layer.audible = json.audible;
@ -2132,7 +2139,11 @@ class Layer {
} }
json.frames = []; json.frames = [];
for (let frame of this.frames) { for (let frame of this.frames) {
json.frames.push(frame.toJSON(randomizeUuid)); if (frame) {
json.frames.push(frame.toJSON(randomizeUuid));
} else {
json.frames.push(undefined)
}
} }
json.visible = this.visible; json.visible = this.visible;
json.audible = this.audible; json.audible = this.audible;