CesiumGS / 3d-tiles-tools

Apache License 2.0
307 stars 46 forks source link

How to merge multiple tileset.jsons into one #119

Closed jingyangking closed 6 months ago

jingyangking commented 6 months ago

I want to combine multiple tiles into one tile set, so I used this command npx 3d files tools merge - i/ Specs/data/mergeTilesets/Tilesetone - i/ Spec/data/mergeTilesets/sub/Tilesettwo - i/ Spec/data/mergeTilesets/sub/Tilesetthree - o/ Spec/data/mergeTilesets/output, where tiles one, tiles two, and tiles three all have tiles set.json and multiple b3dms, but the result shows that tileset.json cannot be found. I am not sure why? I hope you can give me a reply, thank you!

javagl commented 6 months ago

There are two functionalities of the 3D Tiles Tools that are related to each other. (And I'm always mixing them up...)

These functions are merge and combine:

It might be that you expected the merge function to do something else.


For example: When you call something like

npx 3d-tiles-tools merge -i ./input/one -i ./input/two -i ./input/three -o ./output/merged

Then it will create a tileset that refers to the input tilesets as external tilesets. The resulting directory structure and JSON are shown here:

Cesium Merged Tileset

Note that this still refers to the tileset.json files from the inputs.


If you want to create a tileset that does no longer refer to the input tileset.json files, then you can use the following:

npx 3d-tiles-tools combine -i ./output/merged -o ./output/combined

It will create a tileset with this structure:

Cesium Combined Tileset

Note that this now refers directly to the content of these input tilesets (and no longer to the tileset.json files of the input)


If this does not answer your question, then I'd have to ask for clarification what you mean by...

the result shows that tileset.json cannot be found.

If this is part of an error message, then it may be necessary to provide more information about where this error appears.

jingyangking commented 6 months ago

Yes, what I want to implement is the first example you provided, but unfortunately, as I mentioned before, the corresponding tileset.json cannot be found. I'm not sure why this happened. Is it because I input too many files that caused this situation? Thank you!

javagl commented 6 months ago

I have to nitpick about two things:

  1. You wrote...

npx 3d files tools merge - i/ Specs/data/mergeTilesets/Tilesetone ^- there is a slash followed by a space...

You should ensure that the path is given properly.

  1. The path must either contain a tileset.json file, or you must give the name of the tileset JSON file as the input.

For example, if the name of the tileset JSON file for the first input is /Specs/data/mergeTilesets/Tilesetone/theNameOfThisFileIsDifferent.json then you have to pass this full file name to the command line, as in

npx 3d files tools merge -i /Specs/data/mergeTilesets/Tilesetone/theNameOfThisFileIsDifferent.json ...

(When you only pass in the name of a directory, then it assumes that the tileset JSON file is called tileset.json. Otherwise, there could be many different JSON files in this directory, and the tools do not know which one is the tileset JSON)

jingyangking commented 6 months ago

You're right, I provided a specific file path as follows:"E:\3Dmodelfile\3dtiles\ifctileset\one_ifctileset",其中的文件内容如下: image The other tileset.json files are the same except for their names, image but entering such a command resulted in an error message image I hope this can clarify what I want to express,thank you!

javagl commented 6 months ago

Right now, I cannot imagine what could be the reason for this error.

When each input directory contains a file that is called tileset.json, then this should be picked up automatically.

If this does not work: Could you try to merge only two tilesets (as a test), and give the full path to the tileset.json files, like this:

... -i E:\3Dmodelfile\3dtiles\ifctileset\one_ifctileset\tileset.json ... ^--file name here

I tried out the merge function with some example tilesets, and could not yet reproduce this error message, except for cases where the input directory did not contain a tileset.json file...

jingyangking commented 6 months ago

Okay, I'll give it a try. Thank you for your reply!

javagl commented 6 months ago

If it doesn't work, I'd even go so far to create a branch with additional logging information, with details about where exactly it is trying to find that tileset.json file, and which files it does find there instead. We should be able to figure out what's wrong here.

jingyangking commented 6 months ago

Thank you for your reply! I found an issue: the input path must be accurate, including uppercase and lowercase letters, while the output path does not have such strict requirements. image

javagl commented 6 months ago

To some extent, this may depend on the operating system, but I'd have to verify that.

But in general, one should assume that the paths are case-sensitive.

jo-chemla commented 5 months ago

There are two functionalities of the 3D Tiles Tools that are related to each other. (And I'm always mixing them up...)

These functions are merge and combine:

  • merge creates a tileset, that still refers to the input tilesets (as external tilesets)
  • combine creates a tileset where external tilesets have been "inlined"

Sorry for commenting on a closed thread, but a warm thanks for this detailed comparison of merge vs combine. It explains really simply the difference between both methods and probably could be added some place more permanent - maybe in the 3d-tiles-tools readme as-is, or as a link to this comment

javagl commented 5 months ago

@jo-chemla I agree that this could be clarified.

On the one hand, my comment only added a little detail compared the the current documentation of combine, but probably an important detail - namely, that the external tilesets are "inlined". (In fact, inline might have been a better name for combine, and merge could then have been called combine, but ... all this is subjective, to some extent...)

There are a few pending updates/clarifications for the README, and I'll probably add them (including this one) in the next days.

jo-chemla commented 5 months ago

Understood, thanks for the details! Indeed, also in favor of this naming, but probably cannot be done as a somewhat aggressive breaking change.