When I load my .gltf file and import animations, the model automatically starts playing one of the animationGroups (“Walk”), and I can’t get it to stop!
What I’ve tried is to get a reference to the animationGroup (in various ways), then call .stop()
. I can only get it to stop by calling scene.stopAllAnimations()
.
this.canvas = <HTMLCanvasElement> document.getElementById("renderCanvas"); // Get the canvas element
this.engine = new BABYLON.Engine(this.canvas, true); // Generate the BABYLON 3D engine
this.scene = new BABYLON.Scene(this.engine);
this.camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2, new BABYLON.Vector3(0,0,5), this.scene);
this.camera.attachControl(this.canvas, true);
this.light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), this.scene);
this.light2 = new BABYLON.PointLight("light2", new BABYLON.Vector3(0, 1, -1), this.scene);
BABYLON.SceneLoader.Append("./", "BaseCharacter.gltf", this.scene, (scene) => {
BABYLON.SceneLoader.ImportAnimations("./", "BaseCharacter.gltf", this.scene, undefined, undefined, undefined, ()=>{
/* this works
this.scene.stopAllAnimations();
*/
// this doesn't work
let walk = this.scene.getAnimationGroupByName("Walk");
walk.stop();
/* this also doesn't work
let g = this.scene.animationGroups;
g[6].stop(); // used console.log to discover which animationGroup was playing
*/
});
});
this.engine.runRenderLoop(() => {
this.scene.render();
});
I’m probably just not understanding how these controls are supposed to be used, so any insight would be much apprecaited ^_^.