@xeokit/xeokit-sdk 2.6.87-renderers-refactor-v3 → 2.6.87-renderers-refactor-v4

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.87-renderers-refactor-v3",
3
+ "version": "2.6.87-renderers-refactor-v4",
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",
@@ -2995,7 +2995,7 @@ export class SceneModel extends Component {
2995
2995
  const primitive = instancing ? geometry.primitive : cfg.primitive;
2996
2996
  const origin = cfg.origin;
2997
2997
  const posDecode = (! instancing) && (cfg.positionsDecodeMatrix || cfg.positionsDecodeBoundary);
2998
- const positionsDecodeHash = posDecode ? (JSON.stringify(posDecode).split("").reduce((hash, char) => (((hash << 5) - hash + char.charCodeAt(0)) | 0), 0) >>> 0).toString(16) : "-";
2998
+ const positionsDecodeHash = posDecode ? this._createHashStringFromMatrix(posDecode) : "-";
2999
2999
  const textureSetId = cfg.textureSetId || "-";
3000
3000
  const geometryId = instancing ? cfg.geometryId : "-";
3001
3001
  const layerId = (instancing ? "instancing" : "batching") + `.${Math.round(origin[0])}.${Math.round(origin[1])}.${Math.round(origin[2])}.${primitive}.${positionsDecodeHash}.${textureSetId}.${geometryId}`;
@@ -3027,6 +3027,18 @@ export class SceneModel extends Component {
3027
3027
  return this._vboLayers[layerId];
3028
3028
  }
3029
3029
 
3030
+ _createHashStringFromMatrix(matrix) {
3031
+ const matrixString = matrix.join(";");
3032
+ let hash = 0;
3033
+ for (let i = 0; i < matrixString.length; i++) {
3034
+ const char = matrixString.charCodeAt(i);
3035
+ hash = (hash << 5) - hash + char;
3036
+ hash |= 0; // Convert to 32-bit integer
3037
+ }
3038
+ const hashString = (hash >>> 0).toString(16);
3039
+ return hashString;
3040
+ }
3041
+
3030
3042
  /**
3031
3043
  * Creates a {@link SceneModelEntity} within this SceneModel.
3032
3044
  *
@@ -497,6 +497,8 @@ export class Layer {
497
497
  setupFlagCount(ENTITY_FLAGS.EDGES, "numEdgesLayerPortions");
498
498
  }
499
499
 
500
+ // Optimize initFlags to not require Object.values call each time (adds up a lot)
501
+ this._countsByFlagArr = Object.values(this._countsByFlag);
500
502
  this._numTransparentLayerPortions = 0;
501
503
  }
502
504
  }
@@ -709,7 +711,7 @@ export class Layer {
709
711
 
710
712
 
711
713
  initFlags(portionId, flags, transparent) {
712
- Object.values(this._countsByFlag).forEach(cnt => cnt.fromFlags(flags, true));
714
+ this._countsByFlagArr.forEach(cnt => cnt.fromFlags(flags, true));
713
715
 
714
716
  if (transparent) {
715
717
  this._numTransparentLayerPortions++;