Namespace metamodel

xeokit Legacy MetaModel Utilities


Utilities for importing, exporting, and migrating semantic data between xeokit's legacy MetaModel format and the modern DataModel.


This module helps you move between xeokit's older MetaModel format and the newer DataModel, which represents semantic information as an entity–relationship graph with property sets.

You can:

  • Load legacy MetaModel data directly into a DataModel, or
  • Convert MetaModel data into DataModelParams first, then load it explicitly, or
  • Export a DataModel back out as legacy MetaModelParams


xeokit's legacy MetaModel format represents a simple hierarchy of entities with attached property sets. While still supported for compatibility, it has been superseded by the DataModel, which offers a richer and more flexible semantic representation.

This module provides utilities to bridge the two formats.

  • convertMetaModel Converts a MetaModelParams object into a DataModelParams object.
  • MetaModelLoader Loads a MetaModelParams object directly into an existing DataModel.
  • MetaModelExporter Exports a DataModel back out as legacy MetaModelParams JSON.
  • convertDataModel Converts a DataModelParams object into a MetaModelParams object.
  • DataModel The modern semantic data model used by xeokit, based on entity–relationship graphs.
  • DataModelParams The JSON format used to populate a DataModel.
  • MetaModelParams The legacy JSON format describing a hierarchy of entities with property sets.


%%{init:{"theme":"dark"}}%% classDiagram direction TB class MetaModelLoader { +format : "MetaModel" +load(params, options?) Promise~void~ } class convertMetaModel { <<function>> +(metaModelParams) DataModelParams } class ModelLoader { <<formats>> } ModelLoader <|-- MetaModelLoader convertMetaModel ..> MetaModelLoader : upgrades to v3
%%{init:{"theme":"default"}}%% classDiagram direction TB class MetaModelLoader { +format : "MetaModel" +load(params, options?) Promise~void~ } class convertMetaModel { <<function>> +(metaModelParams) DataModelParams } class ModelLoader { <<formats>> } ModelLoader <|-- MetaModelLoader convertMetaModel ..> MetaModelLoader : upgrades to v3
classDiagram
    direction TB
    class MetaModelLoader {
      +format : "MetaModel"
      +load(params, options?) Promise~void~
    }
    class convertMetaModel {
      <<function>>
      +(metaModelParams) DataModelParams
    }
    class ModelLoader {
      <<formats>>
    }
    ModelLoader <|-- MetaModelLoader
    convertMetaModel ..> MetaModelLoader : upgrades to v3

  • Legacy V2 MetaModel — preserves the older xeokit-sdk V2 metadata format for backward compatibility with existing xeokit-convert outputs.
  • Convert-then-loadconvertMetaModel adapts the V2 shape to V3 DataModelParams; feed the result to DataModelImporter for a single-format pipeline.

Install the xeokit SDK using npm:

npm install @xeokit/sdk

The following examples show two common migration workflows.


Use MetaModelLoader when you want to load legacy MetaModel data straight into a DataModel without creating intermediate parameters.

import { Data } from "@xeokit/sdk/model/data";
import { MetaModelLoader } from "@xeokit/sdk/formats/metamodel";

const data = new Data();

const dataModelResult = data.createModel({
id: "myModel"
});

const dataModel = dataModelResult.value;
const metaModelLoader = new MetaModelLoader();

fetch("myMetaModel.json").then(response => {
response.json().then(metaModelParams => {
// Load MetaModelParams directly into the DataModel
metaModelLoader.load({
fileData: metaModelParams,
dataModel
});
});
});

Use convertMetaModel when you want access to DataModelParams—for example, to inspect, modify, or store the converted data before loading it.

import { Data } from "@xeokit/sdk/model/data";
import { convertMetaModel } from "@xeokit/sdk/metamodel";

const data = new Data();

const dataModelResult = data.createModel({
id: "myModel"
});

const dataModel = dataModelResult.value;
fetch("myMetaModel.json").then(response => {
response.json().then(metaModelParams => {
// Convert MetaModelParams -> DataModelParams
const dataModelParams = convertMetaModel(metaModelParams);

// Load DataModelParams into the DataModel
dataModel.fromParams(dataModelParams);
});
});

Classes

MetaModelExporter
MetaModelLoader

Interfaces

MetaModelParams
MetaObjectParams
MetaPropertyParams
MetaPropertySetParams

Functions

convertDataModel
convertMetaModel