Pose (Cocos Creator)

Updated: 03/14/2023

Summary

Pose is a function that manages the display state of a group of parts described in the Pose configuration format .pose3.json.
Using Pose, you can manage parts that you do not want displayed on the screen at the same time, such as “arms in a lowered position” and “arms in a crossed position.”
Pose can also be used to support models with different Part IDs (e.g., costume changes).

The .pose3.json can be configured in Cubism Viewer for OW.
Click here for more information on how to set up parts.

When comparing a model imported using the OW method with a model imported using the conventional method, the following three points change depending on Pose.

  • CubismPosePart is attached to the GameObject under [Prefab root]/Parts/.
  • If the curve of PartOpacity in the AnimationClip matches Stepped, it is processed into a Linear curve.
  • Opacity curves not described in pose3.json are removed from AnimationClip.

Pose performs the following processes.

  1. Process the Opacity curve of the Parts set in Stepped in the Pose motion
  2. Identify parts for Pose
  3. Save Opacity of the part to determine which Pose part to display
  4. Calculate and apply Poses
  5. Interlock Opacity

Process the Opacity curve of the Parts set in Stepped in the Pose motion

As described in the Pose Settings section of the Editor manual, the curve for PartOpacity handled by Pose assumes that the curve type is Stepped.
The Cubism SDK for Cocos Creator processes this curve to linear and exports it to AnimationClip.

If you set a curve of a type other than Stepped, the curve will not be processed and will be exported directly to AnimationClip.

if (
  shouldImportAsOriginalWorkflow &&
  poseJson ! = null &&
  poseJson.adeInTime ! = 0.0
) {
  let track = CubismMotion3Json.convertSteppedCurveToLinerCurver(
    curve,
    poseJson.fadeInTime
  );
}

The processing of this Opacity curve is done by CubismMotion3Json.toAnimationClipB().

Identify parts for Pose

CubismPosePart is attached when a model is imported using the OW method.
The Node to be attached will be the one with the same name as the ID described in .pose3.json, placed under [Prefab root]/Parts/.

// Obtain parts for Pose
const part = ArrayExtensionMethods.findByIdFromParts(
  parts,
  group[partIndex].id
);

// Attach CubismPosePart
posePart = part.node.addComponent(CubismPosePart)!;

// Set Pose information to CubismPosePart
posePart.groupIndex = groupIndex;
posePart.partIndex = partIndex;
posePart.link = group[partIndex].link;

Save Opacity of the part to determine which Pose part to display

The current CubismPart.opacity value is compared with the value cached in the previous frame to determine the parts displayed in the group described in .pose3.json.
Values are cached by CubismPoseController.savePartOpacities().

Calculate and apply Poses

Display parts are applied by AnimationClip.

Apply hidden parts with CubismPoseController.doFade().

The Opacity of the hidden part reduces the opacity to a level that does not allow the background to show through in relation to the opacity of the part to be displayed.
CubismPoseController.doFade() looks for a display part and then sets Opacity, the hidden part.

Interlock Opacity

Opacity is set in CubismPoseController.copyPartOpacities for interlocking parts written in CubismPosePart.link after Pose is applied.

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