From ff0d7d094fc726c4f4ed9fdcfb82d2d016748574 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 23 Jul 2026 23:46:45 +0300 Subject: [PATCH] feat: vca keyframes support --- res/modules/animation.lua | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 0c6d6f3bf..93e7a13e1 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -167,6 +167,12 @@ local action_to_channel = { rotate = CH_ROTATE } +local curve_to_interp = { + const = INT_CONST, + linear = INT_LINEAR, + bezier = INT_BEZIER, +} + function this.parse_track(root) local linesets = {} for i, node in ipairs(root) do @@ -182,14 +188,29 @@ function this.parse_track(root) linesets[bone] = lineset end - local line + local line = { + axis = ("xyz"):find(node.by), + channel = action_to_channel[tag] + } if node.func then - line = { - axis = ("xyz"):find(node.by), - channel = action_to_channel[tag], - expression = node.func, - } - elseif #node > 0 then + line.expression = node.func + elseif node.curve then + line.interp = curve_to_interp[node.curve] + line.keys = {} + for j, key_node in ipairs(node) do + local keyframe = { + frame = tonumber(key_node.frame), + value = tonumber(key_node.value), + } + if line.interp == INT_BEZIER then + keyframe.lx = tonumber(key_node.lx) + keyframe.ly = tonumber(key_node.ly) + keyframe.rx = tonumber(key_node.rx) + keyframe.ry = tonumber(key_node.ry) + end + table.insert(line.keys, keyframe) + end + else error("not implemented") end