@xeokit/xeokit-sdk 2.4.2-beta-22 → 2.4.2-beta-24

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.4.2-beta-22",
3
+ "version": "2.4.2-beta-24",
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",
@@ -57,7 +57,7 @@ class Viewer {
57
57
  * store geometry on the GPU for triangle meshes that don't have textures. This gives a much lower memory footprint for these types of model element. This mode may not perform well on low-end GPUs that are optimized
58
58
  * to use textures to hold geometry data. Works great on most medium/high-end GPUs found in desktop computers, including the nVIDIA and Intel HD chipsets. Set this false to use the default vertex buffer object (VBO)
59
59
  * mode for storing geometry, which is the standard technique used in most graphics engines, and will work adequately on most low-end GPUs.
60
- * @param {number} [cfg.numPreallocatedSectionPlanes=0] Enhances the efficiency of SectionPlane creation by proactively allocating Viewer resources for a specified quantity
60
+ * @param {number} [cfg.numCachedSectionPlanes=0] Enhances the efficiency of SectionPlane creation by proactively allocating Viewer resources for a specified quantity
61
61
  * of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
62
62
  * configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
63
63
  * responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
@@ -120,7 +120,7 @@ class Viewer {
120
120
  pbrEnabled: (!!cfg.pbrEnabled),
121
121
  colorTextureEnabled: (cfg.colorTextureEnabled !== false),
122
122
  dtxEnabled: (!!cfg.dtxEnabled),
123
- numPreallocatedSectionPlanes: cfg.numPreallocatedSectionPlanes
123
+ numCachedSectionPlanes: cfg.numCachedSectionPlanes
124
124
  });
125
125
 
126
126
  /**
@@ -185,7 +185,7 @@ export class TrianglesDataTextureDepthRenderer {
185
185
  this._uProjMatrix = program.getLocation("projMatrix");
186
186
  this._uSectionPlanes = [];
187
187
 
188
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
188
+ for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
189
189
  this._uSectionPlanes.push({
190
190
  active: program.getLocation("sectionPlaneActive" + i),
191
191
  pos: program.getLocation("sectionPlanePos" + i),
@@ -86,7 +86,7 @@ export class TrianglesDataTextureEdgesColorRenderer {
86
86
  gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix);
87
87
  gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix);
88
88
 
89
- const numSectionPlanes = scene._sectionPlanesState.sectionPlanes.length;
89
+ const numSectionPlanes = scene.getMaxSectionPlanes();
90
90
  if (numSectionPlanes > 0) {
91
91
  const sectionPlanes = scene._sectionPlanesState.sectionPlanes;
92
92
  const baseIndex = dataTextureLayer.layerIndex * numSectionPlanes;
@@ -193,7 +193,7 @@ export class TrianglesDataTextureEdgesRenderer {
193
193
  this._uViewMatrix = program.getLocation("viewMatrix");
194
194
  this._uProjMatrix = program.getLocation("projMatrix");
195
195
  this._uSectionPlanes = [];
196
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
196
+ for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
197
197
  this._uSectionPlanes.push({
198
198
  active: program.getLocation("sectionPlaneActive" + i),
199
199
  pos: program.getLocation("sectionPlanePos" + i),
@@ -166,7 +166,7 @@ export class TrianglesDataTexturePickMeshRenderer {
166
166
  this._uViewMatrix = program.getLocation("viewMatrix");
167
167
  this._uProjMatrix = program.getLocation("projMatrix");
168
168
  this._uSectionPlanes = [];
169
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
169
+ for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
170
170
  this._uSectionPlanes.push({
171
171
  active: program.getLocation("sectionPlaneActive" + i),
172
172
  pos: program.getLocation("sectionPlanePos" + i),
@@ -182,7 +182,7 @@ export class TrianglesDataTexturePickNormalsFlatRenderer {
182
182
  this._uViewMatrix = program.getLocation("viewMatrix");
183
183
  this._uProjMatrix = program.getLocation("projMatrix");
184
184
  this._uSectionPlanes = [];
185
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
185
+ for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
186
186
  this._uSectionPlanes.push({
187
187
  active: program.getLocation("sectionPlaneActive" + i),
188
188
  pos: program.getLocation("sectionPlanePos" + i),
@@ -203,7 +203,7 @@ export class TrianglesDataTextureSilhouetteRenderer {
203
203
  this._uViewMatrix = program.getLocation("viewMatrix");
204
204
  this._uProjMatrix = program.getLocation("projMatrix");
205
205
  this._uSectionPlanes = [];
206
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
206
+ for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
207
207
  this._uSectionPlanes.push({
208
208
  active: program.getLocation("sectionPlaneActive" + i),
209
209
  pos: program.getLocation("sectionPlanePos" + i),
@@ -190,7 +190,7 @@ export class TrianglesDataTextureSnapDepthBufInitRenderer {
190
190
  this._uViewMatrix = program.getLocation("viewMatrix");
191
191
  this._uProjMatrix = program.getLocation("projMatrix");
192
192
  this._uSectionPlanes = [];
193
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
193
+ for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
194
194
  this._uSectionPlanes.push({
195
195
  active: program.getLocation("sectionPlaneActive" + i),
196
196
  pos: program.getLocation("sectionPlanePos" + i),
@@ -196,7 +196,7 @@ export class TrianglesDataTextureSnapDepthRenderer {
196
196
  this._uViewMatrix = program.getLocation("viewMatrix");
197
197
  this._uProjMatrix = program.getLocation("projMatrix");
198
198
  this._uSectionPlanes = [];
199
- for (let i = 0, len = scene._sectionPlanesState.sectionPlanes.length; i < len; i++) {
199
+ for (let i = 0, len = scene.getMaxSectionPlanes(); i < len; i++) {
200
200
  this._uSectionPlanes.push({
201
201
  active: program.getLocation("sectionPlaneActive" + i),
202
202
  pos: program.getLocation("sectionPlanePos" + i),
@@ -340,7 +340,7 @@ class Scene extends Component {
340
340
  * @param {String} [cfg.canvasId] ID of an existing HTML canvas for the {@link Scene#canvas} - either this or canvasElement is mandatory. When both values are given, the element reference is always preferred to the ID.
341
341
  * @param {HTMLCanvasElement} [cfg.canvasElement] Reference of an existing HTML canvas for the {@link Scene#canvas} - either this or canvasId is mandatory. When both values are given, the element reference is always preferred to the ID.
342
342
  * @param {HTMLElement} [cfg.keyboardEventsElement] Optional reference to HTML element on which key events should be handled. Defaults to the HTML Document.
343
- * @param {number} [cfg.numPreallocatedSectionPlanes=0] Enhances the efficiency of SectionPlane creation by proactively allocating Viewer resources for a specified quantity
343
+ * @param {number} [cfg.numCachedSectionPlanes=0] Enhances the efficiency of SectionPlane creation by proactively allocating Viewer resources for a specified quantity
344
344
  * of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
345
345
  * configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
346
346
  * responsiveness. It is important to consider that each SectionPlane imposes rendering performance, so it is recommended to set this value to a quantity that aligns with
@@ -367,8 +367,6 @@ class Scene extends Component {
367
367
 
368
368
  this._aabbDirty = true;
369
369
 
370
- this._numPreallocatedSectionPlanes = cfg.numPreallocatedSectionPlanes || 0;
371
-
372
370
  /**
373
371
  * The {@link Viewer} this Scene belongs to.
374
372
  * @type {Viewer}
@@ -631,14 +629,14 @@ class Scene extends Component {
631
629
  alphaDepthMask: alphaDepthMask
632
630
  });
633
631
 
634
- const numPreallocatedSectionPlanes = this._numPreallocatedSectionPlanes;
635
-
636
632
  this._sectionPlanesState = new (function () {
637
633
 
638
634
  this.sectionPlanes = [];
639
635
 
640
636
  this.clippingCaps = false;
641
637
 
638
+ this._numCachedSectionPlanes = 0;
639
+
642
640
  let hash = null;
643
641
 
644
642
  this.getHash = function () {
@@ -677,12 +675,23 @@ class Scene extends Component {
677
675
  }
678
676
  };
679
677
 
678
+ this.setNumCachedSectionPlanes = function(numCachedSectionPlanes) {
679
+ this._numCachedSectionPlanes = numCachedSectionPlanes;
680
+ hash = null;
681
+ }
682
+
683
+ this.getNumCachedSectionPlanes = function() {
684
+ return this._numCachedSectionPlanes;
685
+ }
686
+
680
687
  this.getNumAllocatedSectionPlanes = function () {
681
688
  const num = this.sectionPlanes.length;
682
- return (num > numPreallocatedSectionPlanes) ? num : numPreallocatedSectionPlanes;
689
+ return (num > this._numCachedSectionPlanes) ? num : this._numCachedSectionPlanes;
683
690
  };
684
691
  })();
685
692
 
693
+ this._sectionPlanesState.setNumCachedSectionPlanes(cfg.numCachedSectionPlanes || 0);
694
+
686
695
  this._lightsState = new (function () {
687
696
 
688
697
  const DEFAULT_AMBIENT = math.vec4([0, 0, 0, 0]);
@@ -1258,12 +1267,44 @@ class Scene extends Component {
1258
1267
  return this._logarithmicDepthBufferEnabled;
1259
1268
  }
1260
1269
 
1270
+ /**
1271
+ * Sets the number of {@link SectionPlane}s for which this Scene pre-caches resources.
1272
+ *
1273
+ * This property enhances the efficiency of SectionPlane creation by proactively allocating and caching Viewer resources for a specified quantity
1274
+ * of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
1275
+ * configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
1276
+ * responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
1277
+ * your expected usage.
1278
+ *
1279
+ * Default is ````0````.
1280
+ */
1281
+ set numCachedSectionPlanes(numCachedSectionPlanes) {
1282
+ this._sectionPlanesState.setNumCachedSectionPlanes(numCachedSectionPlanes || 0);
1283
+ this._needRecompile = true;
1284
+ this.glRedraw();
1285
+ }
1286
+
1287
+ /**
1288
+ * Gets the number of {@link SectionPlane}s for which this Scene pre-caches resources.
1289
+ *
1290
+ * This property enhances the efficiency of SectionPlane creation by proactively allocating and caching Viewer resources for a specified quantity
1291
+ * of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
1292
+ * configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
1293
+ * responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
1294
+ * your expected usage.
1295
+ *
1296
+ * Default is ````0````.
1297
+ *
1298
+ * @returns {number} The number of {@link SectionPlane}s for which this Scene pre-caches resources.
1299
+ */
1300
+ get numCachedSectionPlanes() {
1301
+ return this._sectionPlanesState.getNumCachedSectionPlanes();
1302
+ }
1303
+
1261
1304
  /**
1262
1305
  * Sets whether physically-based rendering is enabled.
1263
1306
  *
1264
1307
  * Default is ````false````.
1265
- *
1266
- * @returns {Boolean} True if quality rendering is enabled.
1267
1308
  */
1268
1309
  set pbrEnabled(pbrEnabled) {
1269
1310
  this._pbrEnabled = !!pbrEnabled;