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

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.
@@ -11898,7 +11898,25 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
11898
11898
 
11899
11899
  this._currentAngleMeasurement = null;
11900
11900
 
11901
+ // init markerDiv element (think about making its style configurable)
11902
+ this._initMarkerDiv();
11903
+
11904
+ this._onMouseHoverSurface = null;
11905
+ this._onHoverNothing = null;
11906
+ this._onPickedNothing = null;
11907
+ this._onPickedSurface = null;
11908
+
11909
+ this._onInputMouseDown = null;
11910
+ this._onInputMouseUp = null;
11911
+
11912
+ this._snapping = cfg.snapping !== false;
11913
+
11914
+ this._attachPlugin(angleMeasurementsPlugin, cfg);
11915
+ }
11916
+
11917
+ _initMarkerDiv() {
11901
11918
  const markerDiv = document.createElement('div');
11919
+ markerDiv.setAttribute('id', 'myMarkerDiv');
11902
11920
  const canvas = this.scene.canvas.canvas;
11903
11921
  canvas.parentNode.insertBefore(markerDiv, canvas);
11904
11922
 
@@ -11913,17 +11931,14 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
11913
11931
  markerDiv.style.pointerEvents = "none";
11914
11932
 
11915
11933
  this.markerDiv = markerDiv;
11916
- this._onMouseHoverSurface = null;
11917
- this._onHoverNothing = null;
11918
- this._onPickedNothing = null;
11919
- this._onPickedSurface = null;
11920
-
11921
- this._onInputMouseDown = null;
11922
- this._onInputMouseUp = null;
11923
-
11924
- this._snapping = cfg.snapping !== false;
11934
+ }
11925
11935
 
11926
- this._attachPlugin(angleMeasurementsPlugin, cfg);
11936
+ _destroyMarkerDiv() {
11937
+ if (this._markerDiv) {
11938
+ const element = document.getElementById('myMarkerDiv');
11939
+ element.parentNode.removeChild(element);
11940
+ this._markerDiv = null;
11941
+ }
11927
11942
  }
11928
11943
 
11929
11944
  _attachPlugin(angleMeasurementsPlugin, cfg = {}) {
@@ -11991,6 +12006,9 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
11991
12006
  if (this._active) {
11992
12007
  return;
11993
12008
  }
12009
+ if (!this.markerDiv) {
12010
+ this._initMarkerDiv(); // if the marker is destroyed after deactivation, we recreate it
12011
+ }
11994
12012
  this.angleMeasurementsPlugin;
11995
12013
  const scene = this.scene;
11996
12014
  scene.input;
@@ -12195,6 +12213,9 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12195
12213
  if (this.pointerLens) {
12196
12214
  this.pointerLens.visible = false;
12197
12215
  }
12216
+ if (this._markerDiv) {
12217
+ this._destroyMarkerDiv();
12218
+ }
12198
12219
  this.reset();
12199
12220
  const canvas = this.scene.canvas.canvas;
12200
12221
  canvas.removeEventListener("mousedown", this._onMouseDown);
@@ -12219,6 +12240,10 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
12219
12240
  if (!this._active) {
12220
12241
  return;
12221
12242
  }
12243
+
12244
+ this._destroyMarkerDiv();
12245
+ this._initMarkerDiv();
12246
+
12222
12247
  if (this._currentAngleMeasurement) {
12223
12248
  this._currentAngleMeasurement.destroy();
12224
12249
  this._currentAngleMeasurement = null;
@@ -30235,7 +30260,7 @@ class Scene extends Component {
30235
30260
  * - it runs maximum once per scene-tick
30236
30261
  *
30237
30262
  * @param {Function} cb The function to tickify
30238
- * @returns {Function)}
30263
+ * @returns {Function}
30239
30264
  */
30240
30265
  tickify(cb) {
30241
30266
  const cbString = cb.toString();
@@ -49963,21 +49988,6 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
49963
49988
 
49964
49989
  this._active = false;
49965
49990
 
49966
- const markerDiv = document.createElement('div');
49967
- const canvas = this.scene.canvas.canvas;
49968
- canvas.parentNode.insertBefore(markerDiv, canvas);
49969
- markerDiv.style.background = "black";
49970
- markerDiv.style.border = "2px solid blue";
49971
- markerDiv.style.borderRadius = "10px";
49972
- markerDiv.style.width = "5px";
49973
- markerDiv.style.height = "5px";
49974
- markerDiv.style.margin = "-200px -200px";
49975
- markerDiv.style.zIndex = "100";
49976
- markerDiv.style.position = "absolute";
49977
- markerDiv.style.pointerEvents = "none";
49978
-
49979
- this._markerDiv = markerDiv;
49980
-
49981
49991
  this._currentDistanceMeasurement = null;
49982
49992
 
49983
49993
  this._currentDistanceMeasurementInitState = {
@@ -49989,6 +49999,8 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
49989
49999
  targetVisible: null,
49990
50000
  };
49991
50001
 
50002
+ this._initMarkerDiv();
50003
+
49992
50004
  this._onCameraControlHoverSnapOrSurface = null;
49993
50005
  this._onCameraControlHoverSnapOrSurfaceOff = null;
49994
50006
  this._onMouseDown = null;
@@ -50001,6 +50013,32 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50001
50013
  this._attachPlugin(distanceMeasurementsPlugin, cfg);
50002
50014
  }
50003
50015
 
50016
+ _initMarkerDiv() {
50017
+ const markerDiv = document.createElement('div');
50018
+ markerDiv.setAttribute('id', 'myMarkerDiv');
50019
+ const canvas = this.scene.canvas.canvas;
50020
+ canvas.parentNode.insertBefore(markerDiv, canvas);
50021
+ markerDiv.style.background = "black";
50022
+ markerDiv.style.border = "2px solid blue";
50023
+ markerDiv.style.borderRadius = "10px";
50024
+ markerDiv.style.width = "5px";
50025
+ markerDiv.style.height = "5px";
50026
+ markerDiv.style.margin = "-200px -200px";
50027
+ markerDiv.style.zIndex = "100";
50028
+ markerDiv.style.position = "absolute";
50029
+ markerDiv.style.pointerEvents = "none";
50030
+
50031
+ this._markerDiv = markerDiv;
50032
+ }
50033
+
50034
+ _destroyMarkerDiv() {
50035
+ if (this._markerDiv) {
50036
+ const element = document.getElementById('myMarkerDiv');
50037
+ element.parentNode.removeChild(element);
50038
+ this._markerDiv = null;
50039
+ }
50040
+ }
50041
+
50004
50042
  _attachPlugin(distanceMeasurementsPlugin, cfg = {}) {
50005
50043
 
50006
50044
  /**
@@ -50066,6 +50104,10 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50066
50104
  return;
50067
50105
  }
50068
50106
 
50107
+ if (!this._markerDiv) {
50108
+ this._initMarkerDiv();
50109
+ }
50110
+
50069
50111
  this.fire("activated", true);
50070
50112
 
50071
50113
  const distanceMeasurementsPlugin = this.distanceMeasurementsPlugin;
@@ -50221,6 +50263,9 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50221
50263
  if (this.pointerLens) {
50222
50264
  this.pointerLens.visible = false;
50223
50265
  }
50266
+ if (this._markerDiv) {
50267
+ this._destroyMarkerDiv();
50268
+ }
50224
50269
  this.reset();
50225
50270
  const canvas = this.scene.canvas.canvas;
50226
50271
  canvas.removeEventListener("mousedown", this._onMouseDown);
@@ -50247,6 +50292,10 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
50247
50292
  if (!this._active) {
50248
50293
  return;
50249
50294
  }
50295
+
50296
+ this._destroyMarkerDiv();
50297
+ this._initMarkerDiv();
50298
+
50250
50299
  if (this._currentDistanceMeasurement) {
50251
50300
  this.distanceMeasurementsPlugin.fire("measurementCancel", this._currentDistanceMeasurement);
50252
50301
  this._currentDistanceMeasurement.destroy();
@@ -122553,6 +122602,15 @@ parsers[ParserV10.version] = ParserV10;
122553
122602
  * myViewer.scene.setObjectVisibilities("myModel1#0BTBFw6f90Nfh9rP1dlXrb", true);
122554
122603
  *````
122555
122604
  *
122605
+ * We can also provide an HTTP URL to the XKT file:
122606
+ *
122607
+ * ````javascript
122608
+ * const sceneModel = xktLoader.load({
122609
+ * manifestSrc: "https://xeokit.github.io/xeokit-sdk/assets/models/models/xkt/Schependomlaan.xkt",
122610
+ * id: "myModel",
122611
+ * });
122612
+ * ````
122613
+ *
122556
122614
  * # Loading a model from a manifest of XKT files
122557
122615
  *
122558
122616
  * The `ifc2gltf` tool from Creoox, which converts IFC files into glTF geometry and JSON metadata files, has the option to
@@ -122639,6 +122697,65 @@ parsers[ParserV10.version] = ParserV10;
122639
122697
  * They work much reliably (and faster) when processing smaller files (eg. 20MB) than when processing large files (eg. 500MB), where
122640
122698
  * they have less trouble allocating the system memory they need for conversion and parsing.
122641
122699
  *
122700
+ * We can also provide an HTTP URL to the manifest:
122701
+ *
122702
+ * ````javascript
122703
+ * const sceneModel = xktLoader.load({
122704
+ * manifestSrc: "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model.xkt.manifest.json",
122705
+ * id: "myModel",
122706
+ * });
122707
+ * ````
122708
+ *
122709
+ * We can also provide the manifest as parameter object:
122710
+ *
122711
+ * ````javascript
122712
+ * const sceneModel = xktLoader.load({
122713
+ * id: "myModel",
122714
+ * manifest: {
122715
+ * inputFile: "assets/models/gltf/Karhumaki/model.glb.manifest.json",
122716
+ * converterApplication: "convert2xkt",
122717
+ * converterApplicationVersion: "v1.1.10",
122718
+ * conversionDate": "09-11-2023- 18-29-01",
122719
+ * xktFiles: [
122720
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model.xkt",
122721
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_1.xkt",
122722
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_2.xkt",
122723
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_3.xkt",
122724
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_4.xkt",
122725
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_5.xkt",
122726
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_6.xkt",
122727
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_7.xkt",
122728
+ * "../../assets/models/xkt/v10/split/Karhumaki-Bridge/model_8.xkt"
122729
+ * ]
122730
+ * }
122731
+ * });
122732
+ * ````
122733
+ *
122734
+ * We can also provide the paths to the XKT files as HTTP URLs:
122735
+ *
122736
+ * ````javascript
122737
+ * const sceneModel = xktLoader.load({
122738
+ * id: "myModel",
122739
+ * manifest: {
122740
+ * inputFile: "assets/models/gltf/Karhumaki/model.glb.manifest.json",
122741
+ * converterApplication: "convert2xkt",
122742
+ * converterApplicationVersion: "v1.1.10",
122743
+ * conversionDate": "09-11-2023- 18-29-01",
122744
+ * xktFiles: [
122745
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model.xkt",
122746
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_1.xkt",
122747
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_2.xkt",
122748
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_3.xkt",
122749
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_4.xkt",
122750
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_5.xkt",
122751
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_6.xkt",
122752
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_7.xkt",
122753
+ * "https://xeokit.github.io/xeokit-sdk/assets/models/xkt/v10/split/Karhumaki-Bridge/model_8.xkt"
122754
+ * ]
122755
+ * }
122756
+ * });
122757
+ * ````
122758
+ *
122642
122759
  * @class XKTLoaderPlugin
122643
122760
  */
122644
122761
  class XKTLoaderPlugin extends Plugin {
@@ -122908,10 +123025,14 @@ class XKTLoaderPlugin extends Plugin {
122908
123025
  *
122909
123026
  * @param {*} params Loading parameters.
122910
123027
  * @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.
122911
- * @param {String} [params.src] Path to a *````.xkt````* file, as an alternative to the ````xkt```` parameter.
123028
+ * @param {String} [params.src] Path or URL to an *````.xkt````* file, as an alternative to the ````xkt```` parameter.
122912
123029
  * @param {ArrayBuffer} [params.xkt] The *````.xkt````* file data, as an alternative to the ````src```` parameter.
122913
- * @param {String} [params.metaModelSrc] Path to an optional metadata file, as an alternative to the ````metaModelData```` parameter.
123030
+ * @param {String} [params.metaModelSrc] Path or URL to an optional metadata file, as an alternative to the ````metaModelData```` parameter.
122914
123031
  * @param {*} [params.metaModelData] JSON model metadata, as an alternative to the ````metaModelSrc```` parameter.
123032
+ * @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
123033
+ * multiple XKT files. See [tutorial](https://www.notion.so/xeokit/Automatically-Splitting-Large-Models-for-Better-Performance-165fc022e94742cf966ee50003572259) for more info.
123034
+ * @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
123035
+ * multiple XKT files. See [tutorial](https://www.notion.so/xeokit/Automatically-Splitting-Large-Models-for-Better-Performance-165fc022e94742cf966ee50003572259) for more info.
122915
123036
  * @param {{String:Object}} [params.objectDefaults] Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}.
122916
123037
  * @param {String[]} [params.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
122917
123038
  * @param {String[]} [params.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
@@ -122947,8 +123068,8 @@ class XKTLoaderPlugin extends Plugin {
122947
123068
  delete params.id;
122948
123069
  }
122949
123070
 
122950
- if (!params.src && !params.xkt && !params.manifestSrc) {
122951
- this.error("load() param expected: src, xkt or manifestSrc");
123071
+ if (!params.src && !params.xkt && !params.manifestSrc && !params.manifest) {
123072
+ this.error("load() param expected: src, xkt, manifestSrc or manifestData");
122952
123073
  return sceneModel; // Return new empty model
122953
123074
  }
122954
123075
 
@@ -123076,8 +123197,8 @@ class XKTLoaderPlugin extends Plugin {
123076
123197
  } else if (params.xkt) {
123077
123198
  this._parseModel(params.xkt, params, options, sceneModel, metaModel, manifestCtx);
123078
123199
  finish();
123079
- } else if (params.manifestSrc) {
123080
- const baseDir = getBaseDirectory(params.manifestSrc);
123200
+ } else if (params.manifestSrc || params.manifest) {
123201
+ const baseDir = params.manifestSrc ? getBaseDirectory(params.manifestSrc) : "";
123081
123202
  const loadJSONs = (metaDataFiles, done, error) => {
123082
123203
  let i = 0;
123083
123204
  const loadNext = () => {
@@ -123097,7 +123218,6 @@ class XKTLoaderPlugin extends Plugin {
123097
123218
  };
123098
123219
  loadNext();
123099
123220
  };
123100
-
123101
123221
  const loadXKTs = (xktFiles, done, error) => {
123102
123222
  let i = 0;
123103
123223
  const loadNext = () => {
@@ -123113,11 +123233,8 @@ class XKTLoaderPlugin extends Plugin {
123113
123233
  };
123114
123234
  loadNext();
123115
123235
  };
123116
-
123117
- this._dataSource.getManifest(params.manifestSrc, (manifestData) => {
123118
- if (sceneModel.destroyed) {
123119
- return;
123120
- }
123236
+ if (params.manifest) {
123237
+ const manifestData = params.manifest;
123121
123238
  const xktFiles = manifestData.xktFiles;
123122
123239
  if (!xktFiles || xktFiles.length === 0) {
123123
123240
  error(`load(): Failed to load model manifest - manifest not valid`);
@@ -123131,7 +123248,26 @@ class XKTLoaderPlugin extends Plugin {
123131
123248
  } else {
123132
123249
  loadXKTs(xktFiles, finish, error);
123133
123250
  }
123134
- }, error);
123251
+ } else {
123252
+ this._dataSource.getManifest(params.manifestSrc, (manifestData) => {
123253
+ if (sceneModel.destroyed) {
123254
+ return;
123255
+ }
123256
+ const xktFiles = manifestData.xktFiles;
123257
+ if (!xktFiles || xktFiles.length === 0) {
123258
+ error(`load(): Failed to load model manifest - manifest not valid`);
123259
+ return;
123260
+ }
123261
+ const metaModelFiles = manifestData.metaModelFiles;
123262
+ if (metaModelFiles) {
123263
+ loadJSONs(metaModelFiles, () => {
123264
+ loadXKTs(xktFiles, finish, error);
123265
+ }, error);
123266
+ } else {
123267
+ loadXKTs(xktFiles, finish, error);
123268
+ }
123269
+ }, error);
123270
+ }
123135
123271
  }
123136
123272
  }
123137
123273