diff --git a/src/viewer/metadata/MetaObject.js b/src/viewer/metadata/MetaObject.js index 6c2cc35ea..e0deeabc8 100644 --- a/src/viewer/metadata/MetaObject.js +++ b/src/viewer/metadata/MetaObject.js @@ -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[]} diff --git a/src/viewer/metadata/MetaScene.js b/src/viewer/metadata/MetaScene.js index c1a183890..881f5f82f 100644 --- a/src/viewer/metadata/MetaScene.js +++ b/src/viewer/metadata/MetaScene.js @@ -182,6 +182,7 @@ 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({ @@ -189,7 +190,7 @@ class MetaScene { parentId: metaObjectData.parent, type, name: metaObjectData.name, - propertySetIds: metaObjectData.propertySetIds + propertySetIds }); this.metaObjects[id] = metaObject; } @@ -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) { @@ -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; } } } @@ -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 = {};