@xeokit/xeokit-sdk 2.2.1 → 2.2.5

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.
@@ -2716,30 +2716,6 @@ const math = {
2716
2716
  * @param z
2717
2717
  * @param m
2718
2718
  */
2719
- OLDtranslateMat4c(x, y, z, m) {
2720
-
2721
- const m12 = m[12];
2722
- m[0] += m12 * x;
2723
- m[4] += m12 * y;
2724
- m[8] += m12 * z;
2725
-
2726
- const m13 = m[13];
2727
- m[1] += m13 * x;
2728
- m[5] += m13 * y;
2729
- m[9] += m13 * z;
2730
-
2731
- const m14 = m[14];
2732
- m[2] += m14 * x;
2733
- m[6] += m14 * y;
2734
- m[10] += m14 * z;
2735
-
2736
- const m15 = m[15];
2737
- m[3] += m15 * x;
2738
- m[7] += m15 * y;
2739
- m[11] += m15 * z;
2740
-
2741
- return m;
2742
- },
2743
2719
 
2744
2720
  translateMat4c(x, y, z, m) {
2745
2721
 
@@ -8165,6 +8141,8 @@ class PerformanceNode {
8165
8141
  this._offsetAABB = math.AABB3(aabb);
8166
8142
 
8167
8143
  this._offset = math.vec3();
8144
+ this._colorizeUpdated = false;
8145
+ this._opacityUpdated = false;
8168
8146
 
8169
8147
  if (this._isObject) {
8170
8148
  model.scene._registerObject(this);
@@ -8577,6 +8555,7 @@ class PerformanceNode {
8577
8555
  if (this._isObject) {
8578
8556
  const colorized = (!!color);
8579
8557
  this.scene._objectColorizeUpdated(this, colorized);
8558
+ this._colorizeUpdated = colorized;
8580
8559
  }
8581
8560
  this.model.glRedraw();
8582
8561
  }
@@ -8631,6 +8610,7 @@ class PerformanceNode {
8631
8610
  }
8632
8611
  if (this._isObject) {
8633
8612
  this.scene._objectOpacityUpdated(this, opacityUpdated);
8613
+ this._opacityUpdated = opacityUpdated;
8634
8614
  }
8635
8615
  this.model.glRedraw();
8636
8616
  }
@@ -8777,8 +8757,12 @@ class PerformanceNode {
8777
8757
  if (this.highlighted) {
8778
8758
  scene._objectHighlightedUpdated(this);
8779
8759
  }
8780
- this.scene._objectColorizeUpdated(this, false);
8781
- this.scene._objectOpacityUpdated(this, false);
8760
+ if (this._opacityUpdated) {
8761
+ this.scene._objectColorizeUpdated(this, false);
8762
+ }
8763
+ if (this._opacityUpdated) {
8764
+ this.scene._objectOpacityUpdated(this, false);
8765
+ }
8782
8766
  this.scene._objectOffsetUpdated(this, false);
8783
8767
  }
8784
8768
  for (let i = 0, len = this.meshes.length; i < len; i++) {
@@ -12146,7 +12130,7 @@ class Canvas extends Component {
12146
12130
  * @event boundary
12147
12131
  * @param value The property's new value
12148
12132
  */
12149
- if (!newResolutionScale) {
12133
+ if (!newResolutionScale || newCanvasSize) {
12150
12134
  this.fire("boundary", boundary);
12151
12135
  }
12152
12136
 
@@ -15443,6 +15427,14 @@ const Renderer = function (scene, options) {
15443
15427
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
15444
15428
  };
15445
15429
 
15430
+ /**
15431
+ * Returns true if the next call to render() will draw something
15432
+ * @returns {boolean}
15433
+ */
15434
+ this.needsRender = function () {
15435
+ return (imageDirty || drawableListDirty || stateSortDirty);
15436
+ };
15437
+
15446
15438
  /**
15447
15439
  * Renders inserted drawables.
15448
15440
  * @private
@@ -15966,7 +15958,9 @@ const Renderer = function (scene, options) {
15966
15958
 
15967
15959
  if (highlightedFillOpaqueBinLen > 0 || highlightedEdgesOpaqueBinLen > 0) {
15968
15960
  frameCtx.lastProgramId = null;
15969
- gl.clear(gl.DEPTH_BUFFER_BIT);
15961
+ if ( scene.highlightMaterial.glowThrough) {
15962
+ gl.clear(gl.DEPTH_BUFFER_BIT);
15963
+ }
15970
15964
  if (highlightedEdgesOpaqueBinLen > 0) {
15971
15965
  for (i = 0; i < highlightedEdgesOpaqueBinLen; i++) {
15972
15966
  highlightedEdgesOpaqueBin[i].drawEdgesHighlighted(frameCtx);
@@ -15981,17 +15975,17 @@ const Renderer = function (scene, options) {
15981
15975
 
15982
15976
  if (highlightedFillTransparentBinLen > 0 || highlightedEdgesTransparentBinLen > 0 || highlightedFillOpaqueBinLen > 0) {
15983
15977
  frameCtx.lastProgramId = null;
15984
- gl.clear(gl.DEPTH_BUFFER_BIT);
15985
- gl.enable(gl.CULL_FACE);
15978
+ if (scene.selectedMaterial.glowThrough) {
15979
+ gl.clear(gl.DEPTH_BUFFER_BIT);
15980
+ }
15986
15981
  gl.enable(gl.BLEND);
15987
-
15988
15982
  if (canvasTransparent) {
15989
15983
  gl.blendEquation(gl.FUNC_ADD);
15990
15984
  gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
15991
15985
  } else {
15992
15986
  gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
15993
15987
  }
15994
-
15988
+ gl.enable(gl.CULL_FACE);
15995
15989
  if (highlightedEdgesTransparentBinLen > 0) {
15996
15990
  for (i = 0; i < highlightedEdgesTransparentBinLen; i++) {
15997
15991
  highlightedEdgesTransparentBin[i].drawEdgesHighlighted(frameCtx);
@@ -16007,7 +16001,9 @@ const Renderer = function (scene, options) {
16007
16001
 
16008
16002
  if (selectedFillOpaqueBinLen > 0 || selectedEdgesOpaqueBinLen > 0) {
16009
16003
  frameCtx.lastProgramId = null;
16010
- gl.clear(gl.DEPTH_BUFFER_BIT);
16004
+ if (scene.selectedMaterial.glowThrough) {
16005
+ gl.clear(gl.DEPTH_BUFFER_BIT);
16006
+ }
16011
16007
  if (selectedEdgesOpaqueBinLen > 0) {
16012
16008
  for (i = 0; i < selectedEdgesOpaqueBinLen; i++) {
16013
16009
  selectedEdgesOpaqueBin[i].drawEdgesSelected(frameCtx);
@@ -16022,10 +16018,11 @@ const Renderer = function (scene, options) {
16022
16018
 
16023
16019
  if (selectedFillTransparentBinLen > 0 || selectedEdgesTransparentBinLen > 0) {
16024
16020
  frameCtx.lastProgramId = null;
16025
- gl.clear(gl.DEPTH_BUFFER_BIT);
16021
+ if (scene.selectedMaterial.glowThrough) {
16022
+ gl.clear(gl.DEPTH_BUFFER_BIT);
16023
+ }
16026
16024
  gl.enable(gl.CULL_FACE);
16027
16025
  gl.enable(gl.BLEND);
16028
-
16029
16026
  if (canvasTransparent) {
16030
16027
  gl.blendEquation(gl.FUNC_ADD);
16031
16028
  gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
@@ -23170,6 +23167,7 @@ class EmphasisMaterial extends Material {
23170
23167
  * @param {Number} [cfg.edgeWidth=1] Width of xray edges, in pixels.
23171
23168
  * @param {String} [cfg.preset] Selects a preset EmphasisMaterial configuration - see {@link EmphasisMaterial#presets}.
23172
23169
  * @param {Boolean} [cfg.backfaces=false] Whether to render geometry backfaces when emphasising.
23170
+ * @param {Boolean} [cfg.glowThrough=true] Whether to make the emphasized object appear to float on top of other objects, as if it were "glowing through" them.
23173
23171
  */
23174
23172
  constructor(owner, cfg = {}) {
23175
23173
 
@@ -23184,7 +23182,8 @@ class EmphasisMaterial extends Material {
23184
23182
  edgeColor: null,
23185
23183
  edgeAlpha: null,
23186
23184
  edgeWidth: null,
23187
- backfaces: true
23185
+ backfaces: true,
23186
+ glowThrough: true
23188
23187
  });
23189
23188
 
23190
23189
  this._preset = "default";
@@ -23215,6 +23214,9 @@ class EmphasisMaterial extends Material {
23215
23214
  if (cfg.backfaces !== undefined) {
23216
23215
  this.backfaces = cfg.backfaces;
23217
23216
  }
23217
+ if (cfg.glowThrough !== undefined) {
23218
+ this.glowThrough = cfg.glowThrough;
23219
+ }
23218
23220
  } else {
23219
23221
  this.fill = cfg.fill;
23220
23222
  this.fillColor = cfg.fillColor;
@@ -23224,6 +23226,7 @@ class EmphasisMaterial extends Material {
23224
23226
  this.edgeAlpha = cfg.edgeAlpha;
23225
23227
  this.edgeWidth = cfg.edgeWidth;
23226
23228
  this.backfaces = cfg.backfaces;
23229
+ this.glowThrough = cfg.glowThrough;
23227
23230
  }
23228
23231
  }
23229
23232
 
@@ -23445,7 +23448,7 @@ class EmphasisMaterial extends Material {
23445
23448
  }
23446
23449
 
23447
23450
  /**
23448
- * Sets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````..
23451
+ * Sets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````.
23449
23452
  *
23450
23453
  * Default is ````false````.
23451
23454
  *
@@ -23461,9 +23464,9 @@ class EmphasisMaterial extends Material {
23461
23464
  }
23462
23465
 
23463
23466
  /**
23464
- * Gets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````..
23467
+ * Gets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````.
23465
23468
  *
23466
- * Default is ````false````.
23469
+ * Default is ````true````.
23467
23470
  *
23468
23471
  * @type {Boolean}
23469
23472
  */
@@ -23471,6 +23474,35 @@ class EmphasisMaterial extends Material {
23471
23474
  return this._state.backfaces;
23472
23475
  }
23473
23476
 
23477
+ /**
23478
+ * Sets whether to render emphasized objects over the top of other objects, as if they were "glowing through".
23479
+ *
23480
+ * Default is ````true````.
23481
+ *
23482
+ * Note: updating this property will not affect the appearance of objects that are already emphasized.
23483
+ *
23484
+ * @type {Boolean}
23485
+ */
23486
+ set glowThrough(value) {
23487
+ value = (value !== false);
23488
+ if (this._state.glowThrough === value) {
23489
+ return;
23490
+ }
23491
+ this._state.glowThrough = value;
23492
+ this.glRedraw();
23493
+ }
23494
+
23495
+ /**
23496
+ * Sets whether to render emphasized objects over the top of other objects, as if they were "glowing through".
23497
+ *
23498
+ * Default is ````true````.
23499
+ *
23500
+ * @type {Boolean}
23501
+ */
23502
+ get glowThrough() {
23503
+ return this._state.glowThrough;
23504
+ }
23505
+
23474
23506
  /**
23475
23507
  * Selects a preset EmphasisMaterial configuration.
23476
23508
  *
@@ -23495,6 +23527,7 @@ class EmphasisMaterial extends Material {
23495
23527
  this.edgeColor = preset.edgeColor;
23496
23528
  this.edgeAlpha = preset.edgeAlpha;
23497
23529
  this.edgeWidth = preset.edgeWidth;
23530
+ this.glowThrough = preset.glowThrough;
23498
23531
  this._preset = value;
23499
23532
  }
23500
23533
 
@@ -26426,6 +26459,10 @@ class Scene extends Component {
26426
26459
  this._needRecompile = false;
26427
26460
  }
26428
26461
 
26462
+ if (!forceRender && !this._renderer.needsRender()) {
26463
+ return;
26464
+ }
26465
+
26429
26466
  renderEvent.sceneId = this.id;
26430
26467
 
26431
26468
  const passes = this._passes;
@@ -27374,7 +27411,7 @@ class Scene extends Component {
27374
27411
  * registered by {@link Entity#id} in {@link Scene#visibleObjects}.
27375
27412
  *
27376
27413
  * @param {String[]} ids Array of {@link Entity#id} values.
27377
- * @param {Boolean} visible Whether or not to cull.
27414
+ * @param {Boolean} visible Whether or not to set visible.
27378
27415
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27379
27416
  */
27380
27417
  setObjectsVisible(ids, visible) {
@@ -27391,7 +27428,7 @@ class Scene extends Component {
27391
27428
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27392
27429
  *
27393
27430
  * @param {String[]} ids Array of {@link Entity#id} values.
27394
- * @param {Boolean} collidable Whether or not to cull.
27431
+ * @param {Boolean} collidable Whether or not to set collidable.
27395
27432
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27396
27433
  */
27397
27434
  setObjectsCollidable(ids, collidable) {
@@ -27428,7 +27465,7 @@ class Scene extends Component {
27428
27465
  * registered by {@link Entity#id} in {@link Scene#selectedObjects}.
27429
27466
  *
27430
27467
  * @param {String[]} ids Array of {@link Entity#id} values.
27431
- * @param {Boolean} selected Whether or not to highlight.
27468
+ * @param {Boolean} selected Whether or not to select.
27432
27469
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27433
27470
  */
27434
27471
  setObjectsSelected(ids, selected) {
@@ -27464,9 +27501,6 @@ class Scene extends Component {
27464
27501
  *
27465
27502
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27466
27503
  *
27467
- * Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#xrayed} are ````true```` is
27468
- * registered by {@link Entity#id} in {@link Scene#xrayedObjects}.
27469
- *
27470
27504
  * @param {String[]} ids Array of {@link Entity#id} values.
27471
27505
  * @param {Boolean} xrayed Whether or not to xray.
27472
27506
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
@@ -27534,7 +27568,7 @@ class Scene extends Component {
27534
27568
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27535
27569
  *
27536
27570
  * @param {String[]} ids Array of {@link Entity#id} values.
27537
- * @param {Boolean} pickable Whether or not to enable picking.
27571
+ * @param {Boolean} pickable Whether or not to set pickable.
27538
27572
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27539
27573
  */
27540
27574
  setObjectsPickable(ids, pickable) {
@@ -27560,13 +27594,10 @@ class Scene extends Component {
27560
27594
  }
27561
27595
 
27562
27596
  /**
27563
- * Iterates with a callback over {@link Entity#visible} on {@link Entity}s that represent objects.
27597
+ * Iterates with a callback over {@link Entity}s that represent objects.
27564
27598
  *
27565
27599
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27566
27600
  *
27567
- * Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#visible} are ````true```` is
27568
- * registered by {@link Entity#id} in {@link Scene#visibleObjects}.
27569
- *
27570
27601
  * @param {String[]} ids Array of {@link Entity#id} values.
27571
27602
  * @param {Function} callback Callback to execute on eacn {@link Entity}.
27572
27603
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
@@ -46537,7 +46568,7 @@ class TrianglesBatchingLayer {
46537
46568
  // Color
46538
46569
 
46539
46570
  let f0;
46540
- if (!visible || culled || xrayed) { // Highlight & select are layered on top of color - not mutually exclusive
46571
+ if (!visible || culled || xrayed || (highlighted && !this.model.scene.highlightMaterial.glowThrough) || (selected && !this.model.scene.selectedMaterial.glowThrough)) { // Highlight & select are layered on top of color - not mutually exclusive
46541
46572
  f0 = RENDER_PASSES.NOT_RENDERED;
46542
46573
  } else {
46543
46574
  if (transparent) {
@@ -53654,7 +53685,7 @@ class TrianglesInstancingLayer {
53654
53685
  // Normal fill
53655
53686
 
53656
53687
  let f0;
53657
- if (!visible || culled || xrayed) { // Highlight & select are layered on top of color - not mutually exclusive
53688
+ if (!visible || culled || xrayed || (highlighted && !this.model.scene.highlightMaterial.glowThrough) || (selected && !this.model.scene.selectedMaterial.glowThrough)) { // Highlight & select are layered on top of color - not mutually exclusive
53658
53689
  f0 = RENDER_PASSES.NOT_RENDERED;
53659
53690
  } else {
53660
53691
  if (meshTransparent) {
@@ -55404,7 +55435,7 @@ class LinesBatchingLayer {
55404
55435
  // Color
55405
55436
 
55406
55437
  let f0;
55407
- if (!visible || culled || xrayed) {
55438
+ if (!visible || culled || xrayed || (highlighted && !this.model.scene.highlightMaterial.glowThrough) || (selected && !this.model.scene.selectedMaterial.glowThrough)) { // Highlight & select are layered on top of color - not mutually exclusive
55408
55439
  f0 = RENDER_PASSES.NOT_RENDERED;
55409
55440
  } else {
55410
55441
  if (transparent) {
@@ -56871,7 +56902,7 @@ class LinesInstancingLayer {
56871
56902
  // Normal fill
56872
56903
 
56873
56904
  let f0;
56874
- if (!visible || culled || xrayed) {
56905
+ if (!visible || culled || xrayed || (highlighted && !this.model.scene.highlightMaterial.glowThrough) || (selected && !this.model.scene.selectedMaterial.glowThrough)) { // Highlight & select are layered on top of color - not mutually exclusive
56875
56906
  f0 = RENDER_PASSES.NOT_RENDERED;
56876
56907
  } else {
56877
56908
  if (meshTransparent) {
@@ -59437,7 +59468,7 @@ class PointsBatchingLayer {
59437
59468
  // Normal fill
59438
59469
 
59439
59470
  let f0;
59440
- if (!visible || culled || xrayed) {
59471
+ if (!visible || culled || xrayed || (highlighted && !this.model.scene.highlightMaterial.glowThrough) || (selected && !this.model.scene.selectedMaterial.glowThrough)) { // Highlight & select are layered on top of color - not mutually exclusive
59441
59472
  f0 = RENDER_PASSES.NOT_RENDERED;
59442
59473
  } else {
59443
59474
  if (transparent) {
@@ -62830,7 +62861,7 @@ class PointsInstancingLayer {
62830
62861
  // Normal fill
62831
62862
 
62832
62863
  let f0;
62833
- if (!visible || culled || xrayed) {
62864
+ if (!visible || culled || xrayed || (highlighted && !this.model.scene.highlightMaterial.glowThrough) || (selected && !this.model.scene.selectedMaterial.glowThrough)) { // Highlight & select are layered on top of color - not mutually exclusive
62834
62865
  f0 = RENDER_PASSES.NOT_RENDERED;
62835
62866
  } else {
62836
62867
  if (meshTransparent) {