diff --git a/src/viewer/metadata/MetaModel.js b/src/viewer/metadata/MetaModel.js index d627aa3cc4..71282b25eb 100644 --- a/src/viewer/metadata/MetaModel.js +++ b/src/viewer/metadata/MetaModel.js @@ -138,6 +138,8 @@ class MetaModel { this.metaScene.metaModels[this.id] = this; + this._propertyLookup = []; + /** * True when this MetaModel has been finalized. * @type {boolean} @@ -152,7 +154,7 @@ class MetaModel { * @type {MetaObject|null} */ get rootMetaObject() { - if (this.rootMetaObjects.length == 1) { + if (this.rootMetaObjects.length === 1) { return this.rootMetaObjects[0]; } return null; @@ -173,6 +175,12 @@ class MetaModel { const metaScene = this.metaScene; const propertyLookup = metaModelData.properties; + if (propertyLookup) { + for (let i = 0, len = propertyLookup.length; i < len; i++) { + this._propertyLookup.push(propertyLookup[i]); + } + } + // Create global Property Sets if (metaModelData.propertySets) { @@ -183,9 +191,6 @@ class MetaModel { } let propertySet = metaScene.propertySets[propertySetData.id]; if (!propertySet) { - if (propertyLookup) { - this._decompressProperties(propertyLookup, propertySetData.properties); - } propertySet = new PropertySet({ id: propertySetData.id, originalSystemId: propertySetData.originalSystemId || propertySetData.id, @@ -232,15 +237,21 @@ class MetaModel { } _decompressProperties(propertyLookup, properties) { + const propsNotFound = []; for (let i = 0, len = properties.length; i < len; i++) { const property = properties[i]; if (Number.isInteger(property)) { const lookupProperty = propertyLookup[property]; if (lookupProperty) { properties[i] = lookupProperty; + } else { + propsNotFound.push(property); } } } + if (propsNotFound.length > 0) { + console.error(`[MetaModel._decompressProperties] Properties not found: ${propsNotFound}`); + } } finalize() { @@ -308,6 +319,18 @@ class MetaModel { (metaScene.metaObjectsByType[type] || (metaScene.metaObjectsByType[type] = {}))[objectId] = metaObject; } + // Decompress properties + + if (this.propertySets) { + for (let i = 0, len = this.propertySets.length; i < len; i++) { + const propertySet = this.propertySets[i]; + this._decompressProperties(this._propertyLookup, propertySet.properties); + } + } + + + this._propertyLookup = []; + this.finalized = true; this.metaScene.fire("metaModelCreated", this.id); diff --git a/src/viewer/metadata/PropertySet.js b/src/viewer/metadata/PropertySet.js index f6a2ef0d98..6c041523a1 100644 --- a/src/viewer/metadata/PropertySet.js +++ b/src/viewer/metadata/PropertySet.js @@ -68,7 +68,11 @@ class PropertySet { const properties = params.properties; for (let i = 0, len = properties.length; i < len; i++) { const property = properties[i]; - this.properties.push(new Property(property.name, property.value, property.type, property.valueType, property.description)); + if (Number.isInteger(property)) { // Will decompress in MetaModel.finalize(); + this.properties.push(property); + } else { + this.properties.push(new Property(property.name, property.value, property.type, property.valueType, property.description)); + } } } }