@xeokit/xeokit-sdk 2.6.19 → 2.6.22

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.19",
3
+ "version": "2.6.22",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -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
  }
@@ -2289,8 +2289,6 @@ class Scene extends Component {
2289
2289
  * @param {Number[]} [params.origin] World-space ray origin when ray-picking. Ignored when canvasPos given.
2290
2290
  * @param {Number[]} [params.direction] World-space ray direction when ray-picking. Also indicates the length of the ray. Ignored when canvasPos given.
2291
2291
  * @param {Number[]} [params.matrix] 4x4 transformation matrix to define the World-space ray origin and direction, as an alternative to ````origin```` and ````direction````.
2292
- * @param {String[]} [params.includeEntities] IDs of {@link Entity}s to restrict picking to. When given, ignores {@link Entity}s whose IDs are not in this list.
2293
- * @param {String[]} [params.excludeEntities] IDs of {@link Entity}s to ignore. When given, will pick *through* these {@link Entity}s, as if they were not there.
2294
2292
  * @param {Number} [params.snapRadius=30] The snap radius, in canvas pixels.
2295
2293
  * @param {boolean} [params.snapToVertex=true] Whether to snap to vertex. Only works when `canvasPos` given.
2296
2294
  * @param {boolean} [params.snapToEdge=true] Whether to snap to edge. Only works when `canvasPos` given.
@@ -32,9 +32,6 @@ const Renderer = function (scene, options) {
32
32
  let drawableTypeInfo = {};
33
33
  let drawables = {};
34
34
 
35
- let postSortDrawableList = [];
36
- let postCullDrawableList = [];
37
-
38
35
  let drawableListDirty = true;
39
36
  let stateSortDirty = true;
40
37
  let imageDirty = true;
@@ -272,38 +269,28 @@ const Renderer = function (scene, options) {
272
269
  const drawableInfo = drawableTypeInfo[type];
273
270
  if (drawableInfo.isStateSortable) {
274
271
  drawableInfo.drawableListPreCull.sort(drawableInfo.stateSortCompare);
275
-
276
- drawableInfo.drawableList = drawableInfo.drawableListPreCull;
277
272
  }
278
273
  }
279
274
  }
280
- let lenDrawableList = 0;
275
+ }
276
+
277
+ function cullDrawableList() {
281
278
  for (let type in drawableTypeInfo) {
282
279
  if (drawableTypeInfo.hasOwnProperty(type)) {
283
280
  const drawableInfo = drawableTypeInfo[type];
284
281
  const drawableListPreCull = drawableInfo.drawableListPreCull;
282
+ const drawableList = drawableInfo.drawableList;
283
+ let lenDrawableList = 0;
285
284
  for (let i = 0, len = drawableListPreCull.length; i < len; i++) {
286
285
  const drawable = drawableListPreCull[i];
287
- postSortDrawableList[lenDrawableList++] = drawable;
286
+ drawable.rebuildRenderFlags();
287
+ if (!drawable.renderFlags.culled) {
288
+ drawableList[lenDrawableList++] = drawable;
289
+ }
288
290
  }
291
+ drawableList.length = lenDrawableList;
289
292
  }
290
293
  }
291
- postSortDrawableList.length = lenDrawableList;
292
- postSortDrawableList.sort((a, b) => {
293
- return a.renderOrder - b.renderOrder;
294
- });
295
- }
296
-
297
- function cullDrawableList() {
298
- let lenDrawableList = 0;
299
- for (let i = 0, len = postSortDrawableList.length; i < len; i++) {
300
- const drawable = postSortDrawableList[i];
301
- drawable.rebuildRenderFlags();
302
- if (!drawable.renderFlags.culled) {
303
- postCullDrawableList[lenDrawableList++] = drawable;
304
- }
305
- }
306
- postCullDrawableList.length = lenDrawableList;
307
294
  }
308
295
 
309
296
  function draw(params) {
@@ -580,85 +567,93 @@ const Renderer = function (scene, options) {
580
567
  // Render normal opaque solids, defer others to bins to render after
581
568
  //------------------------------------------------------------------------------------------------------
582
569
 
583
- for (let i = 0, len = postCullDrawableList.length; i < len; i++) {
570
+ for (let type in drawableTypeInfo) {
571
+ if (drawableTypeInfo.hasOwnProperty(type)) {
584
572
 
585
- drawable = postCullDrawableList[i];
573
+ const drawableInfo = drawableTypeInfo[type];
574
+ const drawableList = drawableInfo.drawableList;
586
575
 
587
- if (drawable.culled === true || drawable.visible === false) {
588
- continue;
589
- }
576
+ for (i = 0, len = drawableList.length; i < len; i++) {
590
577
 
591
- const renderFlags = drawable.renderFlags;
578
+ drawable = drawableList[i];
592
579
 
593
- if (renderFlags.colorOpaque) {
594
- if (saoEnabled && saoPossible && drawable.saoEnabled) {
595
- normalDrawSAOBin[normalDrawSAOBinLen++] = drawable;
596
- } else {
597
- drawable.drawColorOpaque(frameCtx);
598
- }
599
- }
580
+ if (drawable.culled === true || drawable.visible === false) {
581
+ continue;
582
+ }
600
583
 
601
- if (transparentEnabled) {
602
- if (renderFlags.colorTransparent) {
603
- normalFillTransparentBin[normalFillTransparentBinLen++] = drawable;
604
- }
605
- }
584
+ const renderFlags = drawable.renderFlags;
606
585
 
607
- if (renderFlags.xrayedSilhouetteTransparent) {
608
- xrayedFillTransparentBin[xrayedFillTransparentBinLen++] = drawable;
609
- }
586
+ if (renderFlags.colorOpaque) {
587
+ if (saoEnabled && saoPossible && drawable.saoEnabled) {
588
+ normalDrawSAOBin[normalDrawSAOBinLen++] = drawable;
589
+ } else {
590
+ drawable.drawColorOpaque(frameCtx);
591
+ }
592
+ }
610
593
 
611
- if (renderFlags.xrayedSilhouetteOpaque) {
612
- xrayedFillOpaqueBin[xrayedFillOpaqueBinLen++] = drawable;
613
- }
594
+ if (transparentEnabled) {
595
+ if (renderFlags.colorTransparent) {
596
+ normalFillTransparentBin[normalFillTransparentBinLen++] = drawable;
597
+ }
598
+ }
614
599
 
615
- if (renderFlags.highlightedSilhouetteTransparent) {
616
- highlightedFillTransparentBin[highlightedFillTransparentBinLen++] = drawable;
617
- }
600
+ if (renderFlags.xrayedSilhouetteTransparent) {
601
+ xrayedFillTransparentBin[xrayedFillTransparentBinLen++] = drawable;
602
+ }
618
603
 
619
- if (renderFlags.highlightedSilhouetteOpaque) {
620
- highlightedFillOpaqueBin[highlightedFillOpaqueBinLen++] = drawable;
621
- }
604
+ if (renderFlags.xrayedSilhouetteOpaque) {
605
+ xrayedFillOpaqueBin[xrayedFillOpaqueBinLen++] = drawable;
606
+ }
622
607
 
623
- if (renderFlags.selectedSilhouetteTransparent) {
624
- selectedFillTransparentBin[selectedFillTransparentBinLen++] = drawable;
625
- }
608
+ if (renderFlags.highlightedSilhouetteTransparent) {
609
+ highlightedFillTransparentBin[highlightedFillTransparentBinLen++] = drawable;
610
+ }
626
611
 
627
- if (renderFlags.selectedSilhouetteOpaque) {
628
- selectedFillOpaqueBin[selectedFillOpaqueBinLen++] = drawable;
629
- }
612
+ if (renderFlags.highlightedSilhouetteOpaque) {
613
+ highlightedFillOpaqueBin[highlightedFillOpaqueBinLen++] = drawable;
614
+ }
630
615
 
631
- if (drawable.edges && edgesEnabled) {
632
- if (renderFlags.edgesOpaque) {
633
- normalEdgesOpaqueBin[normalEdgesOpaqueBinLen++] = drawable;
634
- }
616
+ if (renderFlags.selectedSilhouetteTransparent) {
617
+ selectedFillTransparentBin[selectedFillTransparentBinLen++] = drawable;
618
+ }
635
619
 
636
- if (renderFlags.edgesTransparent) {
637
- normalEdgesTransparentBin[normalEdgesTransparentBinLen++] = drawable;
638
- }
620
+ if (renderFlags.selectedSilhouetteOpaque) {
621
+ selectedFillOpaqueBin[selectedFillOpaqueBinLen++] = drawable;
622
+ }
639
623
 
640
- if (renderFlags.selectedEdgesTransparent) {
641
- selectedEdgesTransparentBin[selectedEdgesTransparentBinLen++] = drawable;
642
- }
624
+ if (drawable.edges && edgesEnabled) {
625
+ if (renderFlags.edgesOpaque) {
626
+ normalEdgesOpaqueBin[normalEdgesOpaqueBinLen++] = drawable;
627
+ }
643
628
 
644
- if (renderFlags.selectedEdgesOpaque) {
645
- selectedEdgesOpaqueBin[selectedEdgesOpaqueBinLen++] = drawable;
646
- }
629
+ if (renderFlags.edgesTransparent) {
630
+ normalEdgesTransparentBin[normalEdgesTransparentBinLen++] = drawable;
631
+ }
647
632
 
648
- if (renderFlags.xrayedEdgesTransparent) {
649
- xrayEdgesTransparentBin[xrayEdgesTransparentBinLen++] = drawable;
650
- }
633
+ if (renderFlags.selectedEdgesTransparent) {
634
+ selectedEdgesTransparentBin[selectedEdgesTransparentBinLen++] = drawable;
635
+ }
651
636
 
652
- if (renderFlags.xrayedEdgesOpaque) {
653
- xrayEdgesOpaqueBin[xrayEdgesOpaqueBinLen++] = drawable;
654
- }
637
+ if (renderFlags.selectedEdgesOpaque) {
638
+ selectedEdgesOpaqueBin[selectedEdgesOpaqueBinLen++] = drawable;
639
+ }
655
640
 
656
- if (renderFlags.highlightedEdgesTransparent) {
657
- highlightedEdgesTransparentBin[highlightedEdgesTransparentBinLen++] = drawable;
658
- }
641
+ if (renderFlags.xrayedEdgesTransparent) {
642
+ xrayEdgesTransparentBin[xrayEdgesTransparentBinLen++] = drawable;
643
+ }
644
+
645
+ if (renderFlags.xrayedEdgesOpaque) {
646
+ xrayEdgesOpaqueBin[xrayEdgesOpaqueBinLen++] = drawable;
647
+ }
659
648
 
660
- if (renderFlags.highlightedEdgesOpaque) {
661
- highlightedEdgesOpaqueBin[highlightedEdgesOpaqueBinLen++] = drawable;
649
+ if (renderFlags.highlightedEdgesTransparent) {
650
+ highlightedEdgesTransparentBin[highlightedEdgesTransparentBinLen++] = drawable;
651
+ }
652
+
653
+ if (renderFlags.highlightedEdgesOpaque) {
654
+ highlightedEdgesOpaqueBin[highlightedEdgesOpaqueBinLen++] = drawable;
655
+ }
656
+ }
662
657
  }
663
658
  }
664
659
  }