Verifying the Integrity of .motion3.json

Updated: 05/15/2025

Before loading .motion3.json, the Cubism SDK can verify that the model does not contain incorrect data due to tampering.

If unspecified .motion3.json files are expected to be loaded, it is recommended that the integrity of the .motion3.json files to be loaded be checked before generating instances with CubismMotion.
Note, however, that integrity verification may affect performance.

For model consistency verification, use CubismMotion3Json.HasConsistency() in the Framework with the SDK for Unity and CubismMotionJson::HasConsistency() in the Framework otherwise.

CubismMotion::Parse() in the Cubism SDK for Native verifies the integrity of the .motion3.json file when importing models only when the CSM_DEBUG macro is enabled.

// Cubism SDK for Native
void CubismMotion::Parse(const csmByte* motionJson, const csmSizeInt size)
{
    _motionData = CSM_NEW CubismMotionData;

    CubismMotionJson* json = CSM_NEW CubismMotionJson(motionJson, size);

    if (!json->IsValid())
    {
        CSM_DELETE(json);
        return;
    }

#if CSM_DEBUG
    json->HasConsistency();
#endif
…
    CSM_DELETE(json);
}

CubismMotion.parse() in the Cubism SDK for Web verifies the integrity of the .motion3.json file when importing models only when CubismMotion._debugMode is true.

// Cubism SDK for Web
public parse(motionJson: ArrayBuffer, size: number): void {
    ...

    if (shouldCheckMotionConsistency) {
      const consistency = json.hasConsistency();
      if (!consistency) {
        json.release();
        CubismLogError('Inconsistent motion3.json.');
        return;
      }
    }

    ...

You can change CubismMotion._debugMode with CubismMotion.setDebugMode().

CubismMotion.parse() in the Cubism SDK for Java verifies the integrity of the .motion3.json file when importing models only when CubismFrameworkConfig.CSM_DEBUG is true.

// Cubism SDK for Java
private void parse(byte[] motionJson, boolean shouldCheckMotionConsistency) {
    ...

    if (shouldCheckMotionConsistency) {
        boolean consistency = json.hasConsistency();

        if (!consistency) {
            CubismDebug.cubismLogError("Inconsistent motion3.json.");
            return;
        }
    }

    ...

CubismMotion3Json.ToAnimationClip() in the Cubism SDK for Unity verifies file integrity when importing .motion3.json only in the Unity Editor.

// Cubism SDK for Unity
public AnimationClip ToAnimationClip(AnimationClip animationClip, bool shouldImportAsOriginalWorkflow = false, bool shouldClearAnimationCurves = false
                                                                , bool isCallFormModelJson = false, CubismPose3Json poseJson = null)
{
#if UNITY_EDITOR
    HasConsistency();
#endif

    ...
Was this article helpful?
YesNo
Please let us know what you think about this article.