stop_all() function JS?
26 January 2017 23:47
27 January 2017 10:39
What is the javascript code behind the Stop All animations button in the Scene Viewer and how do I implement it as a function in my web viewer app?Hello!
You can find Scene Viewer source code in the SDK folder apps_dev/viewer/.
The function you are looking for is anim_stop_all_clicked in the viewer.js file
27 January 2017 10:59
Hi!
The idea is to filter all objects and call the stop method if the object can be animated.
You can also make a cache for the animated objects, retaining them after the scene is loaded (for example in the loaded_callback) and iterating through that cache, if you'll need to optimize the iteration.
The idea is to filter all objects and call the stop method if the object can be animated.
function stop_all() {
var scene_objs = m_scenes.get_all_objects();
for (var i = 0; i < scene_objs.length; i++) {
if (m_anim.is_animated(scene_objs[i]))
m_anim.stop(scene_objs[i]);
}
}
You can also make a cache for the animated objects, retaining them after the scene is loaded (for example in the loaded_callback) and iterating through that cache, if you'll need to optimize the iteration.