-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
FBXLoader doesn't support transformed pivot points #11895
Comments
/ping @takahirox |
see #11878 maybe it's not a problem with the exporter, because I have a similar issue with the JSON format |
@roccapl I investigated a bit and yes, transformed pivots are not supported by three.js. However Clara.io is built on three.js and the model loads fine there. The obvious solution (to me) is that when loaders detect a transformed pivot, they create an empty Object3D to represent the pivot and make the mesh a child of that. Then all animations and transforms must be applied to the pivot object instead. I'll look into this tomorrow to get an idea of how complicated it would be to implement. |
Could someone explain to me why this is unsupported and what do people do as a common practice to circumvent this limitation? I've seen plenty of complex skinned animations with complicated bone chains playing back with no problems in three, why is this case different? |
I found a solution! 🍾 🎆 But it seems the GLTF2Loader does support transformed pivots. So the process goes like this:
Forum topic is here: |
What this shows for this issue (and the related #11878 for JSON format issue), is that transformed pivots can be supported. So we need to find out how the GLTF2Loader (or exporter) supports them and see whether that will work of other loaders too. |
That's great news, I'll dig into the code on Thursday and see if I can come up with a patch. In the meantime if GLTF2 is a mature format I can try to use that instead of the JSON one. |
Wouldn't know how to solve it. For your specific model this patch does the trick: diff --git a/examples/js/loaders/FBXLoader.js b/examples/js/loaders/FBXLoader.js
index 9c2a64c..491c82b 100644
--- a/examples/js/loaders/FBXLoader.js
+++ b/examples/js/loaders/FBXLoader.js
@@ -1509,6 +1509,13 @@
}
+ if ( 'GeometricTranslation' in node.properties ) {
+
+ var array = node.properties.GeometricTranslation.value;
+ model.geometry.translate( array[ 0 ], array[ 1 ], array[ 2 ] );
+
+ }
+
var conns = connections.get( model.FBX_ID );
for ( var parentIndex = 0; parentIndex < conns.parents.length; parentIndex ++ ) {
However, this is modifying the geometry directly, so if other scene nodes use this same geometry things will break. |
I created a simple rectangle in 3DS Max. By default the pivot is placed at the centre of the bottom face of the object. Then I centred the pivot to the object, and created two FBX files: Running these through a diff checker, aside from time stamps and IDs the only differences are pivot_default.fbx
pivot_centered.fbx
Specifically, centring the pivot adds the lines:
Both of these files loaded in three.js display correctly, since it seems these lines are ignored and the pivot is assumed to be at the centre of the object. The problem arises when any animation is applied - animations will only be correct for pivot_centered.fbx, as all transformations will be applied around the centre of the object. |
@mrdoob I can confirm that your solution works in my simple test case. For more complex examples though the model may be a Group or Object3D and this is required: if ( 'GeometricTranslation' in node.properties ) {
var array = node.properties.GeometricTranslation.value;
model.traverse( function( child ) {
if( child.geometry ) {
child.geometry.translate( array[ 0 ], array[ 1 ], array[ 2 ] );
}
} );
} This looks better (unfortunately I can't share my model, but here is a before and after screenshot). The only part of this model that is currently animated are the legs which just swing back and forth, and as you can see some strange transform is applied to the left leg, while the right seems to be OK. Aside from that it looks like normals are inverted on the right leg and right arm. So, still a lot of problems - but this gives me hope that most of them can be fixed in Max before exporting.
At the moment, we are faced with a situation where nearly all complex animated or rigged models are broken. It might be the case that supporting these models is more useful than supporting models with reused geometry. But certainly more testing is in order before making that decision - and ideally a solution that suits both cases can be found. |
Hmm... Would loading the file in Blender and exporting as gltf be an option? |
I found that exporting as .abc (alembic) format works , kind of. Materials are not exported, but the object does load in blender at least. However try as I might I cannot get my animations to export with the gltf2 exporter. Aside from this, gltf seems to have the same issue with winding order as #11911 |
Just wanna come back to this - it got a bit off topic, but as I understand it the issue at the moment is that we can either support animation using transformed pivot, or instanced geometry with non-centred pivots. And at the moment we are supporting instanced geometry. I think that supporting animations with transformed pivots is a much higher priority, given that its one of the most basic animation techniques. There's basically no way to get something as simple as a hinge joint working without this fix, let alone a complex rigged mesh. Instanced geometry with centred pivots will still work in any case, and if there is no way to deal with the instanced geometries with non-centred pivots, then that's a small price to pay for fixing animations. |
@FishOrBear can you try implementing the fix mentioned above to see if this fixes your error? |
Thank you, I tried it. |
Closed via #11963 |
Simplified from #11697 since I've figured out the issue.
Here is a simple animation i created in 3ds max:
You can see the pivot point of the red bar has been moved to one end, and it is animated to swing around the pivot.
Loading this in Clara.io:
The animation plays correctly, and the pivot point is displayed in the correct place.
Loading in Paint3D in windows - animations are not played, but the bar is in the correct place:
Finally, loading in three.js and I get this:
The loader has assumed that the pivot point is at the centre of the bar and moved it accordingly - the animation plays around this new pivot.
Here's the FBX file:
simple joint.zip
The text was updated successfully, but these errors were encountered: