Skip to content

Commit 38e1ee6

Browse files
committed
🐛 Fix old blueprints losing commands keyframes
1 parent 55566b3 commit 38e1ee6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/formats/blueprint/dfu.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,5 +639,27 @@ function updateModelTo1_8_0(model: any) {
639639
}
640640
}
641641

642+
// Update commands keyframes to use new keyframe channel name
643+
if (Array.isArray(fixed.animations)) {
644+
debugger
645+
for (const animation of fixed.animations) {
646+
for (const animator of Object.values<any>(animation.animators ?? {})) {
647+
if (!Array.isArray(animator.keyframes)) continue
648+
for (const keyframe of animator.keyframes) {
649+
if (keyframe.channel !== 'commands') continue
650+
keyframe.channel = 'function'
651+
if (Array.isArray(keyframe.data_points)) {
652+
for (const dataPoint of keyframe.data_points) {
653+
if (dataPoint.commands) {
654+
dataPoint.function = dataPoint.commands
655+
delete dataPoint.commands
656+
}
657+
}
658+
}
659+
}
660+
}
661+
}
662+
}
663+
642664
return fixed
643665
}

0 commit comments

Comments
 (0)