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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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);
}
// 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); }
// 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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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;
}
}
...
// 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; } } ...
// 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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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;
}
}
...
// 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; } } ...
// 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 when shouldCheckMotionConsistency is true.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Cubism SDK for Unity
public AnimationClip ToAnimationClip(AnimationClip animationClip, bool shouldImportAsOriginalWorkflow = false, bool shouldClearAnimationCurves = false
, bool isCallFormModelJson = false, CubismPose3Json poseJson = null)
{
...
if (shouldCheckMotionConsistency)
{
var consistency = cubismMotion3Json.HasConsistency();
if (!consistency)
{
return null;
}
}
...
// Cubism SDK for Unity public AnimationClip ToAnimationClip(AnimationClip animationClip, bool shouldImportAsOriginalWorkflow = false, bool shouldClearAnimationCurves = false , bool isCallFormModelJson = false, CubismPose3Json poseJson = null) { ... if (shouldCheckMotionConsistency) { var consistency = cubismMotion3Json.HasConsistency(); if (!consistency) { return null; } } ...
// Cubism SDK for Unity
public AnimationClip ToAnimationClip(AnimationClip animationClip, bool shouldImportAsOriginalWorkflow = false, bool shouldClearAnimationCurves = false
                                                                , bool isCallFormModelJson = false, CubismPose3Json poseJson = null)
{
    ...
    if (shouldCheckMotionConsistency)
    {
        var consistency = cubismMotion3Json.HasConsistency();
        if (!consistency)
        {
            return null;
        }
    }

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