Reputation: 177
I am working on a project which requires taking fbx models and viewing them in a THREEJS viewer. Most of the time these models come in with the correct pivot points but other times they do not. I am having a hard time figuring out what is causing this issue.
I am using this script to do the conversion from fbx to json:
https://github.com/mrdoob/three.js/blob/master/utils/converters/fbx/convert_to_threejs.py
You can find an example of an fbx file that has the wrong pivot point here:
http://s000.tinyupload.com/index.php?file_id=42525924957536854290
This model contains only one mesh and was exported from Maya with FBX Plugin version 2014.0.1. The pivot should be near the center of the model but it located at the bottom of the model when loaded in threejs. It appears to be placing the pivot at (0,0,0).
I ran a test on this model using the online model viewer at https://clara.io/. When I import the model using the fbx everything looks normal as can be seen here:
Next, I then export this model as THREEJS Scene json by using File -> Export All -> Threejs Scene. When I import the json I just exported via clara.io back into clara.io the pivot is wrong. This is the model after reimporting it as json into clara.io
Any suggestions on how to get the pivot points to always match up between Maya and Threejs would be greatly appreciated.
Upvotes: 2
Views: 1721
Reputation: 934
The issue is that ThreeJS doesn't support Pivots that are different than Transform origin of a model. This is actually somewhat standard for Game Engines.
What I would suggest is to first "Reset Pivots" in Clara.io on this object, and then go into Vertex mode in Clara.io on this object and select all vertices. Move the vertices so that they are relative to the Reset Pivot. This is letting you set any pivot you want because you are moving the vertices relative to the origin of this model. Then when you export, you will have your new pivot.
We can look at adding support for baking pivots. But it is a little complex because there are multiple distinct pivots -- one for scale and a separate one for rotation, so I guess we have to give you the option of which you want to bake into the object.
Best regards, Ben Houston, ben@clara.io
Upvotes: 4