@xeokit/xeokit-convert
Version:
JavaScript utilities to create .XKT files
55 lines (54 loc) • 2.32 kB
TypeScript
/**
* @desc Parses a CityJSON model into an {@link XKTModel}.
*
* [CityJSON](https://www.cityjson.org) is a JSON-based encoding for a subset of the CityGML data model (version 2.0.0),
* which is an open standardised data model and exchange format to store digital 3D models of cities and
* landscapes. CityGML is an official standard of the [Open Geospatial Consortium](https://www.ogc.org/).
*
* This converter function supports most of the [CityJSON 1.0.2 Specification](https://www.cityjson.org/specs/1.0.2),
* with the following limitations:
*
* * Does not (yet) support CityJSON semantics for geometry primitives.
* * Does not (yet) support textured geometries.
* * Does not (yet) support geometry templates.
* * When the CityJSON file provides multiple *themes* for a geometry, then we parse only the first of the provided themes for that geometry.
*
* ## Usage
*
* In the example below we'll create an {@link XKTModel}, then load a CityJSON model into it.
*
* ````javascript
* utils.loadJSON("./models/cityjson/DenHaag.json", async (data) => {
*
* const xktModel = new XKTModel();
*
* parseCityJSONIntoXKTModel({
* data,
* xktModel,
* log: (msg) => { console.log(msg); }
* }).then(()=>{
* xktModel.finalize();
* },
* (msg) => {
* console.error(msg);
* });
* });
* ````
*
* @param {Object} params Parsing params.
* @param {Object} params.data CityJSON data.
* @param {XKTModel} params.xktModel XKTModel to parse into.
* @param {boolean} [params.center=false] Set true to center the CityJSON vertex positions to [0,0,0]. This is applied before the transformation matrix, if specified.
* @param {Boolean} [params.transform] 4x4 transformation matrix to transform CityJSON vertex positions. Use this to rotate, translate and scale them if neccessary.
* @param {Object} [params.stats] Collects statistics.
* @param {function} [params.log] Logging callback.
@returns {Promise} Resolves when CityJSON has been parsed.
*/
export function parseCityJSONIntoXKTModel({ data, xktModel, center, transform, stats, log }: {
data: Object;
xktModel: XKTModel;
center?: boolean | undefined;
transform?: boolean | undefined;
stats?: Object | undefined;
log?: Function | undefined;
}): Promise<any>;