SView Help Center
English (US)

Animation

Author: sviewngts Last Updated: 2026-10-28 19:39

Interface List

Interface Name Description
Initialize Initialize animation data
Play Play an animation
Pause Pause an animation
Resume Resume playing an animation
Set Progress Set the animation playback progress
Switch Step Switch animation steps
Set Speed Set the animation playback speed
Previous Switch to the previous animation step
Next Switch to the next animation step
Loop Set whether the animation loops
Auto Roam Set whether the animation automatically roams
Exit Animation Exit animation playback
Animation Listening Set animation event listeners

Initializing Animation Data

let animationPlayer = viewer.getAnimationPlayer();
//Animation only needs to be initialized once
animationPlayer.getAnimation().then(() => {
	//After successful parsing, initialize the animation player
	animationPlayer.open();
}).catch(() => {
	//Failed to initialize the animation data
});

Playing an Animation

//The first time an animation is played, it must be called after parsing succeeds and the animation player has been initialized.
animationPlayer.playAll();
animationPlayer.setIsPlaying(true);
//If you want to play from a certain step, call the following method
animationPlayer.play(stepId);
//If you want to play from one step up to another step, call the following method
//The parameters are step indices. For example, to play only the first step, set start to 0 and end to 1.
//If you do not want playback to restart from the beginning after these steps have finished, set it to non-looping playback.
animationPlayer.play(start,end);

Pausing an Animation

animationPlayer.pause();
animationPlayer.setIsPlaying(false);

Resuming an Animation

animationPlayer.resume();
animationPlayer.setIsPlaying(true);

Setting the Animation Progress

//percent is the overall progress, in the range 0-100
animationPlayer.setPercent(percent);
animationPlayer.resume();
animationPlayer.setIsPlaying(true);

Switching Animation Steps

//Directly play the corresponding step
animationPlayer.play(stepId);
animationPlayer.setIsPlaying(true);
//Or use the following method
//First get the list of all animation tasks
let animationProcessList = animationPlayer.getTaskList();
let step;
for(let i=0;i<animationProcessList.length;i++){
	let process = animationProcessList[i];
	let stepList = process.getStepList();
	for(let j=0;j<stepList.length;j++){
		step = stepList[j];
		break;
	}
}
//The parameter is an AnimationStep
animationPlayer.setActiveTask(step);
animationPlayer.play();
animationPlayer.setIsPlaying(true);

Setting the Animation Playback Speed

//Playback speed, of number type, between 0-10 (exclusive)
animationPlayer.setSpeed(speed);

Switching to the Previous Animation Step

//When playing the first step, switching to the previous step has no effect
animationPlayer.playPrevious();

Switching to the Next Animation Step

//When currently playing the last step, switching to the next step will, depending on whether looping playback is enabled, either switch to the first step or have no effect.
animationPlayer.playNext();

Setting Loop Playback

//The parameter isLoop is of boolean type
animationPlayer.setLoop(isLoop);

Setting Automatic Roaming

//The parameter autoWalkCamera is of boolean type
animationPlayer.setAutoWalkCamera(autoWalkCamera);

Exiting the Animation

//Exit all animations
M3D.Animation.SimulationAnimationManager.getInstance().exitAll();
//Reset the animation player
animationPlayer.reset();
//Clear the animation playback listeners; skip this if no cleanup is needed
animationPlayer.clearTaskListeners();
//Set to not playing
animationPlayer.setIsPlaying(false);
//Exit perspective projection
scene.getCurrentViewPort().getCamera().setOrthographic(true);
//Set the current step to -1
M3D.Animation.SimulationAnimationManager.getInstance().getAnimationStepManager()
	.getCurrentProcessManager().curProcessID = -1;
//Execute the reset command
let commandManager = frame.getCommandsManager();
commandManager.execute('restore');