Skip to content

Commit 4315574

Browse files
committed
🏗️ Fixed a few more issues with pre-post keyframes
1 parent c312bc2 commit 4315574

File tree

3 files changed

+109
-542
lines changed

3 files changed

+109
-542
lines changed

src/systems/animationRenderer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export function getFrame(
170170
case 'bone': {
171171
matrix = getNodeMatrix(outlinerNode, node.base_scale)
172172
// Only add the frame if the matrix has changed.
173-
// NOTE - Disabled because it causes issues with vanilla interpolation.
174173
if (lastFrame && lastFrame.matrix.equals(matrix)) continue
175174
// Inherit instant interpolation from parent
176175
if (node.parent && node.parent !== 'root') {
@@ -188,6 +187,11 @@ export function getFrame(
188187
interpolation = 'step'
189188
} else if (prevKeyframe?.data_points.length === 2) {
190189
interpolation = 'pre-post'
190+
updatePreview(animation, time + 0.001)
191+
const postMatrix = getNodeMatrix(outlinerNode, node.base_scale)
192+
console.warn('pre-post', matrix.equals(postMatrix), matrix, postMatrix)
193+
matrix = postMatrix
194+
updatePreview(animation, time)
191195
}
192196

193197
lastFrameCache.set(uuid, { matrix, keyframe })

src/systems/datapackCompiler/animation.mcb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ dir <%export_namespace%> {
393393
<%%
394394
const last = global.lastActiveFrame[node.uuid]
395395
global.isStepInterpolation = !!(last?.interpolation === 'step')
396-
global.lastActiveFrame[node.uuid] = node
396+
global.lastActiveFrame[node.uuid] = global.transform
397397
%%>
398-
IF (node.interpolation === 'pre-post' || global.isStepInterpolation) {
398+
IF (global.transform.interpolation === 'pre-post' || global.isStepInterpolation) {
399399
$data merge entity $(<%node.type + '_' + node.safe_name%>) { \
400400
transformation: <%matrixToNbtFloatArray(global.transform.matrix).toString()%>, \
401401
start_interpolation: -1, \
@@ -703,9 +703,6 @@ dir <%export_namespace%> {
703703
{'export_namespace': '<%export_namespace%>', 'function_path': 'animated_java:<%export_namespace%>/apply_default_pose'}
704704
REPEAT (Object.values(rig.nodes)) as node {
705705
IF (['bone', 'text_display', 'item_display', 'block_display'].includes(node.type)) {
706-
<%%
707-
console.log(node)
708-
%%>
709706
execute on passengers if entity @s[tag=aj.<%export_namespace%>.bone.<%node.safe_name%>] run \
710707
data merge entity @s {transformation: <%matrixToNbtFloatArray(node.default_transform.matrix).toString()%>, start_interpolation: 0}
711708
}

0 commit comments

Comments
 (0)