-
Notifications
You must be signed in to change notification settings - Fork 45
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
Decide on the library usage, packaging, and API #21
Comments
The current state of the (non-) API of the 3D Tiles Tools is: Everything is exported, but nothing is public. This is caused by the fact that the current state of the 3D Tiles Tools has largely been implemented as internal (non-public) functionality within the But even though it was not explicitly designed to be a public library, the possibility for things to become public had been kept in mind during the development: The project already is divided into "packages", namely by the directory structure. Each directory contains certain classes that are candidates to become part of a public API. A description of the overall project structure, including the most important classes for each "package", can be found in the implementation notes. It's difficult to come up with a proper API definition without a clear idea about what people might expect to be offered by the tools. But one can start, based on a mix of 1. knowledge about what is required by the These initial thoughts can then be refined, iteratively. Level 1: Restore the previous APIBefore the 'TypeScript rewrite', the module.exports = {
databaseToTileset : require('./lib/databaseToTileset'),
extractB3dm : require('./lib/extractB3dm'),
extractCmpt : require('./lib/extractCmpt'),
extractI3dm : require('./lib/extractI3dm'),
glbToB3dm : require('./lib/glbToB3dm'),
glbToI3dm : require('./lib/glbToI3dm'),
gzipTileset : require('./lib/gzipTileset'),
runPipeline : require('./lib/runPipeline'),
tilesetToDatabase : require('./lib/tilesetToDatabase')
}; These functions resemble a subset of what is offered as command line commands. (They do not exactly correspond to the command line functions, but some details will be discussed below). Command line commands that have not been supported are A similar API could be offered based on the current state, for people who have a dependency to the 0.1.3 version, and want to use the newer version. However, this should probably be marked as deprecated to begin with. The API could be offered based on the Whether or not this API can be exactly compatible in terms of importing and behavior of the functions would have to be sorted out. I think that users of the old API did write something like import { gzip } from '3d-tiles-tools';
gzip(...).then(...); And one could probably define a compatible API by adding import { ToolsMain } from "./ToolsMain";
export function gzip(...) {
return ToolsMain.gzip(...);
} to the Level 2: Provide an API that is equivalent to the old oneThere is no public API for the tools yet, but some things that may become an API. And in many ways...
Then, in the first step, for clients, one of the largest differences would be that of "namespaces" (aka "classes") that are introduced, and ... that there are types.
One example: The old API had a function import { extractB3dm } from '3d-tiles-tools';
...
const b3dm = extractB3dm(b3dmBuffer);
... A similar function exists in the import { TileFormats } from '3d-tiles-tools';
...
const b3dm = TileFormats.readTileData(b3dmBuffer);
... and this functionality is equivalent, insofar that the returned object contains the same information as before, with a slightly different structure of the returned value. (Specifically, the returned object has the type An API that is equivalent to the old oneThe exact way of how the new API should be exposed is not yet clear, and this is where the bazillion questions can come up. Even just referring to the above example:
But some high-level ideas about functions that could be "equivalent" to the old API: Tileset-database conversions
Extracting information from tile data
Zipping/unzipping:
Pipelines
Level 3+: Further thoughts about the APIOne important thing - even if it sounds trivial at the first glance - is whether the API operations should work on files or objects. For certain operations, it's relatively easy: There could be a (Even though there's already the question: Should both of them be But for other things it's not so easy. For example, the doItWithFiles(input: string, output: string) {
souce = open(input);
target = open(output);
doItWithObjects(source, target);
close(input);
close(output);
} Several existing classes have a tendency to use file names (e.g. in the |
This may have to be broken down into smaller issues at some point, but some context is summarized here:
Much of the functionality of version 0.2.0 of the tools was built by extracting "generic" functionality from the 3d-tiles-validator. Nearly all of this functionality is exposed by the 3d-tiles-tools on an API level, because it is supposed to be used by the validator, as an internal project. Therefore, all of the API is marked as
@internal
in the documentation.The overarching question is now: What should be made 'public', and how?
This refers to the API level for each part, but also to the structure of the libraries. There are some "low-level" functionalities that are basic enough so that one could justify offering them as a dedicated library. (Note: The directory structure in the current state of the tools already reflects a possible way to break down the tools into smaller libraries....). Such libraries could be, for example:
structure
classes #20 ) - that could be useful for other TypeScript users in generalIn many ways, this boils down to the question of the intended granularity of the libraries.
For each library itself, there's still the quesition about the exact API.
(From my Java backround, I'm a fan of the purist approach, which can be summarized as: "No public constructors, period". But I'm not (yet) sure whether this is considered to be "idiomatic" in TypeScript).
The importance of this question is already apparent: The
3d-tiles-validator
is supposed to use nearly everything of the3d-tiles-tools
. So the tools will be a dependency of the validator. On the other hand, it would make a lot of sense to use the validator to check whether input/output tilesets of the tools are really valid, meaning that the validator would be a dependency of the tools. This shows that there is a line that should be drawn, but it's not yet clear where to draw this line.The text was updated successfully, but these errors were encountered: