I have imported a glb file with animations in Babylon.js scene . I need to find out how many animations are present in the model and arrange them in a sequence. How can I know this without opening the model in blender or sandbox. Does Babylon give us something like animations and then I can access it as animations[0],animations[1] and so on.
Also I want to know the animationTime so that can move an HTML slider thumb accordingly.
<script>
const canvas = document.getElementById("renderCanvas"); // Get the canvas element
const engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D engine
// Add your code here matching the playground format
var createScene = function() {
var scene = new BABYLON.Scene(engine);
// Add a camera to the scene and attach it to the canvas
const camera = new BABYLON.ArcRotateCamera("camera", -Math.PI / 2, Math.PI / 2.5, 3, new BABYLON.Vector3(0, 0, 0), scene);
camera.attachControl(canvas, true);
// Add a lights to the scene
const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0), scene);
//Your Code
//var model = BABYLON.SceneLoader.ImportMeshAsync("", "Animation/", "Bee.glb", scene);
// Load hero character and play animation
BABYLON.SceneLoader.ImportMesh("", "Animation/", "Bee.glb", scene, function (newMeshes, particleSystems, skeletons, animationGroups) {
var hero = newMeshes[0];
//Scale the model down
hero.scaling.scaleInPlace(0.1);
//Lock camera on the character
camera.target = hero;
});
return scene;
};
const scene = createScene(); //Call the createScene function
// Register a render loop to repeatedly render the scene
engine.runRenderLoop(function () {
scene.render();
});
// Watch for browser/canvas resize events
window.addEventListener("resize", function () {
engine.resize();
});
</script>