KhronosGroup / UnityGLTF

Runtime glTF 2.0 Loader for Unity3D
MIT License
1.83k stars 489 forks source link

Models Now Transformed with Y=180 Degree Rotation #319

Open KermMartian opened 5 years ago

KermMartian commented 5 years ago

Pretty much what it says on the tin. As of a version from around March 2018, models were properly loaded with the transform offset from the loaded GLTF's (0, 0, 0) point. Now, it appears that models are transformed from the center of the model, which is very challenging for precise positioning. Is this intentional behavior, and if so, is there a way to work around it?

I'm afraid I had identified the symptom of this problem incorrectly. What appeared to be an incorrect offset was, in fact, an extra transformation of 180 degrees around the Y axis (in the XZ plane). In other words, while the model's (0, 0, 0) point is in the correct place, the model extends along the negative X and negative Z axis from that point, instead of the positive X and positive Z axis. I have temporarily worked around this by setting obj.transform.eulerAngles = new Vector3(0f, 180f, 0f); for each new GLTFComponent that I create, but that feels like a fragile solution indeed. I note that UnityGLTF.Extensions.SchemaExtensions has some comments that discuss GLTF handedness versus Unity handedness; might this be the culprit? I don't see a robust way to override this behavior. TIA.

blgrossMS commented 5 years ago

Whats an example model you noticed this behavior with?

KermMartian commented 5 years ago

@blgrossMS I apologize, I had misidentified the root symptom. Please see the edited first post.

blgrossMS commented 5 years ago

See the conversation in #257, does this address the coordinate transform issue you are seeing?

otri commented 1 year ago

I can confirm, coordinate spaces don't match export from Blender into Unity. Also a direct comparison of FBX import vs GLB import, shows the GLB gets a Y=180 degree rotation. Model contains identity transform, no rotation, scale, or translation applied. Strictly handedness conversion gets the coordinate spaces wrong. I think people expect Up and Forward orientation the scene space to be respected here, so a GLB scene is loaded identically with respect to other model imports.

FBX and GLB imports with correct relative orientation in Apple's Reality Converter and in Blender. So it really appears to be an issue of UnityGLTF and glTFast import convention malpractice.

hybridherbst commented 1 year ago

Can you check from the dev branch please?