@xeokit/xeokit-sdk 2.4.2-beta-30 → 2.4.2-beta-31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.4.2-beta-30",
3
+ "version": "2.4.2-beta-31",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -431,6 +431,15 @@ parsers[ParserV10.version] = ParserV10;
431
431
  * myViewer.scene.setObjectVisibilities("myModel1#0BTBFw6f90Nfh9rP1dlXrb", true);
432
432
  *````
433
433
  *
434
+ * We can also provide an HTTP URL to the XKT file:
435
+ *
436
+ * ````javascript
437
+ * const sceneModel = xktLoader.load({
438
+ * manifestSrc: "https://xeokit.github.io/xeokit-sdk/assets/models/models/xkt/Schependomlaan.xkt",
439
+ * id: "myModel",
440
+ * });
441
+ * ````
442
+ *
434
443
  * # Loading a model from a manifest of XKT files
435
444
  *
436
445
  * The `ifc2gltf` tool from Creoox, which converts IFC files into glTF geometry and JSON metadata files, has the option to
@@ -517,6 +526,65 @@ parsers[ParserV10.version] = ParserV10;
517
526
  * They work much reliably (and faster) when processing smaller files (eg. 20MB) than when processing large files (eg. 500MB), where
518
527
  * they have less trouble allocating the system memory they need for conversion and parsing.
519
528
  *
529
+ * We can also provide an HTTP URL to the manifest:
530
+ *
531
+ * ````javascript
532
+ * const sceneModel = xktLoader.load({
533
+ * manifestSrc: "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model.xkt.manifest.json",
534
+ * id: "myModel",
535
+ * });
536
+ * ````
537
+ *
538
+ * We can also provide the manifest as parameter object:
539
+ *
540
+ * ````javascript
541
+ * const sceneModel = xktLoader.load({
542
+ * id: "myModel",
543
+ * manifest: {
544
+ * inputFile: "assets/models/gltf/Karhumaki/model.glb.manifest.json",
545
+ * converterApplication: "convert2xkt",
546
+ * converterApplicationVersion: "v1.1.10",
547
+ * conversionDate": "09-11-2023- 18-29-01",
548
+ * xktFiles: [
549
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model.xkt",
550
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_1.xkt",
551
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_2.xkt",
552
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_3.xkt",
553
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_4.xkt",
554
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_5.xkt",
555
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_6.xkt",
556
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_7.xkt",
557
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_8.xkt"
558
+ * ]
559
+ * }
560
+ * });
561
+ * ````
562
+ *
563
+ * We can also provide the paths to the XKT files as HTTP URLs:
564
+ *
565
+ * ````javascript
566
+ * const sceneModel = xktLoader.load({
567
+ * id: "myModel",
568
+ * manifest: {
569
+ * inputFile: "assets/models/gltf/Karhumaki/model.glb.manifest.json",
570
+ * converterApplication: "convert2xkt",
571
+ * converterApplicationVersion: "v1.1.10",
572
+ * conversionDate": "09-11-2023- 18-29-01",
573
+ * xktFiles: [
574
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model.xkt",
575
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_1.xkt",
576
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_2.xkt",
577
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_3.xkt",
578
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_4.xkt",
579
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_5.xkt",
580
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_6.xkt",
581
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_7.xkt",
582
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_8.xkt"
583
+ * ]
584
+ * }
585
+ * });
586
+ * ````
587
+ *
520
588
  * @class XKTLoaderPlugin
521
589
  */
522
590
  class XKTLoaderPlugin extends Plugin {
@@ -786,10 +854,14 @@ class XKTLoaderPlugin extends Plugin {
786
854
  *
787
855
  * @param {*} params Loading parameters.
788
856
  * @param {String} [params.id] ID to assign to the root {@link Entity#id}, unique among all components in the Viewer's {@link Scene}, generated automatically by default.
789
- * @param {String} [params.src] Path to a *````.xkt````* file, as an alternative to the ````xkt```` parameter.
857
+ * @param {String} [params.src] Path or URL to an *````.xkt````* file, as an alternative to the ````xkt```` parameter.
790
858
  * @param {ArrayBuffer} [params.xkt] The *````.xkt````* file data, as an alternative to the ````src```` parameter.
791
- * @param {String} [params.metaModelSrc] Path to an optional metadata file, as an alternative to the ````metaModelData```` parameter.
859
+ * @param {String} [params.metaModelSrc] Path or URL to an optional metadata file, as an alternative to the ````metaModelData```` parameter.
792
860
  * @param {*} [params.metaModelData] JSON model metadata, as an alternative to the ````metaModelSrc```` parameter.
861
+ * @param {String} [params.manifestSrc] Path or URL to a JSON manifest file that provides paths to ````.xkt```` files to load as parts of the model. Use this option to load models that have been split into
862
+ * multiple XKT files. See [tutorial](https://www.notion.so/xeokit/Automatically-Splitting-Large-Models-for-Better-Performance-165fc022e94742cf966ee50003572259) for more info.
863
+ * @param {Object} [params.manifest] A JSON manifest object (as an alternative to a path or URL) that provides paths to ````.xkt```` files to load as parts of the model. Use this option to load models that have been split into
864
+ * multiple XKT files. See [tutorial](https://www.notion.so/xeokit/Automatically-Splitting-Large-Models-for-Better-Performance-165fc022e94742cf966ee50003572259) for more info.
793
865
  * @param {{String:Object}} [params.objectDefaults] Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}.
794
866
  * @param {String[]} [params.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
795
867
  * @param {String[]} [params.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
@@ -825,8 +897,8 @@ class XKTLoaderPlugin extends Plugin {
825
897
  delete params.id;
826
898
  }
827
899
 
828
- if (!params.src && !params.xkt && !params.manifestSrc) {
829
- this.error("load() param expected: src, xkt or manifestSrc");
900
+ if (!params.src && !params.xkt && !params.manifestSrc && !params.manifest) {
901
+ this.error("load() param expected: src, xkt, manifestSrc or manifestData");
830
902
  return sceneModel; // Return new empty model
831
903
  }
832
904
 
@@ -954,8 +1026,8 @@ class XKTLoaderPlugin extends Plugin {
954
1026
  } else if (params.xkt) {
955
1027
  this._parseModel(params.xkt, params, options, sceneModel, metaModel, manifestCtx);
956
1028
  finish();
957
- } else if (params.manifestSrc) {
958
- const baseDir = getBaseDirectory(params.manifestSrc)
1029
+ } else if (params.manifestSrc || params.manifest) {
1030
+ const baseDir = params.manifestSrc ? getBaseDirectory(params.manifestSrc) : "";
959
1031
  const loadJSONs = (metaDataFiles, done, error) => {
960
1032
  let i = 0;
961
1033
  const loadNext = () => {
@@ -975,7 +1047,6 @@ class XKTLoaderPlugin extends Plugin {
975
1047
  }
976
1048
  loadNext();
977
1049
  }
978
-
979
1050
  const loadXKTs = (xktFiles, done, error) => {
980
1051
  let i = 0;
981
1052
  const loadNext = () => {
@@ -991,11 +1062,8 @@ class XKTLoaderPlugin extends Plugin {
991
1062
  }
992
1063
  loadNext();
993
1064
  };
994
-
995
- this._dataSource.getManifest(params.manifestSrc, (manifestData) => {
996
- if (sceneModel.destroyed) {
997
- return;
998
- }
1065
+ if (params.manifest) {
1066
+ const manifestData = params.manifest;
999
1067
  const xktFiles = manifestData.xktFiles;
1000
1068
  if (!xktFiles || xktFiles.length === 0) {
1001
1069
  error(`load(): Failed to load model manifest - manifest not valid`);
@@ -1009,7 +1077,26 @@ class XKTLoaderPlugin extends Plugin {
1009
1077
  } else {
1010
1078
  loadXKTs(xktFiles, finish, error);
1011
1079
  }
1012
- }, error);
1080
+ } else {
1081
+ this._dataSource.getManifest(params.manifestSrc, (manifestData) => {
1082
+ if (sceneModel.destroyed) {
1083
+ return;
1084
+ }
1085
+ const xktFiles = manifestData.xktFiles;
1086
+ if (!xktFiles || xktFiles.length === 0) {
1087
+ error(`load(): Failed to load model manifest - manifest not valid`);
1088
+ return;
1089
+ }
1090
+ const metaModelFiles = manifestData.metaModelFiles;
1091
+ if (metaModelFiles) {
1092
+ loadJSONs(metaModelFiles, () => {
1093
+ loadXKTs(xktFiles, finish, error);
1094
+ }, error);
1095
+ } else {
1096
+ loadXKTs(xktFiles, finish, error);
1097
+ }
1098
+ }, error);
1099
+ }
1013
1100
  }
1014
1101
  }
1015
1102
 
@@ -2654,7 +2654,7 @@ class Scene extends Component {
2654
2654
  * - it runs maximum once per scene-tick
2655
2655
  *
2656
2656
  * @param {Function} cb The function to tickify
2657
- * @returns {Function)}
2657
+ * @returns {Function}
2658
2658
  */
2659
2659
  tickify(cb) {
2660
2660
  const cbString = cb.toString();