A buildable, queryable, importable, and exportable semantic graph for describing model meaning.
Overview
The xeokit SDK represents “meaning” (entities, properties, and relationships) as a generic entity-relationship graph
that works in both browsers and Node.js. Use this module to:
Relationships may connect DataObjects across different DataModels, as long as they share the same owning Data.
Installation
npminstall@xeokit/sdk
Usage
Creating a DataModel from JSON
This example creates a DataModel from a DataModelParams object that describes a simple table:
a tabletop and four legs. After building the model, you can traverse it to collect the IDs of contained
DataObjects.
The DataModel defines:
six DataObjects (table, tabletop, four legs),
aggregation Relationships that connect them into a hierarchy, and
PropertySets with Properties that describe attributes such as height and weight.
All methods in this example return SDKResult values, which should be checked for errors.
With a DataModel built, searchObjects can traverse the graph and collect IDs of visited
DataObjects. A common use case is building a tree view by following aggregation relationships.
DataModels can be loaded from supported file formats via loaders in @xeokit/sdk/formats.
For example, a DotBIM loader can populate both a SceneModel (geometry) and a DataModel
(semantics) from the same source data:
// Pseudocode (loader API depends on the format module you use) constsceneModelRes = scene.createModel({ id:"myModel3" }); constdataModelRes = data.createModel({ id:"myModel3" });
if (!sceneModelRes.ok) thrownewError(sceneModelRes.error); if (!dataModelRes.ok) thrownewError(dataModelRes.error);
xeokit Semantic Data Model
A buildable, queryable, importable, and exportable semantic graph for describing model meaning.
Overview
The xeokit SDK represents “meaning” (entities, properties, and relationships) as a generic entity-relationship graph that works in both browsers and Node.js. Use this module to:
The class diagram below summarizes the main classes in this module and their relationships:
At the top level is Data, which owns one or more DataModels. Each DataModel contains:
To construct DataModels in code, use builder methods such as Data.createModel, DataModel.createObject, DataModel.createPropertySet, and DataModel.createRelationship. To traverse/query the graph, use searchObjects and the relationship links on DataObject.
Notes
Installation
Usage
Creating a DataModel from JSON
This example creates a DataModel from a DataModelParams object that describes a simple table: a tabletop and four legs. After building the model, you can traverse it to collect the IDs of contained DataObjects.
The DataModel defines:
All methods in this example return SDKResult values, which should be checked for errors.
Creating a DataModel using Builder Methods
This example recreates the same model, but constructs each PropertySet, DataObject, and Relationship individually using DataModel builder methods.
Reading DataObjects
With a DataModel built, searchObjects can traverse the graph and collect IDs of visited DataObjects. A common use case is building a tree view by following aggregation relationships.
Traversing Relationships Directly
This example follows outgoing Relationships from a root DataObject:
Serializing a DataModel to JSON
Deserializing a DataModel from JSON
Destroying a DataModel
Loading a DataModel from a File
DataModels can be loaded from supported file formats via loaders in @xeokit/sdk/formats. For example, a DotBIM loader can populate both a SceneModel (geometry) and a DataModel (semantics) from the same source data:
Handling Events
All events for a Data are emitted through DataEvents at Data.events. For example, you can listen for model creation and destruction: