@xeokit/xeokit-sdk 2.6.66 → 2.6.68

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.
Files changed (37) hide show
  1. package/{LICENSE.txt → LICENSE} +30 -27
  2. package/README.md +13 -6
  3. package/dist/xeokit-sdk.cjs.js +19164 -16785
  4. package/dist/xeokit-sdk.es.js +19164 -16785
  5. package/dist/xeokit-sdk.es5.js +5122 -4861
  6. package/dist/xeokit-sdk.min.cjs.js +5 -5
  7. package/dist/xeokit-sdk.min.es.js +5 -5
  8. package/dist/xeokit-sdk.min.es5.js +4 -4
  9. package/package.json +34 -32
  10. package/src/plugins/AnnotationsPlugin/Annotation.js +45 -5
  11. package/src/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.js +1 -1
  12. package/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +3 -2
  13. package/src/plugins/LASLoaderPlugin/LASLoaderPlugin.js +1 -1
  14. package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +57 -2
  15. package/src/plugins/XKTLoaderPlugin/parsers/ParserV10.js +6 -0
  16. package/src/plugins/XKTLoaderPlugin/parsers/ParserV11.js +6 -0
  17. package/src/plugins/XKTLoaderPlugin/parsers/ParserV12.js +822 -0
  18. package/src/plugins/XKTLoaderPlugin/parsers/ParserV6.js +6 -0
  19. package/src/plugins/XKTLoaderPlugin/parsers/ParserV7.js +6 -0
  20. package/src/plugins/XKTLoaderPlugin/parsers/ParserV8.js +6 -0
  21. package/src/plugins/XKTLoaderPlugin/parsers/ParserV9.js +6 -0
  22. package/src/{plugins/lib → viewer/scene/libs}/earcut.js +194 -189
  23. package/src/viewer/scene/materials/EmphasisMaterial.js +5 -1
  24. package/src/viewer/scene/math/math.js +6 -2
  25. package/src/viewer/scene/model/SceneModelEntity.js +26 -0
  26. package/src/viewer/scene/model/SceneModelMesh.js +4 -0
  27. package/src/viewer/scene/model/dtx/triangles/DTXTrianglesLayer.js +1 -1
  28. package/src/viewer/scene/model/vbo/batching/triangles/VBOBatchingTrianglesLayer.js +1 -1
  29. package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +1 -1
  30. package/src/viewer/scene/scene/Scene.js +50 -6
  31. package/src/viewer/scene/sectionCaps/SectionCaps.js +774 -0
  32. package/src/viewer/scene/sectionCaps/index.js +1 -0
  33. package/src/viewer/scene/webgl/Renderer.js +10 -7
  34. package/src/viewer/scene/webgl/sao/SAOOcclusionRenderer.js +9 -1
  35. package/types/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.d.ts +2 -1
  36. package/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts +28 -0
  37. package/types/viewer/scene/models/SceneModelMesh.d.ts +7 -0
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.66",
4
- "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
3
+ "version": "2.6.68",
4
+ "description": "3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
7
7
  "types": "./types/index.d.ts",
8
-
9
8
  "scripts": {
10
9
  "build": "rollup --config rollup.config.js; rollup --config rollup.minified.config.js",
11
10
  "dev-build": "rollup --config rollup.dev.config.js",
12
11
  "docs": "rm -Rf ./docs/*; ./node_modules/.bin/esdoc",
13
12
  "typedocs": "rm -Rf ./docs/*; typedoc --tsconfig tsconfig.json",
14
13
  "publish": "npm publish --access public",
15
- "changelog": "git fetch; auto-changelog --commit-limit false --package --template changelog-template.hbs"
14
+ "changelog": "git fetch; auto-changelog --commit-limit false --package --template changelog-template.hbs",
15
+ "test": "npx percy exec -- npx playwright test"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
19
- "url": "git+https://github.com/xeokit/xeokit-sdk.git"
19
+ "url": "https://github.com/xeokit/xeokit-sdk.git"
20
20
  },
21
21
  "auto-changelog": {
22
22
  "output": "CHANGELOG.md",
@@ -25,47 +25,50 @@
25
25
  "commitLimit": false
26
26
  },
27
27
  "keywords": [
28
- "webgl",
29
- "webgl2",
30
- "javascript",
31
- "xeokit",
32
- "xeolabs",
33
- "creoox",
34
- "ifc",
35
- "bcf",
28
+ "ifc-viewer",
29
+ "bim-viewer",
30
+ "3d-web-viewer",
31
+ "point-cloud-viewer",
32
+ "online-viewer",
33
+ "web-gl",
34
+ "viewer-sdk",
35
+ "3d-viewers",
36
36
  "bim",
37
- "gis",
38
- "cad",
37
+ "ifc",
38
+ "geometry",
39
+ "point-cloud",
40
+ "las-viewer",
41
+ "laz-viewer",
42
+ "webgl-viewer",
43
+ "javascript-viewer",
39
44
  "buildingsmart",
40
- "openbim",
41
- "opensource",
42
- "solidworks",
43
- "gltf",
44
- "3dxml",
45
- "obj",
46
- "stl",
47
- "laz",
48
- "las",
49
- "pointcloud",
50
- "3d-viewer"
45
+ "geospatial",
46
+ "gis",
47
+ "3d-tiles"
51
48
  ],
52
49
  "author": "Lindsay Kay",
53
- "license": "See LICENSE.txt",
50
+ "license": "AGPL-3.0",
54
51
  "bugs": {
55
52
  "url": "https://github.com/xeokit/xeokit-sdk/issues"
56
53
  },
57
54
  "homepage": "https://xeokit.io",
58
55
  "dependencies": {
59
- "@loaders.gl/core": "^3.2.6",
60
- "@loaders.gl/gltf": "^3.2.6",
61
- "@loaders.gl/las": "^3.2.6",
56
+ "@loaders.gl/core": "^4.3.3",
57
+ "@loaders.gl/gltf": "^4.3.3",
58
+ "@loaders.gl/las": "^4.3.3",
62
59
  "html2canvas": "^1.4.1"
63
60
  },
64
61
  "devDependencies": {
65
62
  "@babel/core": "^7.18.6",
66
63
  "@babel/preset-env": "^7.18.6",
64
+ "@percy/cli": "^1.30.7",
65
+ "@percy/playwright": "^1.0.7",
66
+ "@playwright/test": "^1.49.1",
67
67
  "@rollup/plugin-babel": "^5.3.1",
68
68
  "@rollup/plugin-node-resolve": "^13.2.1",
69
+ "@types/node": "^22.10.6",
70
+ "auto-changelog": "^2.4.0",
71
+ "dotenv": "^16.4.7",
69
72
  "esdoc": "^1.1.0",
70
73
  "esdoc-custom-theme": "^1.4.2",
71
74
  "esdoc-publish-html-plugin": "^1.1.2",
@@ -74,8 +77,7 @@
74
77
  "parse5": "^7.0.0",
75
78
  "rollup": "^2.70.2",
76
79
  "rollup-plugin-terser": "^7.0.2",
77
- "typedoc": "^0.22.15",
78
- "auto-changelog": "^2.4.0"
80
+ "typedoc": "^0.22.15"
79
81
  },
80
82
  "files": [
81
83
  "/src",
@@ -40,6 +40,8 @@ class Annotation extends Marker {
40
40
  }
41
41
 
42
42
  this._htmlDirty = false;
43
+ this._curMarkerWidth = undefined;
44
+ this._curLabelWidth = 0;
43
45
 
44
46
  if (cfg.markerElement) {
45
47
  this._marker = cfg.markerElement;
@@ -210,27 +212,65 @@ class Annotation extends Marker {
210
212
  /**
211
213
  * @private
212
214
  */
213
- _updatePosition() {
215
+ _updateWithCurWidths() {
214
216
  const px = x => x + "px";
215
217
  const boundary = this.scene.canvas.boundary;
216
218
  const left = boundary[0] + this.canvasPos[0];
217
219
  const top = boundary[1] + this.canvasPos[1];
218
- const markerRect = this._marker.getBoundingClientRect();
219
- const markerWidth = markerRect.width;
220
+ const markerWidth = this._curMarkerWidth;
220
221
  const markerDir = (this._markerAlign === "right") ? -1 : ((this._markerAlign === "center") ? 0 : 1);
221
222
  const markerCenter = left + markerDir * (markerWidth / 2 - 12);
222
223
  this._marker.style.left = px(markerCenter - markerWidth / 2);
223
224
  this._marker.style.top = px(top - 12);
224
225
  this._marker.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
225
226
 
226
- const labelRect = this._label.getBoundingClientRect();
227
- const labelWidth = labelRect.width;
227
+ const labelWidth = this._curLabelWidth;
228
228
  const labelDir = Math.sign(this._labelPosition);
229
229
  this._label.style.left = px(markerCenter + labelDir * (markerWidth / 2 + Math.abs(this._labelPosition) + labelWidth / 2) - labelWidth / 2);
230
230
  this._label.style.top = px(top - 17);
231
231
  this._label.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
232
232
  }
233
233
 
234
+ /**
235
+ * @private
236
+ */
237
+ _updateIfWidthsChanged() {
238
+ let needsUpdate = false;
239
+ const markerWidth = this._marker.getBoundingClientRect().width;
240
+ if (this._curMarkerWidth !== markerWidth) {
241
+ this._curMarkerWidth = markerWidth;
242
+ needsUpdate = true;
243
+ }
244
+ const labelDir = Math.sign(this._labelPosition);
245
+ // if (labelDir === 1) then don't perform relatively expensive label.getBoundingClientRect call
246
+ if (labelDir !== 1) {
247
+ const labelWidth = this._label.getBoundingClientRect().width;
248
+ if (this._curLabelWidth !== labelWidth) {
249
+ this._curLabelWidth = labelWidth;
250
+ needsUpdate = true;
251
+ }
252
+ }
253
+ if (needsUpdate) {
254
+ this._updateWithCurWidths();
255
+ }
256
+ }
257
+
258
+ /**
259
+ * @private
260
+ */
261
+ _updatePosition() {
262
+ if (this._curMarkerWidth === undefined) {
263
+ this._updateIfWidthsChanged();
264
+ } else {
265
+ // Update position with cached width values
266
+ // and postpone expensive Annotation's getBoundingClientRect calls
267
+ // so they don't interfere with e.g. interactive scene manipulation
268
+ this._updateWithCurWidths();
269
+ window.clearTimeout(this._widthTimeout);
270
+ this._widthTimeout = window.setTimeout(() => this._updateIfWidthsChanged(), 500);
271
+ }
272
+ }
273
+
234
274
  /**
235
275
  * @private
236
276
  */
@@ -1,7 +1,7 @@
1
1
  import {math, Plugin, SceneModel, utils} from "../../viewer/index.js";
2
2
  import {CityJSONDefaultDataSource} from "./CityJSONDefaultDataSource.js";
3
3
 
4
- import {earcut} from '../lib/earcut.js';
4
+ import earcut from '../../viewer/scene/libs/earcut.js';
5
5
 
6
6
  const tempVec2a = math.vec2();
7
7
  const tempVec3a = math.vec3();
@@ -4,7 +4,7 @@ import {core} from "../../viewer/scene/core.js";
4
4
  import {sRGBEncoding} from "../../viewer/scene/constants/constants.js";
5
5
  import {worldToRTCPositions} from "../../viewer/scene/math/rtcCoords.js";
6
6
  import {parse} from '@loaders.gl/core';
7
- import {GLTFLoader} from '@loaders.gl/gltf/dist/esm/gltf-loader.js';
7
+ import {GLTFLoader, postProcessGLTF} from '@loaders.gl/gltf';
8
8
 
9
9
  import {
10
10
  ClampToEdgeWrapping,
@@ -104,6 +104,7 @@ function parseGLTF(plugin, src, gltf, metaModelJSON, options, sceneModel, ok) {
104
104
  parse(gltf, GLTFLoader, {
105
105
  baseUri: options.basePath
106
106
  }).then((gltfData) => {
107
+ const processedGLTF = postProcessGLTF(gltfData);
107
108
  const ctx = {
108
109
  src: src,
109
110
  entityId: options.entityId,
@@ -115,7 +116,7 @@ function parseGLTF(plugin, src, gltf, metaModelJSON, options, sceneModel, ok) {
115
116
  basePath: options.basePath,
116
117
  handlenode: options.handlenode,
117
118
  backfaces: !!options.backfaces,
118
- gltfData: gltfData,
119
+ gltfData: processedGLTF,
119
120
  scene: sceneModel.scene,
120
121
  plugin: plugin,
121
122
  sceneModel: sceneModel,
@@ -4,7 +4,7 @@ import {Plugin} from "../../viewer/Plugin.js";
4
4
  import {LASDefaultDataSource} from "./LASDefaultDataSource.js";
5
5
  import {math} from "../../viewer/index.js";
6
6
  import {parse} from '@loaders.gl/core';
7
- import {LASLoader} from '@loaders.gl/las/dist/esm/las-loader.js';
7
+ import {LASLoader} from '@loaders.gl/las';
8
8
  import {loadLASHeader} from "./loadLASHeader";
9
9
 
10
10
  const MAX_VERTICES = 500000; // TODO: Rough estimate
@@ -16,6 +16,7 @@ import {ParserV8} from "./parsers/ParserV8.js";
16
16
  import {ParserV9} from "./parsers/ParserV9.js";
17
17
  import {ParserV10} from "./parsers/ParserV10.js";
18
18
  import {ParserV11} from "./parsers/ParserV11.js";
19
+ import {ParserV12} from './parsers/ParserV12.js';
19
20
 
20
21
 
21
22
  const parsers = {};
@@ -31,6 +32,7 @@ parsers[ParserV8.version] = ParserV8;
31
32
  parsers[ParserV9.version] = ParserV9;
32
33
  parsers[ParserV10.version] = ParserV10;
33
34
  parsers[ParserV11.version] = ParserV11;
35
+ parsers[ParserV12.version] = ParserV12;
34
36
 
35
37
  /**
36
38
  * {@link Viewer} plugin that loads models from xeokit's optimized *````.XKT````* format.
@@ -253,6 +255,20 @@ parsers[ParserV11.version] = ParserV11;
253
255
  * });
254
256
  * ````
255
257
  *
258
+ * # Including specific elements by id
259
+ *
260
+ * We can also load only those objects that have the specified ids.
261
+ *
262
+ * In the example below, we'll load only the objects that represent a specified wall with 4 windows.
263
+ *
264
+ * ````javascript
265
+ * const model4 = xktLoader.load({
266
+ * id: "myModel4",
267
+ * src: "../../assets/models/xkt/v10/glTF-Embedded/Duplex_A_20110505.glTFEmbedded.xkt",
268
+ * includeIds: ["2O2Fr$t4X7Zf8NOew3FLOH", "1hOSvn6df7F8_7GcBWlS_W", "1hOSvn6df7F8_7GcBWlS4Q", "1hOSvn6df7F8_7GcBWlS1M", "1hOSvn6df7F8_7GcBWlS2V"],
269
+ * });
270
+ * ````
271
+ *
256
272
  * # Configuring initial IFC object appearances
257
273
  *
258
274
  * We can specify the custom initial appearance of loaded objects according to their IFC types.
@@ -747,6 +763,34 @@ class XKTLoaderPlugin extends Plugin {
747
763
  this._excludeTypes = value;
748
764
  }
749
765
 
766
+ /**
767
+ * Gets the whitelist of the specified elements loaded by this XKTLoaderPlugin.
768
+ *
769
+ * When loading models with metadata, causes this XKTLoaderPlugin to only load objects whose ids are in this
770
+ * list. An object's id is indicated by its {@link MetaObject}'s {@link MetaObject#id}.
771
+ *
772
+ * Default value is ````undefined````.
773
+ *
774
+ * @type {String[]}
775
+ */
776
+ get includeIds() {
777
+ return this._includeIds;
778
+ }
779
+
780
+ /**
781
+ * Sets the whitelist of the specified elements by this XKTLoaderPlugin.
782
+ *
783
+ * When loading models with metadata, causes this XKTLoaderPlugin to only load objects whose ids are in this
784
+ * list. An object's id is indicated by its {@link MetaObject}'s {@link MetaObject#id}.
785
+ *
786
+ * Default value is ````undefined````.
787
+ *
788
+ * @type {String[]}
789
+ */
790
+ set includeIds(value) {
791
+ this._includeIds = value;
792
+ }
793
+
750
794
  /**
751
795
  * Gets whether we load objects that don't have IFC types.
752
796
  *
@@ -859,6 +903,7 @@ class XKTLoaderPlugin extends Plugin {
859
903
  * @param {{String:Object}} [params.objectDefaults] Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}.
860
904
  * @param {String[]} [params.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
861
905
  * @param {String[]} [params.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
906
+ * @param {String[]} [params.includeIds] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#id} values in this list.
862
907
  * @param {Boolean} [params.edges=false] Whether or not xeokit renders the model with edges emphasized.
863
908
  * @param {Number[]} [params.origin=[0,0,0]] The model's World-space double-precision 3D origin. Use this to position the model within xeokit's World coordinate system, using double-precision coordinates.
864
909
  * @param {Number[]} [params.position=[0,0,0]] The model single-precision 3D position, relative to the ````origin```` parameter.
@@ -900,6 +945,7 @@ class XKTLoaderPlugin extends Plugin {
900
945
  const options = {};
901
946
  const includeTypes = params.includeTypes || this._includeTypes;
902
947
  const excludeTypes = params.excludeTypes || this._excludeTypes;
948
+ const includeIds = params.includeIds || this._includeIds;
903
949
  const objectDefaults = params.objectDefaults || this._objectDefaults;
904
950
 
905
951
  options.reuseGeometries = (params.reuseGeometries !== null && params.reuseGeometries !== undefined) ? params.reuseGeometries : (this._reuseGeometries !== false);
@@ -918,6 +964,13 @@ class XKTLoaderPlugin extends Plugin {
918
964
  }
919
965
  }
920
966
 
967
+ if (includeIds) {
968
+ options.includeIdsMap = {};
969
+ for (let i = 0, len = includeIds.length; i < len; i++) {
970
+ options.includeIdsMap[includeIds[i]] = true;
971
+ }
972
+ }
973
+
921
974
  if (objectDefaults) {
922
975
  options.objectDefaults = objectDefaults;
923
976
  }
@@ -1139,7 +1192,9 @@ class XKTLoaderPlugin extends Plugin {
1139
1192
  }
1140
1193
  const dataView = new DataView(arrayBuffer);
1141
1194
  const dataArray = new Uint8Array(arrayBuffer);
1142
- const xktVersion = dataView.getUint32(0, true);
1195
+ const firstUint = dataView.getUint32(0, true);
1196
+ const xktVersion = firstUint & 0x7fffffff;
1197
+ const zipped = (xktVersion < 11) || ((xktVersion >= 12) && (firstUint >>> 31));
1143
1198
  const parser = parsers[xktVersion];
1144
1199
  if (!parser) {
1145
1200
  this.error("Unsupported .XKT file version: " + xktVersion + " - this XKTLoaderPlugin supports versions " + Object.keys(parsers));
@@ -1147,7 +1202,7 @@ class XKTLoaderPlugin extends Plugin {
1147
1202
  }
1148
1203
  // this.log("Loading .xkt V" + xktVersion);
1149
1204
 
1150
- if (parser.parseArrayBuffer) {
1205
+ if (!zipped) {
1151
1206
  parser.parseArrayBuffer(this.viewer, options, arrayBuffer, sceneModel, metaModel, manifestCtx);
1152
1207
  return;
1153
1208
  }
@@ -320,6 +320,12 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
320
320
  continue;
321
321
  }
322
322
 
323
+ // Mask loading of object ids
324
+
325
+ if (options.includeIdsMap && metaObject.id && (!options.includeIdsMap[metaObject.id])) {
326
+ continue;
327
+ }
328
+
323
329
  // Get initial property values for object types
324
330
 
325
331
  const props = options.objectDefaults ? options.objectDefaults[metaObject.type] || options.objectDefaults["DEFAULT"] : null;
@@ -313,6 +313,12 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
313
313
  continue;
314
314
  }
315
315
 
316
+ // Mask loading of object ids
317
+
318
+ if (options.includeIdsMap && metaObject.id && (!options.includeIdsMap[metaObject.id])) {
319
+ continue;
320
+ }
321
+
316
322
  // Get initial property values for object types
317
323
 
318
324
  const props = options.objectDefaults ? options.objectDefaults[metaObject.type] || options.objectDefaults["DEFAULT"] : null;