Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three JS exporter exports "active" keyframes for all frames #6751

Closed
beiller opened this issue Jun 29, 2015 · 12 comments
Closed

Three JS exporter exports "active" keyframes for all frames #6751

beiller opened this issue Jun 29, 2015 · 12 comments

Comments

@beiller
Copy link

beiller commented Jun 29, 2015

Hello,

I tried testing every combination of setting with the new THREE js blender exporter (r71 and dev branch)

The exporter exports all animations fine with the correct number of frames per "action", but the keyframe data for all animations written to the json is the keyframe data for the current "active" animation in the action editor (truncating the frames if the animation is shorter, etc).

I reverted to r68 exporter and the .js file exports the animation data properly.

@beiller
Copy link
Author

beiller commented Jun 30, 2015

I will add something that may or may not be relevant. When I export, I selected the mesh in blender in object mode before exporting. With the older exporter, I exported after selecting the armature in object mode. Could that matter? What is the correct option?

Tested in blender 2.71 and 2.74

Exported with r71 - https://github.com/beiller/gameplatform/blob/master/gizmo_thunder_ffmodel_upload.json

Exported with r68 - https://github.com/beiller/gameplatform/blob/master/gizmo_thunder_ffmodel_upload.js

Code that imports the mesh:
https://github.com/beiller/gameplatform/blob/master/game.js#L100

Code that updates animation frames:
https://github.com/beiller/gameplatform/blob/master/main.js#L74

@titansoftime
Copy link
Contributor

Try setting armature to "rest" mode and also selecting "rest" on the skeletal animation option in export ui.

This works for me.

@beiller
Copy link
Author

beiller commented Jun 30, 2015

I tried that and it worked for me as well... :) Now I think this issue may have turned into another already existing issue.

Thanks @titansoftime

@beiller
Copy link
Author

beiller commented Jun 30, 2015

I guess its still an issue. When exporting in POSE - POSE mode it exports the same keyframes for the active actions for all the actions.

@titansoftime
Copy link
Contributor

Yea, that's why I never do that.

@beiller
Copy link
Author

beiller commented Jul 3, 2015

Great for you. I read the source code of three js and the plugin, because there was no documentation, and I could not figure this out. What is the point of the POSE selection at all then, or any other combination of those settings.

Maybe we can set the armature to REST position and get rid of this selector in the export options? I know that someone had difficulty accomplishing this task. Would the following solution work?

http://blender.stackexchange.com/questions/26395/python-exporter-set-armature-to-rest-pose-while-exporting-meshes

@repsac
Copy link
Contributor

repsac commented Jul 3, 2015

Maybe we can set the armature to REST position and get rid of this selector in the export options?

Because we haven't been able to get one type of animation export to work with everyone.
#5887

Animation exports were changed somewhere around r68.
#5582 (comment)

While this "fixed" animation exports for some, but broke for others. This is why during the refactor we implemented the toggle. We tried to update the armature based on the exporter settings in this function
https://github.com/mrdoob/three.js/blob/master/utils/exporters/blender/addons/io_three/exporter/api/mesh.py#L41

Currently that logic is commented out. This is because it does not work in batch mode like it does when the gui is open.

There has been talk about setting a rigging/animation standard. But the work I did had nothing to do with rigging or animation (and I haven't rigged in over 10 years and when I did it was in Maya).

I am on a doctor ordered restriction in keyboard use because of bad RSI in all my finger joints so my computer time is extremely limited over the next few months. If you understand how Blender handles animation data but don't understand the add-on's logic just ask.

Basic overview of the add-on hierarchy down to where animation data is parsed.
blender_export

Rough documentation on why it is broken down like this (as opposed to one huge pita monolithic module)
https://dl.dropboxusercontent.com/u/2907790/Blender_Export.pdf

@beiller
Copy link
Author

beiller commented Jul 7, 2015

Appreciate the info repsac! When I encountered my issue I started to wade through the blender exporter source code to see if I could fix the issue. I did not spend a lot of time, however I can definitely take another look as I have done lots of blender python scripting before.

What is the animation / rigging standard you speak of? Are you suggesting a standard rig for THREE? I would advise against this for sure. :)

I saw how one of the _rest_bones and _pose_bones function are dynamically passed in as a variable. It was a bit confusing to read FYI. I'll take a look at the code when I have some time.

I also think many problems are cropping up because there is no guidelines for usage. In blender - do we use armature modifier, or do we parent the mesh to the armature object in armature mode, or parent the mesh in object mode with an armature modifier, or without the modifiers, and other options. Do we select the mesh, select the armature when exporting?

There are many possible combinations as you can see and involves a lot of trial and error to get it working.

Cheers!

@repsac
Copy link
Contributor

repsac commented Jul 13, 2015

What is the animation / rigging standard you speak of? Are you suggesting a standard rig for THREE? I would advise against this for sure.

Correct. There should be a convention so the code knows what to expect so that predictable results can be had. I don't think a strict one is needed, but many people I have encountered rigged their assets based some random tutorial they found in google searches.

I saw how one of the _rest_bones and _pose_bones function are dynamically passed in as a variable. It was a bit confusing to read FYI. I'll take a look at the code when I have some time.

Just ask whenever, I can point you in the right direction.

In blender - do we use armature modifier, or do we parent the mesh to the armature object in armature mode, or parent the mesh in object mode with an armature modifier, or without the modifiers, and other options.

Good question. It sounds like users have multiple ways of shooting themselves in the foot with rigs. Different approaches can be the result of specific needs but I have encountered people rarely know the exact approach and just do with what ever seems to work (a word I will use loosely).

Do we select the mesh, select the armature when exporting?

Select the object. I never got around to inserting

if user has armature selected:
    assume its the first mesh object in the children array
    and that there isn't more than one

@please-wait
Copy link
Contributor

Here is how I dealt with the problem. I don't have the python skills to modify the exporter, but I hope it helps in recognizing the problem. Today I spent 6 hours on it (then I realized I had already spent the same amount of time a week ago and simply forgot how I solved this. So if the following doesn't help any one, consider it as a note-to-self):

I make an action, which contains one frame, keyframed as same as the rest mode and export it with "pose" selected in exporter's settings. If don't do that, the pose is applied to the posed form of the first frame. So it doubles the armature influence.
Then I change the active action to each of the other animations, export individually, and replace them in the original file. btw, I couldn't get rest mode to work so that's why I used pose...

many people I have encountered rigged their assets based some random tutorial they found in google searches

True, my model was from makehuman. That's why I think the rigging should have been pretty standard.

But I must say, the exporter does an amazing job in understanding all the influences. I even keyframed a value in an armature constraint and it wasn't a problem, like, wow!

@manthrax
Copy link
Contributor

There is a possible workaround / fix for this issue in #6050

@Mugen87
Copy link
Collaborator

Mugen87 commented May 31, 2018

The JSON Blender exporter has been removed with R93 (#14117).

Also see: https://threejs.org/docs/#manual/introduction/Loading-3D-models

@Mugen87 Mugen87 closed this as completed May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants