@xeokit/xeokit-sdk 2.6.100 → 2.6.101

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.100",
3
+ "version": "2.6.101",
4
4
  "description": "3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -37,9 +37,9 @@ const createPositionsDecodeMatrix = (function () {
37
37
  const xmin = aabb[0];
38
38
  const ymin = aabb[1];
39
39
  const zmin = aabb[2];
40
- const xwid = aabb[3] - xmin;
41
- const ywid = aabb[4] - ymin;
42
- const zwid = aabb[5] - zmin;
40
+ const xwid = (aabb[3] - xmin) || 1;
41
+ const ywid = (aabb[4] - ymin) || 1;
42
+ const zwid = (aabb[5] - zmin) || 1;
43
43
  const maxInt = 65535;
44
44
  math.identityMat4(translate);
45
45
  math.translationMat4v(aabb, translate);
@@ -362,4 +362,4 @@ const geometryCompressionUtils = {
362
362
  decompressNormal: decompressNormal
363
363
  };
364
364
 
365
- export {geometryCompressionUtils};
365
+ export {geometryCompressionUtils};
@@ -549,6 +549,25 @@ const math = {
549
549
  return dest;
550
550
  },
551
551
 
552
+ /**
553
+ * Multiplies one three-element vector by another.
554
+ * @method mulVec3
555
+ * @static
556
+ * @param {Array(Number)} u First vector
557
+ * @param {Array(Number)} v Second vector
558
+ * @param {Array(Number)} [dest] Destination vector
559
+ * @return {Array(Number)} dest if specified, u otherwise
560
+ */
561
+ mulVec3(u, v, dest) {
562
+ if (!dest) {
563
+ dest = u;
564
+ }
565
+ dest[0] = u[0] * v[0];
566
+ dest[1] = u[1] * v[1];
567
+ dest[2] = u[2] * v[2];
568
+ return dest;
569
+ },
570
+
552
571
  /**
553
572
  * Multiplies one four-element vector by another.
554
573
  * @method mulVec4
@@ -208,7 +208,9 @@ export class DTXLayer extends Layer {
208
208
  }
209
209
  }
210
210
  };
211
- }
211
+ },
212
+
213
+ _clearToOptimizeGC: () => { indicesBuffer.length = edgeIndicesBuffer.length = 0; }
212
214
  };
213
215
  };
214
216
 
@@ -509,7 +511,14 @@ export class DTXLayer extends Layer {
509
511
  const draw16 = buffer.geometry16Bits.createDrawers(createTextureForSingleItems, gl.UNSIGNED_SHORT);
510
512
  const draw32 = buffer.geometry32Bits.createDrawers(createTextureForSingleItems, gl.UNSIGNED_INT);
511
513
 
512
- // Free up memory
514
+ // Optimization to free up memory (XCD-408 and XCD-424).
515
+ // The following lines were added to assist GC in cleaning up some of the data. See also the `texArray = null`.
516
+ // A Chrome test with Lyon[1-9].xkt models loaded simultaneously showed a decrease of 596MB to 158MB.
517
+ this._bucketGeometries = null;
518
+ this._buffer.geometry8Bits._clearToOptimizeGC();
519
+ this._buffer.geometry16Bits._clearToOptimizeGC();
520
+ this._buffer.geometry32Bits._clearToOptimizeGC();
521
+ Object.keys(this._buffer).forEach(k => this._buffer[k] = null);
513
522
  this._buffer = null;
514
523
 
515
524
  let deferredSetFlagsActive = false;
@@ -720,7 +729,7 @@ const createBindableDataTexture = function(gl, entitiesCnt, entitySize, type, en
720
729
  if (textureHeight === 0) {
721
730
  throw "texture height===0";
722
731
  }
723
- const texArray = new arrayType(textureWidth * textureHeight * pixelWidth);
732
+ let texArray = new arrayType(textureWidth * textureHeight * pixelWidth);
724
733
  dataTextureRamStats[statsProp] += texArray.byteLength;
725
734
  dataTextureRamStats.numberOfTextures++;
726
735
 
@@ -736,6 +745,10 @@ const createBindableDataTexture = function(gl, entitiesCnt, entitySize, type, en
736
745
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
737
746
  gl.bindTexture(gl.TEXTURE_2D, null);
738
747
 
748
+ if (! exposeData) {
749
+ texArray = null; // See the comment related to XCD-408 and XCD-424 above.
750
+ }
751
+
739
752
  return {
740
753
  // called by createSampler::bindTexture
741
754
  bind(unit) {
@@ -150,7 +150,8 @@ export class VBOLayer extends Layer {
150
150
  });
151
151
 
152
152
  return buf;
153
- }
153
+ },
154
+ _clearToOptimizeGC: () => { portions.length = 0; }
154
155
  };
155
156
  };
156
157
 
@@ -477,12 +478,13 @@ export class VBOLayer extends Layer {
477
478
  : (quantizePositions(buffer.positions.compileBuffer(Float64Array), modelAABB, positionsDecodeMatrix = math.mat4()))));
478
479
  const positionsBuf = positions && maybeCreateBuffer(positions, 3, gl.STATIC_DRAW);
479
480
  if (! instancing) {
480
- portions.forEach(portion => {
481
- if (portion.retainedGeometry) {
481
+ for (let i = 0; i < portions.length; ++i) { // WARNING: Replacing this for-loop by forEach increases memory consumption
482
+ const portion = portions[i]; // by not GCing `positions` arr, even if portion.retainedGeometry is false.
483
+ if (portion.retainedGeometry) { // See the comment related to XCD-408 and XCD-424 below.
482
484
  const start = 3 * portion.portionBase;
483
485
  portion.retainedGeometry.quantizedPositions = positions.subarray(start, start + 3 * portion.portionSize);
484
486
  }
485
- });
487
+ }
486
488
  }
487
489
 
488
490
  const modelMatrixColBufs = instancing && buffer.modelMatrixCol.map(b => maybeCreateBuffer(b.compileBuffer(Float32Array), 4, gl.STATIC_DRAW, true));
@@ -521,6 +523,10 @@ export class VBOLayer extends Layer {
521
523
  })());
522
524
 
523
525
  // Free up memory
526
+ // Optimization to free up memory (XCD-408 and XCD-424)
527
+ // The following line was added to assist GC in cleaning up some of the data. See also the `portions` loop above.
528
+ // A Chrome test with Lyon[1-9].xkt models loaded simultaneously showed a decrease of 538MB to 143MB.
529
+ Object.values(this._buffer).forEach(a => a._clearToOptimizeGC ? a._clearToOptimizeGC() : a.forEach(a => a._clearToOptimizeGC()));
524
530
  this._buffer = null;
525
531
 
526
532
  scratchMemory.acquire();