Import and visualize 3D urban models using the
CityJSON
format.
Overview
The xeokit SDK supports importing CityJSON, a lightweight, open,
JSON-based format for representing 3D city models.
CityJSON is designed as a simpler, more developer-friendly alternative to
CityGML, while preserving the same conceptual model. It is commonly used
to represent:
// 1) Create containers for geometry and city semantics constscene = newScene(); constdata = newData();
// 2) Create Viewer and WebGL renderer constviewer = newViewer({ scene }); newWebGLRenderer({ viewer });
// 3) Create a View bound to an existing canvas element constviewResult = viewer.createView({ id:"myView", elementId:"myCanvas"// Ensure this HTMLElement exists });
if (viewResult.ok === false) { handleError(viewResult.error); return; }
constview = viewResult.value;
// 4) Position the camera view.camera.eye = [1841982.93, 10.03, -5173286.74]; view.camera.look = [1842009.49, 9.68, -5173295.85]; view.camera.up = [0, 1, 0];
// 5) Enable interactive camera control newCameraControl(view, {});
// 6) Create target models for the loader constsceneModelResult = scene.createModel({ id:"myModel" }); if (sceneModelResult.ok === false) { handleError(sceneModelResult.error); return; }
cityjson — CityJSON Importer
Import and visualize 3D urban models using the CityJSON format.
Overview
The xeokit SDK supports importing CityJSON, a lightweight, open, JSON-based format for representing 3D city models.
CityJSON is designed as a simpler, more developer-friendly alternative to CityGML, while preserving the same conceptual model. It is commonly used to represent:
Importing CityJSON
Use CityJSONLoader to load CityJSON data into xeokit.
The loader populates:
This separation allows applications to visualize large urban models while still querying and analyzing their underlying city objects.
Installation
Example: loading a CityJSON model (with error checking)
The following example demonstrates a complete CityJSON import workflow, including explicit error handling for all xeokit factory calls.
Notes