Skip to content

Commit

Permalink
Fix creation of metamodels propertySets #1103
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Jul 19, 2023
1 parent 355ee52 commit db7697e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/viewer/metadata/MetaObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ class MetaObject {
this.type = params.type;

/**
* Optional {@link PropertySet}s used by this MetaObject.
* IDs of PropertySets associated with this MetaObject.
* @type {[]|*}
*/
this.propertySetIds = params.propertySetIds;

/**
* The {@link PropertySet}s associated with this MetaObject.
*
* @property propertySets
* @type {PropertySet[]}
Expand Down
47 changes: 39 additions & 8 deletions src/viewer/metadata/MetaScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ class MetaScene {
const metaObjectData = metaModelData.metaObjects[i];
const type = metaObjectData.type;
const id = metaObjectData.id;
const propertySetIds = metaObjectData.propertySets | metaObjectData.propertySetIds;
let metaObject = this.metaObjects[id];
if (!metaObject) {
metaObject = new MetaObject({
id,
parentId: metaObjectData.parent,
type,
name: metaObjectData.name,
propertySetIds: metaObjectData.propertySetIds
propertySetIds
});
this.metaObjects[id] = metaObject;
}
Expand All @@ -209,6 +210,19 @@ class MetaScene {
if (metaObject.children) {
metaObject.children = [];
}

// Re-link each MetaObject's property sets

if (metaObject.propertySets) {
metaObject.propertySets = [];
}
if (metaObject.propertySetIds) {
for (let i = 0, len = metaObject.propertySetIds.length; i < len; i++) {
const propertySetId = metaObject.propertySetIds[i];
const propertySet = this.propertySets[propertySetId];
metaObject.propertySets.push(propertySet);
}
}
}

for (let objectId in this.metaObjects) {
Expand Down Expand Up @@ -255,14 +269,18 @@ class MetaScene {

// Globalize MetaObject property set IDs

const propertySetIds = metaObjectData.propertySetIds;
if (propertySetIds) {
const propertySetGlobalIds = [];
for (let j = 0, lenj = propertySetIds.length; j < lenj; j++) {
propertySetGlobalIds.push(math.globalizeObjectId(modelId, propertySetIds[j]));
if (globalize) {
const propertySetIds = metaObjectData.propertySetIds;
if (propertySetIds) {
const propertySetGlobalIds = [];
for (let j = 0, lenj = propertySetIds.length; j < lenj; j++) {
propertySetGlobalIds.push(math.globalizeObjectId(modelId, propertySetIds[j]));
}
metaObjectData.propertySetIds = propertySetGlobalIds;
metaObjectData.originalSystemPropertySetIds = propertySetIds;
}
metaObjectData.propertySetIds = propertySetGlobalIds;
metaObjectData.originalSystemPropertySetIds = propertySetIds;
} else {
metaObjectData.originalSystemPropertySetIds = metaObjectData.propertySetIds;
}
}
}
Expand Down Expand Up @@ -345,6 +363,19 @@ class MetaScene {
if (metaObject.children) {
metaObject.children = [];
}

// Re-link each MetaObject's property sets

if (metaObject.propertySets) {
metaObject.propertySets = [];
}
if (metaObject.propertySetIds) {
for (let i = 0, len = metaObject.propertySetIds.length; i < len; i++) {
const propertySetId = metaObject.propertySetIds[i];
const propertySet = this.propertySets[propertySetId];
metaObject.propertySets.push(propertySet);
}
}
}

this.metaObjectsByType = {};
Expand Down

0 comments on commit db7697e

Please sign in to comment.