@xeokit/xeokit-sdk 2.6.20 → 2.6.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -138,6 +138,8 @@ class MetaModel {
138
138
 
139
139
  this.metaScene.metaModels[this.id] = this;
140
140
 
141
+ this._propertyLookup = [];
142
+
141
143
  /**
142
144
  * True when this MetaModel has been finalized.
143
145
  * @type {boolean}
@@ -152,7 +154,7 @@ class MetaModel {
152
154
  * @type {MetaObject|null}
153
155
  */
154
156
  get rootMetaObject() {
155
- if (this.rootMetaObjects.length == 1) {
157
+ if (this.rootMetaObjects.length === 1) {
156
158
  return this.rootMetaObjects[0];
157
159
  }
158
160
  return null;
@@ -173,6 +175,12 @@ class MetaModel {
173
175
  const metaScene = this.metaScene;
174
176
  const propertyLookup = metaModelData.properties;
175
177
 
178
+ if (propertyLookup) {
179
+ for (let i = 0, len = propertyLookup.length; i < len; i++) {
180
+ this._propertyLookup.push(propertyLookup[i]);
181
+ }
182
+ }
183
+
176
184
  // Create global Property Sets
177
185
 
178
186
  if (metaModelData.propertySets) {
@@ -183,9 +191,6 @@ class MetaModel {
183
191
  }
184
192
  let propertySet = metaScene.propertySets[propertySetData.id];
185
193
  if (!propertySet) {
186
- if (propertyLookup) {
187
- this._decompressProperties(propertyLookup, propertySetData.properties);
188
- }
189
194
  propertySet = new PropertySet({
190
195
  id: propertySetData.id,
191
196
  originalSystemId: propertySetData.originalSystemId || propertySetData.id,
@@ -232,15 +237,21 @@ class MetaModel {
232
237
  }
233
238
 
234
239
  _decompressProperties(propertyLookup, properties) {
240
+ const propsNotFound = [];
235
241
  for (let i = 0, len = properties.length; i < len; i++) {
236
242
  const property = properties[i];
237
243
  if (Number.isInteger(property)) {
238
244
  const lookupProperty = propertyLookup[property];
239
245
  if (lookupProperty) {
240
246
  properties[i] = lookupProperty;
247
+ } else {
248
+ propsNotFound.push(property);
241
249
  }
242
250
  }
243
251
  }
252
+ if (propsNotFound.length > 0) {
253
+ console.error(`[MetaModel._decompressProperties] Properties not found: ${propsNotFound}`);
254
+ }
244
255
  }
245
256
 
246
257
  finalize() {
@@ -308,6 +319,18 @@ class MetaModel {
308
319
  (metaScene.metaObjectsByType[type] || (metaScene.metaObjectsByType[type] = {}))[objectId] = metaObject;
309
320
  }
310
321
 
322
+ // Decompress properties
323
+
324
+ if (this.propertySets) {
325
+ for (let i = 0, len = this.propertySets.length; i < len; i++) {
326
+ const propertySet = this.propertySets[i];
327
+ this._decompressProperties(this._propertyLookup, propertySet.properties);
328
+ }
329
+ }
330
+
331
+
332
+ this._propertyLookup = [];
333
+
311
334
  this.finalized = true;
312
335
 
313
336
  this.metaScene.fire("metaModelCreated", this.id);
@@ -68,7 +68,11 @@ class PropertySet {
68
68
  const properties = params.properties;
69
69
  for (let i = 0, len = properties.length; i < len; i++) {
70
70
  const property = properties[i];
71
- this.properties.push(new Property(property.name, property.value, property.type, property.valueType, property.description));
71
+ if (Number.isInteger(property)) { // Will decompress in MetaModel.finalize();
72
+ this.properties.push(property);
73
+ } else {
74
+ this.properties.push(new Property(property.name, property.value, property.type, property.valueType, property.description));
75
+ }
72
76
  }
73
77
  }
74
78
  }