@xeokit/xeokit-sdk 2.2.3 → 2.2.5-beta-1

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.
@@ -2720,30 +2720,6 @@ const math = {
2720
2720
  * @param z
2721
2721
  * @param m
2722
2722
  */
2723
- OLDtranslateMat4c(x, y, z, m) {
2724
-
2725
- const m12 = m[12];
2726
- m[0] += m12 * x;
2727
- m[4] += m12 * y;
2728
- m[8] += m12 * z;
2729
-
2730
- const m13 = m[13];
2731
- m[1] += m13 * x;
2732
- m[5] += m13 * y;
2733
- m[9] += m13 * z;
2734
-
2735
- const m14 = m[14];
2736
- m[2] += m14 * x;
2737
- m[6] += m14 * y;
2738
- m[10] += m14 * z;
2739
-
2740
- const m15 = m[15];
2741
- m[3] += m15 * x;
2742
- m[7] += m15 * y;
2743
- m[11] += m15 * z;
2744
-
2745
- return m;
2746
- },
2747
2723
 
2748
2724
  translateMat4c(x, y, z, m) {
2749
2725
 
@@ -8169,6 +8145,8 @@ class PerformanceNode {
8169
8145
  this._offsetAABB = math.AABB3(aabb);
8170
8146
 
8171
8147
  this._offset = math.vec3();
8148
+ this._colorizeUpdated = false;
8149
+ this._opacityUpdated = false;
8172
8150
 
8173
8151
  if (this._isObject) {
8174
8152
  model.scene._registerObject(this);
@@ -8581,6 +8559,7 @@ class PerformanceNode {
8581
8559
  if (this._isObject) {
8582
8560
  const colorized = (!!color);
8583
8561
  this.scene._objectColorizeUpdated(this, colorized);
8562
+ this._colorizeUpdated = colorized;
8584
8563
  }
8585
8564
  this.model.glRedraw();
8586
8565
  }
@@ -8635,6 +8614,7 @@ class PerformanceNode {
8635
8614
  }
8636
8615
  if (this._isObject) {
8637
8616
  this.scene._objectOpacityUpdated(this, opacityUpdated);
8617
+ this._opacityUpdated = opacityUpdated;
8638
8618
  }
8639
8619
  this.model.glRedraw();
8640
8620
  }
@@ -8781,8 +8761,12 @@ class PerformanceNode {
8781
8761
  if (this.highlighted) {
8782
8762
  scene._objectHighlightedUpdated(this);
8783
8763
  }
8784
- this.scene._objectColorizeUpdated(this, false);
8785
- this.scene._objectOpacityUpdated(this, false);
8764
+ if (this._opacityUpdated) {
8765
+ this.scene._objectColorizeUpdated(this, false);
8766
+ }
8767
+ if (this._opacityUpdated) {
8768
+ this.scene._objectOpacityUpdated(this, false);
8769
+ }
8786
8770
  this.scene._objectOffsetUpdated(this, false);
8787
8771
  }
8788
8772
  for (let i = 0, len = this.meshes.length; i < len; i++) {
@@ -12150,7 +12134,7 @@ class Canvas extends Component {
12150
12134
  * @event boundary
12151
12135
  * @param value The property's new value
12152
12136
  */
12153
- if (!newResolutionScale) {
12137
+ if (!newResolutionScale || newCanvasSize) {
12154
12138
  this.fire("boundary", boundary);
12155
12139
  }
12156
12140
 
@@ -15978,7 +15962,9 @@ const Renderer = function (scene, options) {
15978
15962
 
15979
15963
  if (highlightedFillOpaqueBinLen > 0 || highlightedEdgesOpaqueBinLen > 0) {
15980
15964
  frameCtx.lastProgramId = null;
15981
- gl.clear(gl.DEPTH_BUFFER_BIT);
15965
+ if ( scene.highlightMaterial.glowThrough) {
15966
+ gl.clear(gl.DEPTH_BUFFER_BIT);
15967
+ }
15982
15968
  if (highlightedEdgesOpaqueBinLen > 0) {
15983
15969
  for (i = 0; i < highlightedEdgesOpaqueBinLen; i++) {
15984
15970
  highlightedEdgesOpaqueBin[i].drawEdgesHighlighted(frameCtx);
@@ -15993,17 +15979,17 @@ const Renderer = function (scene, options) {
15993
15979
 
15994
15980
  if (highlightedFillTransparentBinLen > 0 || highlightedEdgesTransparentBinLen > 0 || highlightedFillOpaqueBinLen > 0) {
15995
15981
  frameCtx.lastProgramId = null;
15996
- gl.clear(gl.DEPTH_BUFFER_BIT);
15997
- gl.enable(gl.CULL_FACE);
15982
+ if (scene.selectedMaterial.glowThrough) {
15983
+ gl.clear(gl.DEPTH_BUFFER_BIT);
15984
+ }
15998
15985
  gl.enable(gl.BLEND);
15999
-
16000
15986
  if (canvasTransparent) {
16001
15987
  gl.blendEquation(gl.FUNC_ADD);
16002
15988
  gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
16003
15989
  } else {
16004
15990
  gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
16005
15991
  }
16006
-
15992
+ gl.enable(gl.CULL_FACE);
16007
15993
  if (highlightedEdgesTransparentBinLen > 0) {
16008
15994
  for (i = 0; i < highlightedEdgesTransparentBinLen; i++) {
16009
15995
  highlightedEdgesTransparentBin[i].drawEdgesHighlighted(frameCtx);
@@ -16019,7 +16005,9 @@ const Renderer = function (scene, options) {
16019
16005
 
16020
16006
  if (selectedFillOpaqueBinLen > 0 || selectedEdgesOpaqueBinLen > 0) {
16021
16007
  frameCtx.lastProgramId = null;
16022
- gl.clear(gl.DEPTH_BUFFER_BIT);
16008
+ if (scene.selectedMaterial.glowThrough) {
16009
+ gl.clear(gl.DEPTH_BUFFER_BIT);
16010
+ }
16023
16011
  if (selectedEdgesOpaqueBinLen > 0) {
16024
16012
  for (i = 0; i < selectedEdgesOpaqueBinLen; i++) {
16025
16013
  selectedEdgesOpaqueBin[i].drawEdgesSelected(frameCtx);
@@ -16034,10 +16022,11 @@ const Renderer = function (scene, options) {
16034
16022
 
16035
16023
  if (selectedFillTransparentBinLen > 0 || selectedEdgesTransparentBinLen > 0) {
16036
16024
  frameCtx.lastProgramId = null;
16037
- gl.clear(gl.DEPTH_BUFFER_BIT);
16025
+ if (scene.selectedMaterial.glowThrough) {
16026
+ gl.clear(gl.DEPTH_BUFFER_BIT);
16027
+ }
16038
16028
  gl.enable(gl.CULL_FACE);
16039
16029
  gl.enable(gl.BLEND);
16040
-
16041
16030
  if (canvasTransparent) {
16042
16031
  gl.blendEquation(gl.FUNC_ADD);
16043
16032
  gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
@@ -23182,6 +23171,7 @@ class EmphasisMaterial extends Material {
23182
23171
  * @param {Number} [cfg.edgeWidth=1] Width of xray edges, in pixels.
23183
23172
  * @param {String} [cfg.preset] Selects a preset EmphasisMaterial configuration - see {@link EmphasisMaterial#presets}.
23184
23173
  * @param {Boolean} [cfg.backfaces=false] Whether to render geometry backfaces when emphasising.
23174
+ * @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.
23185
23175
  */
23186
23176
  constructor(owner, cfg = {}) {
23187
23177
 
@@ -23196,7 +23186,8 @@ class EmphasisMaterial extends Material {
23196
23186
  edgeColor: null,
23197
23187
  edgeAlpha: null,
23198
23188
  edgeWidth: null,
23199
- backfaces: true
23189
+ backfaces: true,
23190
+ glowThrough: true
23200
23191
  });
23201
23192
 
23202
23193
  this._preset = "default";
@@ -23227,6 +23218,9 @@ class EmphasisMaterial extends Material {
23227
23218
  if (cfg.backfaces !== undefined) {
23228
23219
  this.backfaces = cfg.backfaces;
23229
23220
  }
23221
+ if (cfg.glowThrough !== undefined) {
23222
+ this.glowThrough = cfg.glowThrough;
23223
+ }
23230
23224
  } else {
23231
23225
  this.fill = cfg.fill;
23232
23226
  this.fillColor = cfg.fillColor;
@@ -23236,6 +23230,7 @@ class EmphasisMaterial extends Material {
23236
23230
  this.edgeAlpha = cfg.edgeAlpha;
23237
23231
  this.edgeWidth = cfg.edgeWidth;
23238
23232
  this.backfaces = cfg.backfaces;
23233
+ this.glowThrough = cfg.glowThrough;
23239
23234
  }
23240
23235
  }
23241
23236
 
@@ -23457,7 +23452,7 @@ class EmphasisMaterial extends Material {
23457
23452
  }
23458
23453
 
23459
23454
  /**
23460
- * Sets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````..
23455
+ * Sets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````.
23461
23456
  *
23462
23457
  * Default is ````false````.
23463
23458
  *
@@ -23473,9 +23468,9 @@ class EmphasisMaterial extends Material {
23473
23468
  }
23474
23469
 
23475
23470
  /**
23476
- * Gets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````..
23471
+ * Gets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````.
23477
23472
  *
23478
- * Default is ````false````.
23473
+ * Default is ````true````.
23479
23474
  *
23480
23475
  * @type {Boolean}
23481
23476
  */
@@ -23483,6 +23478,35 @@ class EmphasisMaterial extends Material {
23483
23478
  return this._state.backfaces;
23484
23479
  }
23485
23480
 
23481
+ /**
23482
+ * Sets whether to render emphasized objects over the top of other objects, as if they were "glowing through".
23483
+ *
23484
+ * Default is ````true````.
23485
+ *
23486
+ * Note: updating this property will not affect the appearance of objects that are already emphasized.
23487
+ *
23488
+ * @type {Boolean}
23489
+ */
23490
+ set glowThrough(value) {
23491
+ value = (value !== false);
23492
+ if (this._state.glowThrough === value) {
23493
+ return;
23494
+ }
23495
+ this._state.glowThrough = value;
23496
+ this.glRedraw();
23497
+ }
23498
+
23499
+ /**
23500
+ * Sets whether to render emphasized objects over the top of other objects, as if they were "glowing through".
23501
+ *
23502
+ * Default is ````true````.
23503
+ *
23504
+ * @type {Boolean}
23505
+ */
23506
+ get glowThrough() {
23507
+ return this._state.glowThrough;
23508
+ }
23509
+
23486
23510
  /**
23487
23511
  * Selects a preset EmphasisMaterial configuration.
23488
23512
  *
@@ -23507,6 +23531,7 @@ class EmphasisMaterial extends Material {
23507
23531
  this.edgeColor = preset.edgeColor;
23508
23532
  this.edgeAlpha = preset.edgeAlpha;
23509
23533
  this.edgeWidth = preset.edgeWidth;
23534
+ this.glowThrough = preset.glowThrough;
23510
23535
  this._preset = value;
23511
23536
  }
23512
23537
 
@@ -27390,7 +27415,7 @@ class Scene extends Component {
27390
27415
  * registered by {@link Entity#id} in {@link Scene#visibleObjects}.
27391
27416
  *
27392
27417
  * @param {String[]} ids Array of {@link Entity#id} values.
27393
- * @param {Boolean} visible Whether or not to cull.
27418
+ * @param {Boolean} visible Whether or not to set visible.
27394
27419
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27395
27420
  */
27396
27421
  setObjectsVisible(ids, visible) {
@@ -27407,7 +27432,7 @@ class Scene extends Component {
27407
27432
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27408
27433
  *
27409
27434
  * @param {String[]} ids Array of {@link Entity#id} values.
27410
- * @param {Boolean} collidable Whether or not to cull.
27435
+ * @param {Boolean} collidable Whether or not to set collidable.
27411
27436
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27412
27437
  */
27413
27438
  setObjectsCollidable(ids, collidable) {
@@ -27428,7 +27453,7 @@ class Scene extends Component {
27428
27453
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27429
27454
  */
27430
27455
  setObjectsCulled(ids, culled) {
27431
- return this.withObjects(ids, this.objects, entity => {
27456
+ return this.withObjects(ids, entity => {
27432
27457
  const changed = (entity.culled !== culled);
27433
27458
  entity.culled = culled;
27434
27459
  return changed;
@@ -27444,7 +27469,7 @@ class Scene extends Component {
27444
27469
  * registered by {@link Entity#id} in {@link Scene#selectedObjects}.
27445
27470
  *
27446
27471
  * @param {String[]} ids Array of {@link Entity#id} values.
27447
- * @param {Boolean} selected Whether or not to highlight.
27472
+ * @param {Boolean} selected Whether or not to select.
27448
27473
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27449
27474
  */
27450
27475
  setObjectsSelected(ids, selected) {
@@ -27480,9 +27505,6 @@ class Scene extends Component {
27480
27505
  *
27481
27506
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27482
27507
  *
27483
- * Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#xrayed} are ````true```` is
27484
- * registered by {@link Entity#id} in {@link Scene#xrayedObjects}.
27485
- *
27486
27508
  * @param {String[]} ids Array of {@link Entity#id} values.
27487
27509
  * @param {Boolean} xrayed Whether or not to xray.
27488
27510
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
@@ -27550,7 +27572,7 @@ class Scene extends Component {
27550
27572
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27551
27573
  *
27552
27574
  * @param {String[]} ids Array of {@link Entity#id} values.
27553
- * @param {Boolean} pickable Whether or not to enable picking.
27575
+ * @param {Boolean} pickable Whether or not to set pickable.
27554
27576
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27555
27577
  */
27556
27578
  setObjectsPickable(ids, pickable) {
@@ -27576,13 +27598,10 @@ class Scene extends Component {
27576
27598
  }
27577
27599
 
27578
27600
  /**
27579
- * Iterates with a callback over {@link Entity#visible} on {@link Entity}s that represent objects.
27601
+ * Iterates with a callback over {@link Entity}s that represent objects.
27580
27602
  *
27581
27603
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27582
27604
  *
27583
- * Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#visible} are ````true```` is
27584
- * registered by {@link Entity#id} in {@link Scene#visibleObjects}.
27585
- *
27586
27605
  * @param {String[]} ids Array of {@link Entity#id} values.
27587
27606
  * @param {Function} callback Callback to execute on eacn {@link Entity}.
27588
27607
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
@@ -46553,7 +46572,7 @@ class TrianglesBatchingLayer {
46553
46572
  // Color
46554
46573
 
46555
46574
  let f0;
46556
- if (!visible || culled || xrayed) { // Highlight & select are layered on top of color - not mutually exclusive
46575
+ 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
46557
46576
  f0 = RENDER_PASSES.NOT_RENDERED;
46558
46577
  } else {
46559
46578
  if (transparent) {
@@ -53670,7 +53689,7 @@ class TrianglesInstancingLayer {
53670
53689
  // Normal fill
53671
53690
 
53672
53691
  let f0;
53673
- if (!visible || culled || xrayed) { // Highlight & select are layered on top of color - not mutually exclusive
53692
+ 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
53674
53693
  f0 = RENDER_PASSES.NOT_RENDERED;
53675
53694
  } else {
53676
53695
  if (meshTransparent) {
@@ -55420,7 +55439,7 @@ class LinesBatchingLayer {
55420
55439
  // Color
55421
55440
 
55422
55441
  let f0;
55423
- if (!visible || culled || xrayed) {
55442
+ 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
55424
55443
  f0 = RENDER_PASSES.NOT_RENDERED;
55425
55444
  } else {
55426
55445
  if (transparent) {
@@ -56887,7 +56906,7 @@ class LinesInstancingLayer {
56887
56906
  // Normal fill
56888
56907
 
56889
56908
  let f0;
56890
- if (!visible || culled || xrayed) {
56909
+ 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
56891
56910
  f0 = RENDER_PASSES.NOT_RENDERED;
56892
56911
  } else {
56893
56912
  if (meshTransparent) {
@@ -59453,7 +59472,7 @@ class PointsBatchingLayer {
59453
59472
  // Normal fill
59454
59473
 
59455
59474
  let f0;
59456
- if (!visible || culled || xrayed) {
59475
+ 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
59457
59476
  f0 = RENDER_PASSES.NOT_RENDERED;
59458
59477
  } else {
59459
59478
  if (transparent) {
@@ -62846,7 +62865,7 @@ class PointsInstancingLayer {
62846
62865
  // Normal fill
62847
62866
 
62848
62867
  let f0;
62849
- if (!visible || culled || xrayed) {
62868
+ 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
62850
62869
  f0 = RENDER_PASSES.NOT_RENDERED;
62851
62870
  } else {
62852
62871
  if (meshTransparent) {
@@ -65100,41 +65119,37 @@ class PerformanceModel extends Component {
65100
65119
 
65101
65120
  let needNewBatchingLayers = false;
65102
65121
 
65103
- let origin = null;
65122
+ const origin = math.vec3(this._origin);
65104
65123
 
65124
+ const cfgOrigin = cfg.origin || cfg.rtcCenter;
65125
+ if (cfgOrigin) {
65126
+ math.addVec3(origin, cfgOrigin, origin);
65127
+ }
65128
+
65129
+ let rtcOrigin = null;
65105
65130
  if (!cfg.positionsDecodeMatrix) { // TODO: Assumes we never quantize double-precision coordinates
65106
65131
  const rtcCenter = math.vec3();
65107
65132
  const rtcPositions = [];
65108
65133
  const rtcNeeded = worldToRTCPositions(positions, rtcPositions, rtcCenter);
65109
65134
  if (rtcNeeded) {
65110
65135
  positions = rtcPositions;
65111
- origin = math.addVec3(this._origin, rtcCenter, rtcCenter);
65136
+ rtcOrigin = rtcCenter;
65112
65137
  }
65113
65138
  }
65114
-
65115
- const cfgOrigin = cfg.origin || cfg.rtcCenter;
65116
- if (cfgOrigin) {
65117
- if (!origin) {
65118
- origin = cfgOrigin;
65119
- } else {
65120
- origin = math.addVec3(this._origin, cfgOrigin, tempVec3a$9);
65121
- }
65122
- } else {
65123
- origin = this._origin;
65139
+ if (rtcOrigin) {
65140
+ math.addVec3(origin, rtcOrigin, origin);
65124
65141
  }
65125
65142
 
65126
- if (origin) {
65127
- if (!this._lastOrigin) {
65143
+ if (!this._lastOrigin) {
65144
+ needNewBatchingLayers = true;
65145
+ this._lastOrigin = math.vec3(origin);
65146
+ } else {
65147
+ if (!math.compareVec3(this._lastOrigin, origin)) {
65128
65148
  needNewBatchingLayers = true;
65129
- this._lastOrigin = math.vec3(origin);
65130
- } else {
65131
- if (!math.compareVec3(this._lastOrigin, origin)) {
65132
- needNewBatchingLayers = true;
65133
- this._lastOrigin.set(origin);
65134
- }
65149
+ this._lastOrigin.set(origin);
65135
65150
  }
65136
65151
  }
65137
-
65152
+
65138
65153
  if (cfg.positionsDecodeMatrix) {
65139
65154
  if (!this._lastDecodeMatrix) {
65140
65155
  needNewBatchingLayers = true;