@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.
package/README.md CHANGED
@@ -16,16 +16,13 @@ npm i @xeokit/xeokit-sdk
16
16
  ## Usage
17
17
 
18
18
  The xeokit SDK lets us develop our own browser-based BIM viewer, which we can fully customize and extend with
19
- plugins.
20
-
21
- Let's create a [Viewer](https://xeokit.github.io/xeokit-sdk/docs/class/src/viewer/Viewer.js~Viewer.html) with
19
+ plugins. Let's create a [Viewer](https://xeokit.github.io/xeokit-sdk/docs/class/src/viewer/Viewer.js~Viewer.html) with
22
20
  a [WebIFCLoaderPlugin](https://xeokit.github.io/xeokit-sdk/docs/class/src/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.js~WebIFCLoaderPlugin.html)
23
21
  to view a IFC model in the browser, then view a sample IFC model from
24
22
  the [Open IFC Model Database](http://openifcmodel.cs.auckland.ac.nz/Model/Details/274).
25
23
 
26
- > > [Run this example](https://xeokit.github.io/xeokit-sdk/examples/#BIMOffline_WebIFCLoaderPlugin_Duplex)
27
- >
28
- > > [Read the full tutorial](https://www.notion.so/xeokit/Viewing-an-IFC-Model-with-WebIFCLoaderPlugin-9a572b801af949bf87a21c88968bd251)
24
+ * [Run this example](https://xeokit.github.io/xeokit-sdk/examples/#BIMOffline_WebIFCLoaderPlugin_Duplex)
25
+ * [Read the full tutorial](https://www.notion.so/xeokit/Viewing-an-IFC-Model-with-WebIFCLoaderPlugin-9a572b801af949bf87a21c88968bd251)
29
26
 
30
27
  ![](https://xeokit.io/img/docs/WebIFCLoaderPlugin/WebIFCLoaderPluginBig.png)
31
28
 
@@ -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
 
@@ -15447,6 +15431,14 @@ const Renderer = function (scene, options) {
15447
15431
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
15448
15432
  };
15449
15433
 
15434
+ /**
15435
+ * Returns true if the next call to render() will draw something
15436
+ * @returns {boolean}
15437
+ */
15438
+ this.needsRender = function () {
15439
+ return (imageDirty || drawableListDirty || stateSortDirty);
15440
+ };
15441
+
15450
15442
  /**
15451
15443
  * Renders inserted drawables.
15452
15444
  * @private
@@ -15970,7 +15962,9 @@ const Renderer = function (scene, options) {
15970
15962
 
15971
15963
  if (highlightedFillOpaqueBinLen > 0 || highlightedEdgesOpaqueBinLen > 0) {
15972
15964
  frameCtx.lastProgramId = null;
15973
- gl.clear(gl.DEPTH_BUFFER_BIT);
15965
+ if ( scene.highlightMaterial.glowThrough) {
15966
+ gl.clear(gl.DEPTH_BUFFER_BIT);
15967
+ }
15974
15968
  if (highlightedEdgesOpaqueBinLen > 0) {
15975
15969
  for (i = 0; i < highlightedEdgesOpaqueBinLen; i++) {
15976
15970
  highlightedEdgesOpaqueBin[i].drawEdgesHighlighted(frameCtx);
@@ -15985,17 +15979,17 @@ const Renderer = function (scene, options) {
15985
15979
 
15986
15980
  if (highlightedFillTransparentBinLen > 0 || highlightedEdgesTransparentBinLen > 0 || highlightedFillOpaqueBinLen > 0) {
15987
15981
  frameCtx.lastProgramId = null;
15988
- gl.clear(gl.DEPTH_BUFFER_BIT);
15989
- gl.enable(gl.CULL_FACE);
15982
+ if (scene.selectedMaterial.glowThrough) {
15983
+ gl.clear(gl.DEPTH_BUFFER_BIT);
15984
+ }
15990
15985
  gl.enable(gl.BLEND);
15991
-
15992
15986
  if (canvasTransparent) {
15993
15987
  gl.blendEquation(gl.FUNC_ADD);
15994
15988
  gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
15995
15989
  } else {
15996
15990
  gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
15997
15991
  }
15998
-
15992
+ gl.enable(gl.CULL_FACE);
15999
15993
  if (highlightedEdgesTransparentBinLen > 0) {
16000
15994
  for (i = 0; i < highlightedEdgesTransparentBinLen; i++) {
16001
15995
  highlightedEdgesTransparentBin[i].drawEdgesHighlighted(frameCtx);
@@ -16011,7 +16005,9 @@ const Renderer = function (scene, options) {
16011
16005
 
16012
16006
  if (selectedFillOpaqueBinLen > 0 || selectedEdgesOpaqueBinLen > 0) {
16013
16007
  frameCtx.lastProgramId = null;
16014
- gl.clear(gl.DEPTH_BUFFER_BIT);
16008
+ if (scene.selectedMaterial.glowThrough) {
16009
+ gl.clear(gl.DEPTH_BUFFER_BIT);
16010
+ }
16015
16011
  if (selectedEdgesOpaqueBinLen > 0) {
16016
16012
  for (i = 0; i < selectedEdgesOpaqueBinLen; i++) {
16017
16013
  selectedEdgesOpaqueBin[i].drawEdgesSelected(frameCtx);
@@ -16026,10 +16022,11 @@ const Renderer = function (scene, options) {
16026
16022
 
16027
16023
  if (selectedFillTransparentBinLen > 0 || selectedEdgesTransparentBinLen > 0) {
16028
16024
  frameCtx.lastProgramId = null;
16029
- gl.clear(gl.DEPTH_BUFFER_BIT);
16025
+ if (scene.selectedMaterial.glowThrough) {
16026
+ gl.clear(gl.DEPTH_BUFFER_BIT);
16027
+ }
16030
16028
  gl.enable(gl.CULL_FACE);
16031
16029
  gl.enable(gl.BLEND);
16032
-
16033
16030
  if (canvasTransparent) {
16034
16031
  gl.blendEquation(gl.FUNC_ADD);
16035
16032
  gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
@@ -23174,6 +23171,7 @@ class EmphasisMaterial extends Material {
23174
23171
  * @param {Number} [cfg.edgeWidth=1] Width of xray edges, in pixels.
23175
23172
  * @param {String} [cfg.preset] Selects a preset EmphasisMaterial configuration - see {@link EmphasisMaterial#presets}.
23176
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.
23177
23175
  */
23178
23176
  constructor(owner, cfg = {}) {
23179
23177
 
@@ -23188,7 +23186,8 @@ class EmphasisMaterial extends Material {
23188
23186
  edgeColor: null,
23189
23187
  edgeAlpha: null,
23190
23188
  edgeWidth: null,
23191
- backfaces: true
23189
+ backfaces: true,
23190
+ glowThrough: true
23192
23191
  });
23193
23192
 
23194
23193
  this._preset = "default";
@@ -23219,6 +23218,9 @@ class EmphasisMaterial extends Material {
23219
23218
  if (cfg.backfaces !== undefined) {
23220
23219
  this.backfaces = cfg.backfaces;
23221
23220
  }
23221
+ if (cfg.glowThrough !== undefined) {
23222
+ this.glowThrough = cfg.glowThrough;
23223
+ }
23222
23224
  } else {
23223
23225
  this.fill = cfg.fill;
23224
23226
  this.fillColor = cfg.fillColor;
@@ -23228,6 +23230,7 @@ class EmphasisMaterial extends Material {
23228
23230
  this.edgeAlpha = cfg.edgeAlpha;
23229
23231
  this.edgeWidth = cfg.edgeWidth;
23230
23232
  this.backfaces = cfg.backfaces;
23233
+ this.glowThrough = cfg.glowThrough;
23231
23234
  }
23232
23235
  }
23233
23236
 
@@ -23449,7 +23452,7 @@ class EmphasisMaterial extends Material {
23449
23452
  }
23450
23453
 
23451
23454
  /**
23452
- * Sets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````..
23455
+ * Sets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````.
23453
23456
  *
23454
23457
  * Default is ````false````.
23455
23458
  *
@@ -23465,9 +23468,9 @@ class EmphasisMaterial extends Material {
23465
23468
  }
23466
23469
 
23467
23470
  /**
23468
- * Gets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````..
23471
+ * Gets whether to render backfaces when {@link EmphasisMaterial#fill} is ````true````.
23469
23472
  *
23470
- * Default is ````false````.
23473
+ * Default is ````true````.
23471
23474
  *
23472
23475
  * @type {Boolean}
23473
23476
  */
@@ -23475,6 +23478,35 @@ class EmphasisMaterial extends Material {
23475
23478
  return this._state.backfaces;
23476
23479
  }
23477
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
+
23478
23510
  /**
23479
23511
  * Selects a preset EmphasisMaterial configuration.
23480
23512
  *
@@ -23499,6 +23531,7 @@ class EmphasisMaterial extends Material {
23499
23531
  this.edgeColor = preset.edgeColor;
23500
23532
  this.edgeAlpha = preset.edgeAlpha;
23501
23533
  this.edgeWidth = preset.edgeWidth;
23534
+ this.glowThrough = preset.glowThrough;
23502
23535
  this._preset = value;
23503
23536
  }
23504
23537
 
@@ -26430,6 +26463,10 @@ class Scene extends Component {
26430
26463
  this._needRecompile = false;
26431
26464
  }
26432
26465
 
26466
+ if (!forceRender && !this._renderer.needsRender()) {
26467
+ return;
26468
+ }
26469
+
26433
26470
  renderEvent.sceneId = this.id;
26434
26471
 
26435
26472
  const passes = this._passes;
@@ -27378,7 +27415,7 @@ class Scene extends Component {
27378
27415
  * registered by {@link Entity#id} in {@link Scene#visibleObjects}.
27379
27416
  *
27380
27417
  * @param {String[]} ids Array of {@link Entity#id} values.
27381
- * @param {Boolean} visible Whether or not to cull.
27418
+ * @param {Boolean} visible Whether or not to set visible.
27382
27419
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27383
27420
  */
27384
27421
  setObjectsVisible(ids, visible) {
@@ -27395,7 +27432,7 @@ class Scene extends Component {
27395
27432
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27396
27433
  *
27397
27434
  * @param {String[]} ids Array of {@link Entity#id} values.
27398
- * @param {Boolean} collidable Whether or not to cull.
27435
+ * @param {Boolean} collidable Whether or not to set collidable.
27399
27436
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27400
27437
  */
27401
27438
  setObjectsCollidable(ids, collidable) {
@@ -27432,7 +27469,7 @@ class Scene extends Component {
27432
27469
  * registered by {@link Entity#id} in {@link Scene#selectedObjects}.
27433
27470
  *
27434
27471
  * @param {String[]} ids Array of {@link Entity#id} values.
27435
- * @param {Boolean} selected Whether or not to highlight.
27472
+ * @param {Boolean} selected Whether or not to select.
27436
27473
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27437
27474
  */
27438
27475
  setObjectsSelected(ids, selected) {
@@ -27468,9 +27505,6 @@ class Scene extends Component {
27468
27505
  *
27469
27506
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27470
27507
  *
27471
- * Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#xrayed} are ````true```` is
27472
- * registered by {@link Entity#id} in {@link Scene#xrayedObjects}.
27473
- *
27474
27508
  * @param {String[]} ids Array of {@link Entity#id} values.
27475
27509
  * @param {Boolean} xrayed Whether or not to xray.
27476
27510
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
@@ -27538,7 +27572,7 @@ class Scene extends Component {
27538
27572
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27539
27573
  *
27540
27574
  * @param {String[]} ids Array of {@link Entity#id} values.
27541
- * @param {Boolean} pickable Whether or not to enable picking.
27575
+ * @param {Boolean} pickable Whether or not to set pickable.
27542
27576
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27543
27577
  */
27544
27578
  setObjectsPickable(ids, pickable) {
@@ -27564,13 +27598,10 @@ class Scene extends Component {
27564
27598
  }
27565
27599
 
27566
27600
  /**
27567
- * 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.
27568
27602
  *
27569
27603
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27570
27604
  *
27571
- * Each {@link Entity} on which both {@link Entity#isObject} and {@link Entity#visible} are ````true```` is
27572
- * registered by {@link Entity#id} in {@link Scene#visibleObjects}.
27573
- *
27574
27605
  * @param {String[]} ids Array of {@link Entity#id} values.
27575
27606
  * @param {Function} callback Callback to execute on eacn {@link Entity}.
27576
27607
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
@@ -46541,7 +46572,7 @@ class TrianglesBatchingLayer {
46541
46572
  // Color
46542
46573
 
46543
46574
  let f0;
46544
- 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
46545
46576
  f0 = RENDER_PASSES.NOT_RENDERED;
46546
46577
  } else {
46547
46578
  if (transparent) {
@@ -53658,7 +53689,7 @@ class TrianglesInstancingLayer {
53658
53689
  // Normal fill
53659
53690
 
53660
53691
  let f0;
53661
- 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
53662
53693
  f0 = RENDER_PASSES.NOT_RENDERED;
53663
53694
  } else {
53664
53695
  if (meshTransparent) {
@@ -55408,7 +55439,7 @@ class LinesBatchingLayer {
55408
55439
  // Color
55409
55440
 
55410
55441
  let f0;
55411
- 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
55412
55443
  f0 = RENDER_PASSES.NOT_RENDERED;
55413
55444
  } else {
55414
55445
  if (transparent) {
@@ -56875,7 +56906,7 @@ class LinesInstancingLayer {
56875
56906
  // Normal fill
56876
56907
 
56877
56908
  let f0;
56878
- 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
56879
56910
  f0 = RENDER_PASSES.NOT_RENDERED;
56880
56911
  } else {
56881
56912
  if (meshTransparent) {
@@ -59441,7 +59472,7 @@ class PointsBatchingLayer {
59441
59472
  // Normal fill
59442
59473
 
59443
59474
  let f0;
59444
- 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
59445
59476
  f0 = RENDER_PASSES.NOT_RENDERED;
59446
59477
  } else {
59447
59478
  if (transparent) {
@@ -62834,7 +62865,7 @@ class PointsInstancingLayer {
62834
62865
  // Normal fill
62835
62866
 
62836
62867
  let f0;
62837
- 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
62838
62869
  f0 = RENDER_PASSES.NOT_RENDERED;
62839
62870
  } else {
62840
62871
  if (meshTransparent) {