CesiumGS / obj2gltf

Convert OBJ assets to glTF
Apache License 2.0
1.71k stars 307 forks source link

Axis problem or georeference problem? #148

Closed zxzfcsu closed 6 years ago

zxzfcsu commented 6 years ago

Hello! I have a obj format model. I found the model has a rotation change after convert it into gltf. The first picture below is the obj file.The second is gltf file,when I put it in Cesium,it displays like that.

obj-wrong

gltf-wrong

I have searched the Issues,someone said it's an axis problem,others said it's a georeference problem.Could anyone answer me and give a solution? Thanks in advance!

jwsz04_0024_residential_corporation_walk_348.mtl.txt jwsz04_0024_residential_corporation_walk_348.obj.txt

likangning93 commented 6 years ago

This looks like an up-axis problem. We have some notes in the 1.47 release's CHANGES.md that could be helpful for directly editing the gltf if that's an option, but you can also adjust the model's orientation in something like Blender.

As a quick tip, georeference problems also often put the model very far away from the latitude/longitude where you expect it to show up on Cesium, they may even end up floating very far away from the ground.

likangning93 commented 6 years ago

Importing the obj into blender as Z-up and exporting it as Y-up seems to work via the online converter.

zxzfcsu commented 6 years ago

Thank you very much.

zxzfcsu commented 6 years ago

Hi. I have tried to add the Y_UP_Transform node to the node hierarchy like this: transform But it didn't change anything.Why and what should I do next? And I tried to use blender,it works well. Thank you!

likangning93 commented 6 years ago

@zxzfcsu for Y_UP_Transform to be part of the node hierarchy, it needs to be in the nodes array. Its children should be the previous contents of scene[0], and then scene[0] should be changed to only contain the index of the Y_UP_Transform node.

I recommend adding Y_UP_Transform only at the end of the nodes array, because putting it anywhere else will shift the indices of other nodes, which could mess up the scene.

Here's an example using the Duck from gltf 2.0 sample models, please see attached.

Ducks.zip