Callback for end of motion playback (Web)

[Last updated : 01/30/2020]

 

Summary

Cubism SDK for Web now supports callback events at the end of motion playback.

In the sample, the callback function outputs log text to notify the end of playback.

 

Callback implementation

This time, because it processes by callback at the end of motion playback,
we have implemented callbacks in Framework/src/motion/acubismmotion, an abstract class that manages motion.

Tips

Please note that in the sample, callbacks cannot be invoked in the following conditions.

  • When the motion being played is set as “looping”
  • When null is registered in the callback

 

Using Callback Functions

Implement what you actually want to be processed in the callback function.

The sample implements the use of LAppPal.printMessage() to output log text notifying the end of motion playback.
To change the processing at the end of motion playback, change the implementation of the following function.

 

 

The callback function is registered when CubismUserModel.loadMotion() is used in the Framework layer to load motion data, and the callback function is passed at the same time the motion is generated.
When there is already a motion, setFinishedMotionHandler() introduced in “Callback Implementation” is used.

In the sample, the callback function is passed from startRandomMotion(), which is called when OnTap() is executed to obtain the tap event.

 

Since CubismMotion.doUpdateParameters() is actually playing back the motion, the implementation is made so that the callback function can be passed to CubismMotion.

 

 

On the development of implementation

The sample implements only the end of motion playback, but by developing these implementations, asynchronous processing can be used in callback functions after motion playback is finished, or
by reverse engineering the function from the actual process to which the callback is to be applied, callbacks can be implemented at points other than the end of motion playback.

© 2010 - 2022 Live2D Inc.