Animation Listening
Animation Playback Listening
let aniTaskListener;
// After initialization, call this method to add the animation listener
function addAnimationListener() {
if (!aniTaskListener) {
aniTaskListener = new SView.Animation.AnimationTaskLinstener();
// Progress bar listener
aniTaskListener.updatePercent = function () {
// Overall animation progress
let entiretyPercent = viewer.getAnimationPlayer().getPercent();
// Current step animation progress
let percent = viewer.getAnimationPlayer().getTaskPercent();
};
aniTaskListener.updateState = function (task, state) {
// Update playback state
};
aniTaskListener.updateActive = function (task) {
// Update the active step
}
viewer.getAnimationPlayer().addTaskListener(aniTaskListener);
}
}
Animation Command Listening
Animation command listening uses the SView message mechanism. Add the following cases in the update method.
case SView.Commands.CommandNames.PLAYANIMATIONCOMMAND:
// Animation play command message
if (msg.state === SView.Commands.PlayAnimationCommand.LoadAnimationDataError) {
// Animation data loading error
} else if (msg.state === SView.CommandMessageState.ExitView) {
// Animation exit
}
break;