warrenm / GLTFKit2

A glTF 2.0 asset loader and exporter for Objective-C and Swift.
MIT License
150 stars 26 forks source link

Temperance bone direction #55

Closed daninils closed 2 months ago

daninils commented 2 months ago

Hello! Is it possible to change the bone directions when importing a glb file? It seems like other GLTF loaders are able to do that. Tested with ThreeJS and it works correctly. Our glbs are exported using Maya which seems to expect the glb loader to sort the bones different.

If I import the glb using blender and select "Temperance" it seems to fix the issue.

Screenshot 2024-04-17 at 10 11 33
Temperance Default
Blender-Temperance Defualt-Blender

My fork that reproduce the issue: https://github.com/daninils/GLTFKit2/tree/bone-direction-example

warrenm commented 2 months ago

This may be a usage error. In lines 43–49 of ContentView.swift, you iterate over the skinned nodes of the dino model and apply the skeleton of a different hierarchy ("head") as the skeleton of these nodes. The framework already applies skeletons to the SceneKit node/skinner pairs it generates, so this seems extremely odd to me. If I remove line 47, the model looks the same regardless of which model I load.

daninils commented 2 months ago

Thanks for the fast reply!

Sorry for the confusion. The reason why I'm applying the skeleton to a different hierarchy is to be able to build a "avatar" with different skins/assets and then run a animation for the character.

So the head.glb is the main file where we build the avatar with different skins (like t-shirt or hoodies etc).

I don't know if this "temperance" bone direction is possible to do in this lib or if it's more towards something that cgltf can do? What do you think?😊

warrenm commented 2 months ago

There is no such concept as "Temperance" or any other variation on joint pose in the glTF format. These are just heuristics used by modeling packages to map from whatever their internal format is to glTF. This should be apparent because if you load either model and don't change its skeleton, it displays correctly. If you want to compose multiple scenes together, you are responsible for ensuring that the coordinate spaces of the joint hierarchies are consistent among them. This is a data problem, not a library problem.

warrenm commented 2 months ago

This issue will be closed as completed in 7 days if no further response is received.