Skip to content
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

cjio exports inaccurate when translation is large #184

Open
wlinna opened this issue May 4, 2024 · 1 comment
Open

cjio exports inaccurate when translation is large #184

wlinna opened this issue May 4, 2024 · 1 comment

Comments

@wlinna
Copy link

wlinna commented May 4, 2024

Describe the bug
cjio exports tend to become very inaccurate once translation is involded.

My suspicion is that it is caused by cjio calling self.decompress before computing normals, triangulating etc.
The problem would likely go away if only the scale was applied before computations, and then the translation was applied
as a final step. In the case of glTF, the translation should be set for the node. In the case of OBJ, the translation should be
applied to each vertex.

cjio version
I tried both the master and develop branches

To Reproduce
Prerequisite: you have cjio in your PATH

repro.zip

  1. Download the test files
  2. Run cjio simplified.city.json export glb simplified.glb
  3. Run cjio simplified_translated.city.json export glb simplified_translated.glb
  4. Open Blender. Import simplified.glb . It looks okay. You can remove it
  5. Import simplified_translated.glb
  6. Select the node called "building", press F3, sand run "Origin to Geometry"
  7. Set the location to 0, 0, 0
  8. See how deformed the GLB is

I also tested OBJ, and the problem is basically the same.
(The reason why we must take so many steps to view the file is because the translation is applied to vertex coordinates instead of setting it for the node)

Expected behavior
The resulting geometry should not deform.

(Also, as a side note, the GLB should have the translation applied to its root node, not at geometry level. The viewers have much easier time handling such models)

Screenshots
SimplifiedTranslated

Desktop (please complete the following information):

  • OS: Pop!_OS (Ubuntu-based)
  • Version 22.04

Additional context
This happens with real-life models. This is just a simplified version with made-up coordinates, but the problem is the same.

@wlinna
Copy link
Author

wlinna commented May 5, 2024

The other issue where I just mentioned in cityjson-threejs-loader is very similar. I also posted a side-by-side comparison image there.

The files have different translations from the ones posted here, which leads to slightly different deformities.

cityjson-loader-broken-translation-handling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant