Skip to content

Improve compatibility and generation#96

Open
HeDo88TH wants to merge 2 commits into
masterfrom
improve-compatibility
Open

Improve compatibility and generation#96
HeDo88TH wants to merge 2 commits into
masterfrom
improve-compatibility

Conversation

@HeDo88TH

@HeDo88TH HeDo88TH commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

This PR addresses #93 #84

@HeDo88TH HeDo88TH self-assigned this Jul 9, 2026
Copilot AI review requested due to automatic review settings July 9, 2026 09:22
@HeDo88TH HeDo88TH added bug Something isn't working enhancement New feature or request labels Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.b3dm from a coarsest whole-model OBJ and attach it as tileset.root.content.
  • Change tileset root refinement to "REPLACE" and derive --error automatically from model bounds when unspecified (default 0).
  • Update CLI help text for --error to 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 thread Obj2Tiles/Program.cs
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.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants