Improve compatibility and generation#96
Open
HeDo88TH wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves 3D Tiles renderer compatibility and dataset generation behavior by (1) optionally generating renderable root-tile content (to avoid “empty root” tilesets that some renderers won’t traverse) and (2) making the root geometricError default scale with the model’s size instead of using a fixed constant.
Changes:
- Generate an optional
root.b3dmfrom a coarsest whole-model OBJ and attach it astileset.root.content. - Change tileset root refinement to
"REPLACE"and derive--errorautomatically from model bounds when unspecified (default0). - Update CLI help text for
--errorto clarify behavior and units.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Obj2Tiles/Stages/TilingStage.cs | Adds optional root content generation and updates root tile refinement/content wiring. |
| Obj2Tiles/Program.cs | Derives default baseError from model bounds and prepares a compressed coarsest root mesh for tiling. |
| Obj2Tiles/Options.cs | Changes --error default to 0 and documents automatic derivation behavior. |
Comment on lines
+78
to
+82
| // REPLACE (not ADD): the root's coarse whole-model content is superseded by the finer | ||
| // child tiles as they load, so the two never render on top of each other. | ||
| Refine = "REPLACE", | ||
| Transform = rootTransform, | ||
| Content = rootContentUri != null ? new Content { Uri = rootContentUri } : null, |
Comment on lines
+98
to
+100
| var modelDiagonal = Math.Sqrt(b.Width * b.Width + b.Height * b.Height + b.Depth * b.Depth); | ||
| var baseError = opts.BaseError > 0 ? opts.BaseError : modelDiagonal; | ||
| if (!(baseError > 0)) baseError = 1.0; |
Comment on lines
+22
to
+43
| // Give the tileset root renderable content. The root tile spans the whole model but, in an | ||
| // octree/multi-tile layout, its geometry lives only in the child tiles, leaving the root | ||
| // empty (content: null). An empty root is legal per the 3D Tiles spec, but several renderers | ||
| // (e.g. giro3d's 3d-tiles-renderer, which hardcodes LOAD_ROOT_SIBLINGS) will not descend into | ||
| // the children of a content-less root, so the whole model never appears. Converting the | ||
| // coarsest decimated whole-model mesh into "root.b3dm" gives the root a lightweight, complete | ||
| // representation that is then refined (REPLACE) by the finer child tiles. | ||
| string? rootContentUri = null; | ||
| if (rootSourceObj != null && File.Exists(rootSourceObj)) | ||
| { | ||
| try | ||
| { | ||
| var rootB3dm = Path.Combine(destPath, "root.b3dm"); | ||
| Utils.ConvertB3dm(rootSourceObj, rootB3dm); | ||
| rootContentUri = "root.b3dm"; | ||
| Console.WriteLine($" ?> Generated root content from '{Path.GetFileName(rootSourceObj)}'"); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Console.WriteLine($" !> Could not generate root content ({ex.Message}); the root tile will be empty."); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses #93 #84