Jump to content

Mesh animation starting position at last frame after loading


FunFetched
 Share

Recommended Posts

I have a Blender file with some meshes with Actions assigned to them. I'm exporting it using version 5.3.-1 of the Babylon.JS exporter and loading the resulting .babylon file with Scene.ImportMesh. There are no bones in this scene; all animations are applied directly to meshes.

I can trigger my animations without issue; everything behaves as expected (more or less). However, after loading the file, the orientation and positions of all of my animated meshes begin at the final frame of their Actions, as opposed to frame 0, as I would expect.

My first thought was that the animations were playing automatically upon loading. I scoured the forums here and discovered the autoAnimate flag. I opened my .babylon file, but no such flag was present. I re-exported and checked autoAnimate intentionally, opened the .babylon file again, and explicitly set each autoAnimate flag to false. No effect. Next, I set breakpoints at all relevant beginAnimation functions in my babylon.js, but none were triggered.

As far as I can tell, none of these animations are being automatically played, yet the problem persists. Any thoughts? I can work around this issue by making sure that the keyframes at the first and final frames of my Actions are exactly the same (and simply not play that final frame), but it seems there might be a bug in play here.

Link to comment
Share on other sites

Hi and welcome, funfetched!  I was hoping you would have some replies by now.  hmm.

I have never done animations inside Blender... but... allow me to ask this.  At the time of export, are the animations "sitting" on their last frame?  In other words, does it matter if you "rewind" the animations before export?  (I am probably talking crap, here, sorry). 

If there IS animation "scrubbers" (timeline sliders) in Blender, are they all set at frame 0 for all animated mesh... at export-time?

That might be a stupid thing to ask... not sure.  Sorry if it was.  :)

Usually, when things like this happen, we like to see the .blend and .babylon files.  Sometimes things can be seen in those files... that can give us an indicator as-to what is happening.  It sounds like you have already been looking-around in there.  hmm.

Anyway, can you make your .blend and .babylon files available to us, somehow?  That would be great.

I'm going to ping @gryff and @JCPalmer just in case they want to monitor this thread.  Both are quite knowledgeable in Blender->BabylonJS operations.  They both might be a bit busy during the holidays, but they will visit soon.  And there are other export/animation experts nearby.  Let's hope SOMEBODY has seen this "all animated mesh start-at last frame of animation" - puzzler sometime before... and has a fix.  Talk soon.

Link to comment
Share on other sites

One of the first things I tried was to make sure I was exporting the file while everything was sitting at frame 0. :)  It doesn't seem to matter. I'll see what I can do as to providing some files. I can't see anything in my .babylon file referring to anything resembling a starting frame, either. Weird. The only thing I can figure is that there might be a "current frame" counter in Babylon that gets incremented during the parsing of .babylon files, but never gets reset to 0 when its done. I'll do some more digging.

Link to comment
Share on other sites

Alright; fooling around with the final frame, I've discovered that the problem is actually in the exporter. Regardless of what frame I'm on in the Timeline at the time of export, the position and orientation of the meshes are always exported in their final states. I'll take a look at that and see if I can make any sense of it.

Link to comment
Share on other sites

Found it! It is indeed in the exporter, and I've managed to fix it on my end. I've submitted a bug to github (#2416), but figured I'd post it here for @JCPalmer as well.

animation.py line 104: append_range() introduces an issue where the scene's current frame is changed as the range is iterated through, but not restored upon completion. This leads to all animated objects being exported in their final positions/orientations, regardless of the current frame in the Timeline.

I managed to resolve the issue on my end in f_curve_animatable.py. I added currentFrame = bpy.context.scene.frame_current before the for action in bpy.data.actions: loop on line 37, restoring the scene's current frame immediately after this loop with bpy.context.scene.frame_set(currentFrame).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...