CraftStudio API

CraftStudio API

12M Downloads

KeyFrame transformations becoming corrupted

TangoTek opened this issue ยท 0 comments

commented

Current Behavior

This occurs in all of the getNextXXX() or getPreviousXXX() functions inside ClientChannel.
getPreviousRotationKeyFrameForBox, getNextRotationKeyFrameForBox, etc

It seems "fake" KeyFrames are being cloned (possibly with negative positions) so that interpolation remains consistent. However, cloning a full keyframe which might contain multiple types of transformations (ie: rotation and translation) is incorrect since only the desired transformation type should be copied.

The "this.keyFrames.put" lines are potentially causing multiple issues.

  1. There might already be a keyframe at the new index being inserted that contains transformation data other than the type being searched for. This will cause all existing keyframe data in that index to be lost.
  2. Cloning a full KeyFrame structure is incorrect since it might contain transformations other than the type being searched for.

Possible Solution

Don't clone the entire KeyFrame with potentially all 4 types of transformations. Instead create a new KeyFrame and only copy over the relevant translation, rotation, offset, or stretch data.

Also, be careful not to stomp existing KeyFrame data in the keyFrames map by using a put() on an index that already exists. This can happen in the existing code which causes data to be lost.