Namespace datamodel

xeokit DataModelParams Importer and Exporter


Import and export semantic DataModels using xeokit’s JSON-based DataModelParams interchange format.


This module provides utilities for serializing and deserializing DataModels to and from the SDK’s canonical JSON representation, DataModelParams. The format captures a DataModel’s complete semantic state, including objects, relationships, properties, and metadata.


npm install @xeokit/sdk

Use DataModelParamsExporter to serialize a DataModel into a DataModelParams object, which can then be stored or transmitted as JSON.

import { DataModelParamsExporter } from "@xeokit/sdk/datamodel";

const exporter = new DataModelParamsExporter();

const paramsResult = exporter.write({
dataModel
});

if (!paramsResult.ok) {
console.error(paramsResult.error);
} else {
const dataModelParams = paramsResult.value;
const json = JSON.stringify(dataModelParams, null, 2);
// persist or transmit `json`
}

Use DataModelParamsLoader to reconstruct a DataModel from a previously serialized DataModelParams object.

import { DataModelParamsLoader } from "@xeokit/sdk/datamodel";
import { Data } from "@xeokit/sdk/data";

const data = new Data();

const loader = new DataModelParamsLoader();

const result = loader.load({
dataModelParams,
data
});

if (!result.ok) {
console.error(result.error);
} else {
const dataModel = result.value;
console.log("DataModel loaded:", dataModel.id);
}

Because DataModelParams is a lossless representation of xeokit’s semantic graph, a DataModel can be exported and re-imported without changing object IDs, relationships, or properties—making it suitable for caching and synchronization workflows.


Classes

DataModelParamsExporter
DataModelParamsLoader