Mesh Disappearing When Dynamically Generated Animation Is Played

I’m developing an AnimationSequencer Class that, once provided with a group of keyframes, is able to dynamically generate an Animation instance for each keyframe group, append these animations to an an AnimationGroup and finally play the animation group on a call to the “playAll()” method. At present, this works without error, however no animation plays and the mesh disappears during the animation. Here is the playground:

Curiously, as noted in the playground, everything works as expected when I attempt the process directly, (i.e non-dynamically and without use of the custom AnimationSequencer class)

@Evgeni_Popov and @sebavan any idea what could be causing the problem, could it be an issue with the AnimationGroup component itself? It seems to be a bit temperamental. I’ve noted that in this scenario, an error is generated if the scene is not explicitly passed to the AnimationGroup constructor, usually this is not necessary.

Just to provide some additional context, it seems to be an internal error. disabling blendingMode on the animation produces the following error. I’ve included the stacks trace and the actual error line itself. Seems like an internal function attempts to set a read only property.

The error only appears to be happening in my custom class which accepts the scene as an argument. I’ve verified that the scene passed in is identical to the scene used in the top-level createScene function. I’ve also tried refactoring the code, but nothing appears to work. As long as the scene/mesh is used in the custom class the Animation doesn’t seem to work, whether I attempt to play in directly via an Animatable instance or add it to an AnimationGroup for play back - it seems as though the Mesh becomes readonly?? Deltakosh, I wondered if there is some limitation on passing scene and mesh objects to classes in this way? It shouldn’t be this difficult to integrate the framework into native JS class primitives.

My experience in logical contemplations makes me think that the problem is in the custom AnimationSequencer class (or how it works in PG) :slight_smile:

@labris Of course, but It’s just a standard JS class. I’ve merely moved the working logic into a few methods for better code structuring and modulation. I’ve included a link to the playground, there is nothing special going on in the class.

1 Like

I would advise to port the PG to Typescript, maybe this will reveal a problem with types or variables not initialized / accessed correctly.

1 Like

I’ve found the source of the error. It was an oversight on my part; where an animation has been declared to update the position attribute then the data type must be also specified as a Vector3:

 let meshPositionAnim = new BABYLON.Animation(

I had been erroneously using BABYLON.Animation.ANIMATIONTYPE_FLOAT before now as I had been animating each axis independently prior, using position.x,position.y and position.z respectively (which are float values), rather than just position.

Many thanks to all those that took a look, I’m completely new to the Babylon platform and thus essentially learning as I go!

1 Like