@xeokit/xeokit-sdk 2.4.2-beta-29 → 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-29",
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",
@@ -316,29 +316,11 @@ class BCFViewpointsPlugin extends Plugin {
316
316
  * @param {String} [cfg.id="BCFViewpoints"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
317
317
  * @param {String} [cfg.originatingSystem] Identifies the originating system for BCF records.
318
318
  * @param {String} [cfg.authoringTool] Identifies the authoring tool for BCF records.
319
- * @param {Boolean} [cfg.xrayAsZeroAlpha=false] Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints. See {@link BCFViewpointsPlugin#xrayAsZeroAlpha} for details.
320
319
  */
321
320
  constructor(viewer, cfg = {}) {
322
321
 
323
322
  super("BCFViewpoints", viewer, cfg);
324
323
 
325
- /**
326
- * Specifies how xeokit's X-ray emphasis effect is handled in BCF viewpoints.
327
- *
328
- * When `xrayAsZeroAlpha` is `true`:
329
- *
330
- * * when saving a viewpoint, set the `A` channel of each `coloring` component to `0` for each X-rayed object, and
331
- * * when loading a viewpoint saved from a xeokit application (i.e. when the viewpoint's `originating_system == "xeokit.io"`), set an object X-rayed if the `A` channel of its corresponding `coloring` component equals `0`
332
- *
333
- * When `xrayAsZeroAlpha` is `false`:
334
- *
335
- * * don't save any X-ray information in viewpoints, and
336
- * * reset all objects as not X-rayed whenever loading a viewpoint.
337
- *
338
- * @type {boolean}
339
- */
340
- this.xrayAsZeroAlpha = !!cfg.xrayAsZeroAlpha;
341
-
342
324
  /**
343
325
  * Identifies the originating system to include in BCF viewpoints saved by this plugin.
344
326
  * @property originatingSystem
@@ -363,6 +345,9 @@ class BCFViewpointsPlugin extends Plugin {
363
345
  * @param {Boolean} [options.spacesVisible=false] Indicates whether ````IfcSpace```` types should be forced visible in the viewpoint.
364
346
  * @param {Boolean} [options.openingsVisible=false] Indicates whether ````IfcOpening```` types should be forced visible in the viewpoint.
365
347
  * @param {Boolean} [options.spaceBoundariesVisible=false] Indicates whether the boundaries of ````IfcSpace```` types should be visible in the viewpoint.
348
+ * @param {Boolean} [options.spacesTranslucent=false] Indicates whether ````IfcSpace```` types should be forced translucent in the viewpoint.
349
+ * @param {Boolean} [options.spaceBoundariesTranslucent=false] Indicates whether the boundaries of ````IfcSpace```` types should be forced translucent in the viewpoint.
350
+ * @param {Boolean} [options.openingsTranslucent=true] Indicates whether ````IfcOpening```` types should be forced translucent in the viewpoint.
366
351
  * @param {Boolean} [options.snapshot=true] Indicates whether the snapshot should be included in the viewpoint.
367
352
  * @param {Boolean} [options.defaultInvisible=false] When ````true````, will save the default visibility of all objects
368
353
  * as ````false````. This means that when we load the viewpoint again, and there are additional models loaded that
@@ -510,7 +495,10 @@ class BCFViewpointsPlugin extends Plugin {
510
495
  view_setup_hints: {
511
496
  spaces_visible: !!options.spacesVisible,
512
497
  space_boundaries_visible: !!options.spaceBoundariesVisible,
513
- openings_visible: !!options.openingsVisible
498
+ openings_visible: !!options.openingsVisible,
499
+ spaces_translucent: !!options.spaces_translucent,
500
+ space_boundaries_translucent: !!options.space_boundaries_translucent,
501
+ openings_translucent: !!options.openings_translucent
514
502
  }
515
503
  }
516
504
  };
@@ -527,15 +515,11 @@ class BCFViewpointsPlugin extends Plugin {
527
515
  let alpha;
528
516
 
529
517
  if (entity.xrayed) {
530
- if (this.xrayAsZeroAlpha) {
531
- alpha = 0;
518
+ if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
519
+ // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
520
+ alpha = 0.1;
532
521
  } else {
533
- if (scene.xrayMaterial.fillAlpha === 0.0 && scene.xrayMaterial.edgeAlpha !== 0.0) {
534
- // BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
535
- alpha = 0.1;
536
- } else {
537
- alpha = scene.xrayMaterial.fillAlpha;
538
- }
522
+ alpha = scene.xrayMaterial.fillAlpha;
539
523
  }
540
524
  alpha = Math.round(alpha * 255).toString(16).padStart(2, "0");
541
525
  color = alpha + color;
@@ -586,6 +570,8 @@ class BCFViewpointsPlugin extends Plugin {
586
570
 
587
571
  bcfViewpoint.components.selection = this._createBCFComponents(selectedObjectIds);
588
572
 
573
+ bcfViewpoint.components.translucency = this._createBCFComponents(scene.xrayedObjectIds);
574
+
589
575
  if (options.snapshot !== false) {
590
576
  bcfViewpoint.snapshot = {
591
577
  snapshot_type: "png",
@@ -771,13 +757,22 @@ class BCFViewpointsPlugin extends Plugin {
771
757
  const view_setup_hints = bcfViewpoint.components.visibility.view_setup_hints;
772
758
  if (view_setup_hints) {
773
759
  if (view_setup_hints.spaces_visible === false) {
774
- scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"), false);
760
+ scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"), true);
775
761
  }
776
- if (view_setup_hints.openings_visible === false) {
777
- scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"), false);
762
+ if (view_setup_hints.spaces_translucent !== undefined) {
763
+ scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcSpace"), true);
778
764
  }
779
765
  if (view_setup_hints.space_boundaries_visible !== undefined) {
780
- // TODO: Ability to show boundaries
766
+
767
+ }
768
+ if (view_setup_hints.openings_visible === false) {
769
+ scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"), true);
770
+ }
771
+ if (view_setup_hints.space_boundaries_translucent !== undefined) {
772
+
773
+ }
774
+ if (view_setup_hints.openings_translucent !== undefined) {
775
+ scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcOpening"), true);
781
776
  }
782
777
  }
783
778
  }
@@ -788,6 +783,11 @@ class BCFViewpointsPlugin extends Plugin {
788
783
 
789
784
  }
790
785
 
786
+ if (bcfViewpoint.components.translucency) {
787
+ scene.setObjectsXRayed(scene.xrayedObjectIds, false);
788
+ bcfViewpoint.components.translucency.forEach(component => this._withBCFComponent(options, component, entity => entity.xrayed = true));
789
+ }
790
+
791
791
  if (bcfViewpoint.components.coloring) {
792
792
  bcfViewpoint.components.coloring.forEach(coloring => {
793
793
 
@@ -814,16 +814,7 @@ class BCFViewpointsPlugin extends Plugin {
814
814
  this._withBCFComponent(options, component, entity => {
815
815
  entity.colorize = colorize;
816
816
  if (alphaDefined) {
817
- if (alpha === 0 && this.xrayAsZeroAlpha) {
818
- const savedFromXeokit = (component.originating_system === this.originatingSystem);
819
- if (savedFromXeokit) {
820
- entity.xrayed = true;
821
- } else {
822
- entity.opacity = alpha;
823
- }
824
- } else {
825
- entity.opacity = alpha;
826
- }
817
+ entity.opacity = alpha;
827
818
  }
828
819
  }));
829
820
  });
@@ -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();