@xeokit/xeokit-sdk 2.2.1-beta.4 → 2.2.4

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
@@ -4,30 +4,94 @@
4
4
  [![npm version](https://badge.fury.io/js/%40xeokit%2Fxeokit-sdk.svg)](https://badge.fury.io/js/%40xeokit%2Fxeokit-sdk)
5
5
  [![](https://data.jsdelivr.com/v1/package/npm/@xeokit/xeokit-sdk/badge)](https://www.jsdelivr.com/package/npm/@xeokit/xeokit-sdk)
6
6
 
7
- [xeokit](http://xeokit.io) is a JavaScript software development kit from [xeolabs](http://xeolabs.com) for viewing
7
+ [xeokit](http://xeokit.io) is a JavaScript software development kit from [xeolabs](http://xeolabs.com) for viewing
8
8
  high-detail, full-precision 3D engineering and BIM models in the browser.
9
9
 
10
- [![Peek-2019-10-22-10-57](https://user-images.githubusercontent.com/83100/67271586-14690780-f4bb-11e9-9e76-203fe425ee08.gif)](https://xeokit.github.io/xeokit-sdk/examples/#storeyViews_StoreyViewsPlugin_recipe2)
10
+ ## Installing
11
+
12
+ ````bash
13
+ npm i @xeokit/xeokit-sdk
14
+ ````
11
15
 
12
16
  ## Usage
13
17
 
14
- To install:
18
+ The xeokit SDK lets us develop our own browser-based BIM viewer, which we can fully customize and extend with
19
+ plugins. Let's create a [Viewer](https://xeokit.github.io/xeokit-sdk/docs/class/src/viewer/Viewer.js~Viewer.html) with
20
+ a [WebIFCLoaderPlugin](https://xeokit.github.io/xeokit-sdk/docs/class/src/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.js~WebIFCLoaderPlugin.html)
21
+ to view a IFC model in the browser, then view a sample IFC model from
22
+ the [Open IFC Model Database](http://openifcmodel.cs.auckland.ac.nz/Model/Details/274).
15
23
 
16
- ````bash
17
- npm i @xeokit/xeokit-sdk
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)
26
+
27
+ ![](https://xeokit.io/img/docs/WebIFCLoaderPlugin/WebIFCLoaderPluginBig.png)
28
+
29
+ ````html
30
+ <!doctype html>
31
+ <html>
32
+ <head>
33
+ <meta charset="utf-8">
34
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
35
+ <meta name="viewport" content="width=device-width, initial-scale=1">
36
+ <title>xeokit Example</title>
37
+ <style>
38
+ body {
39
+ margin: 0;
40
+ width: 100%;
41
+ height: 100%;
42
+ user-select: none;
43
+ }
44
+
45
+ #myCanvas {
46
+ width: 100%;
47
+ height: 100%;
48
+ position: absolute;
49
+ background: lightblue;
50
+ background-image: linear-gradient(lightblue, white);
51
+ }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <canvas id="myCanvas"></canvas>
56
+ </body>
57
+ <script id="source" type="module">
58
+
59
+ import {Viewer, WebIFCLoaderPlugin} from
60
+ "https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/xeokit-sdk.es.min.js";
61
+
62
+ const viewer = new Viewer({
63
+ canvasId: "myCanvas",
64
+ transparent: true
65
+ });
66
+
67
+ viewer.camera.eye = [-3.933, 2.855, 27.018];
68
+ viewer.camera.look = [4.400, 3.724, 8.899];
69
+ viewer.camera.up = [-0.018, 0.999, 0.039];
70
+
71
+ const webIFCLoader = new WebIFCLoaderPlugin(viewer, {
72
+ wasmPath: "https://cdn.jsdelivr.net/npm/@xeokit/xeokit-sdk/dist/"
73
+ });
74
+
75
+ const model = webIFCLoader.load({
76
+ src: "Duplex.ifc",
77
+ edges: true
78
+ });
79
+
80
+ </script>
81
+ </html>
18
82
  ````
19
83
 
20
- ## Resources
21
-
22
- * [xeokit.io](https://xeokit.io/)
23
- * [Examples](http://xeokit.github.io/xeokit-sdk/examples/)
24
- * [Guides](https://www.notion.so/xeokit/xeokit-Documentation-4598591fcedb4889bf8896750651f74e)
25
- * [API Docs](https://xeokit.github.io/xeokit-sdk/docs/)
26
- * [Changelog](https://xeokit.github.io/xeokit-sdk/CHANGE_LOG)
27
- * [Features](https://xeokit.io/index.html?foo=1#features)
28
- * [FAQ](https://xeokit.io/index.html?foo=1#faq)
29
- * [Blog](https://xeokit.io/blog.html)
30
- * [License](https://xeokit.io/index.html#pricing)
84
+ ## Resources
85
+
86
+ * [xeokit.io](https://xeokit.io/)
87
+ * [Examples](http://xeokit.github.io/xeokit-sdk/examples/)
88
+ * [Guides](https://www.notion.so/xeokit/xeokit-Documentation-4598591fcedb4889bf8896750651f74e)
89
+ * [API Docs](https://xeokit.github.io/xeokit-sdk/docs/)
90
+ * [Changelog](https://xeokit.github.io/xeokit-sdk/CHANGE_LOG)
91
+ * [Features](https://xeokit.io/index.html?foo=1#features)
92
+ * [FAQ](https://xeokit.io/index.html?foo=1#faq)
93
+ * [Blog](https://xeokit.io/blog.html)
94
+ * [License](https://xeokit.io/index.html#pricing)
31
95
 
32
96
 
33
97
 
@@ -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
@@ -26430,6 +26422,10 @@ class Scene extends Component {
26430
26422
  this._needRecompile = false;
26431
26423
  }
26432
26424
 
26425
+ if (!forceRender && !this._renderer.needsRender()) {
26426
+ return;
26427
+ }
26428
+
26433
26429
  renderEvent.sceneId = this.id;
26434
26430
 
26435
26431
  const passes = this._passes;
@@ -27378,7 +27374,7 @@ class Scene extends Component {
27378
27374
  * registered by {@link Entity#id} in {@link Scene#visibleObjects}.
27379
27375
  *
27380
27376
  * @param {String[]} ids Array of {@link Entity#id} values.
27381
- * @param {Boolean} visible Whether or not to cull.
27377
+ * @param {Boolean} visible Whether or not to set visible.
27382
27378
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27383
27379
  */
27384
27380
  setObjectsVisible(ids, visible) {
@@ -27395,7 +27391,7 @@ class Scene extends Component {
27395
27391
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27396
27392
  *
27397
27393
  * @param {String[]} ids Array of {@link Entity#id} values.
27398
- * @param {Boolean} collidable Whether or not to cull.
27394
+ * @param {Boolean} collidable Whether or not to set collidable.
27399
27395
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27400
27396
  */
27401
27397
  setObjectsCollidable(ids, collidable) {
@@ -27432,7 +27428,7 @@ class Scene extends Component {
27432
27428
  * registered by {@link Entity#id} in {@link Scene#selectedObjects}.
27433
27429
  *
27434
27430
  * @param {String[]} ids Array of {@link Entity#id} values.
27435
- * @param {Boolean} selected Whether or not to highlight.
27431
+ * @param {Boolean} selected Whether or not to select.
27436
27432
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27437
27433
  */
27438
27434
  setObjectsSelected(ids, selected) {
@@ -27468,9 +27464,6 @@ class Scene extends Component {
27468
27464
  *
27469
27465
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27470
27466
  *
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
27467
  * @param {String[]} ids Array of {@link Entity#id} values.
27475
27468
  * @param {Boolean} xrayed Whether or not to xray.
27476
27469
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
@@ -27538,7 +27531,7 @@ class Scene extends Component {
27538
27531
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27539
27532
  *
27540
27533
  * @param {String[]} ids Array of {@link Entity#id} values.
27541
- * @param {Boolean} pickable Whether or not to enable picking.
27534
+ * @param {Boolean} pickable Whether or not to set pickable.
27542
27535
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27543
27536
  */
27544
27537
  setObjectsPickable(ids, pickable) {
@@ -27564,13 +27557,10 @@ class Scene extends Component {
27564
27557
  }
27565
27558
 
27566
27559
  /**
27567
- * Iterates with a callback over {@link Entity#visible} on {@link Entity}s that represent objects.
27560
+ * Iterates with a callback over {@link Entity}s that represent objects.
27568
27561
  *
27569
27562
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27570
27563
  *
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
27564
  * @param {String[]} ids Array of {@link Entity#id} values.
27575
27565
  * @param {Function} callback Callback to execute on eacn {@link Entity}.
27576
27566
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
@@ -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
@@ -26426,6 +26418,10 @@ class Scene extends Component {
26426
26418
  this._needRecompile = false;
26427
26419
  }
26428
26420
 
26421
+ if (!forceRender && !this._renderer.needsRender()) {
26422
+ return;
26423
+ }
26424
+
26429
26425
  renderEvent.sceneId = this.id;
26430
26426
 
26431
26427
  const passes = this._passes;
@@ -27374,7 +27370,7 @@ class Scene extends Component {
27374
27370
  * registered by {@link Entity#id} in {@link Scene#visibleObjects}.
27375
27371
  *
27376
27372
  * @param {String[]} ids Array of {@link Entity#id} values.
27377
- * @param {Boolean} visible Whether or not to cull.
27373
+ * @param {Boolean} visible Whether or not to set visible.
27378
27374
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27379
27375
  */
27380
27376
  setObjectsVisible(ids, visible) {
@@ -27391,7 +27387,7 @@ class Scene extends Component {
27391
27387
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27392
27388
  *
27393
27389
  * @param {String[]} ids Array of {@link Entity#id} values.
27394
- * @param {Boolean} collidable Whether or not to cull.
27390
+ * @param {Boolean} collidable Whether or not to set collidable.
27395
27391
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27396
27392
  */
27397
27393
  setObjectsCollidable(ids, collidable) {
@@ -27428,7 +27424,7 @@ class Scene extends Component {
27428
27424
  * registered by {@link Entity#id} in {@link Scene#selectedObjects}.
27429
27425
  *
27430
27426
  * @param {String[]} ids Array of {@link Entity#id} values.
27431
- * @param {Boolean} selected Whether or not to highlight.
27427
+ * @param {Boolean} selected Whether or not to select.
27432
27428
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27433
27429
  */
27434
27430
  setObjectsSelected(ids, selected) {
@@ -27464,9 +27460,6 @@ class Scene extends Component {
27464
27460
  *
27465
27461
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27466
27462
  *
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
27463
  * @param {String[]} ids Array of {@link Entity#id} values.
27471
27464
  * @param {Boolean} xrayed Whether or not to xray.
27472
27465
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
@@ -27534,7 +27527,7 @@ class Scene extends Component {
27534
27527
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27535
27528
  *
27536
27529
  * @param {String[]} ids Array of {@link Entity#id} values.
27537
- * @param {Boolean} pickable Whether or not to enable picking.
27530
+ * @param {Boolean} pickable Whether or not to set pickable.
27538
27531
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
27539
27532
  */
27540
27533
  setObjectsPickable(ids, pickable) {
@@ -27560,13 +27553,10 @@ class Scene extends Component {
27560
27553
  }
27561
27554
 
27562
27555
  /**
27563
- * Iterates with a callback over {@link Entity#visible} on {@link Entity}s that represent objects.
27556
+ * Iterates with a callback over {@link Entity}s that represent objects.
27564
27557
  *
27565
27558
  * An {@link Entity} represents an object when {@link Entity#isObject} is ````true````.
27566
27559
  *
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
27560
  * @param {String[]} ids Array of {@link Entity#id} values.
27571
27561
  * @param {Function} callback Callback to execute on eacn {@link Entity}.
27572
27562
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.