@xeokit/xeokit-sdk 2.4.0-alpha-14 → 2.4.0-alpha-16

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.
@@ -327,6 +327,7 @@ class ContextMenu {
327
327
  * @param {Object} [cfg.context] The context, which is passed into the item callbacks. This can also be dynamically set on {@link ContextMenu#context}. This must be set before calling {@link ContextMenu#show}.
328
328
  * @param {Boolean} [cfg.enabled=true] Whether this ````ContextMenu```` is initially enabled. {@link ContextMenu#show} does nothing while this is ````false````.
329
329
  * @param {Boolean} [cfg.hideOnMouseDown=true] Whether this ````ContextMenu```` automatically hides whenever we mouse-down or tap anywhere in the page.
330
+ * @param {Boolean} [cfg.hideOnAction=true] Whether this ````ContextMenu```` automatically hides after we select a menu item. Se false if we want the menu to remain shown and show any updates to its item titles, after we've selected an item.
330
331
  */
331
332
  constructor(cfg = {}) {
332
333
 
@@ -365,6 +366,8 @@ class ContextMenu {
365
366
  this.items = cfg.items;
366
367
  }
367
368
 
369
+ this._hideOnAction = (cfg.hideOnAction !== false);
370
+
368
371
  this.context = cfg.context;
369
372
  this.enabled = cfg.enabled !== false;
370
373
  this.hide();
@@ -793,7 +796,6 @@ class ContextMenu {
793
796
 
794
797
  item.itemElement.addEventListener("click", (event) => {
795
798
  event.preventDefault();
796
- self.hide();
797
799
  if (!self._context) {
798
800
  return;
799
801
  }
@@ -803,9 +805,13 @@ class ContextMenu {
803
805
  if (item.doAction) {
804
806
  item.doAction(self._context);
805
807
  }
808
+ if (this._hideOnAction) {
809
+ self.hide();
810
+ } else {
811
+ self._updateItemsTitles();
812
+ self._updateItemsEnabledStatus();
813
+ }
806
814
  });
807
-
808
-
809
815
  item.itemElement.addEventListener("mouseenter", (event) => {
810
816
  event.preventDefault();
811
817
  if (item.enabled === false) {
@@ -11519,12 +11525,12 @@ class Annotation extends Marker {
11519
11525
  const canvasPos = this.canvasPos;
11520
11526
  this._marker.style.left = (Math.floor(left + canvasPos[0]) - 12) + "px";
11521
11527
  this._marker.style.top = (Math.floor(top + canvasPos[1]) - 12) + "px";
11522
- this._marker.style["z-index"] = cfg._markerZIndex;
11528
+ this._marker.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
11523
11529
  const offsetX = 20;
11524
11530
  const offsetY = -17;
11525
11531
  this._label.style.left = 20 + Math.floor(left + canvasPos[0] + offsetX) + "px";
11526
11532
  this._label.style.top = Math.floor(top + canvasPos[1] + offsetY) + "px";
11527
- this._label.style["z-index"] = cfg._labelZIndex;
11533
+ this._label.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
11528
11534
  }
11529
11535
 
11530
11536
  /**
@@ -12061,8 +12067,6 @@ class AnnotationsPlugin extends Plugin {
12061
12067
  * @param {String} [cfg.id="Annotations"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
12062
12068
  * @param {String} [cfg.markerHTML] HTML text template for Annotation markers. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````markerElementId````.
12063
12069
  * @param {String} [cfg.labelHTML] HTML text template for Annotation labels. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````labelElementId````.
12064
- * @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
12065
- * @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
12066
12070
  * @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
12067
12071
  * @param {{String:(String|Number)}} [cfg.values={}] Map of default values to insert into the HTML templates for the marker and label.
12068
12072
  * @param {Number} [cfg.surfaceOffset=0.3] The amount by which each {@link Annotation} is offset from the surface of
@@ -12071,12 +12075,10 @@ class AnnotationsPlugin extends Plugin {
12071
12075
  constructor(viewer, cfg) {
12072
12076
 
12073
12077
  super("Annotations", viewer);
12074
- const randomZIndex = 90005 + Math.floor(this._viewPos[2]) + 1;
12078
+
12075
12079
  this._labelHTML = cfg.labelHTML || "<div></div>";
12076
12080
  this._markerHTML = cfg.markerHTML || "<div></div>";
12077
12081
  this._container = cfg.container || document.body;
12078
- this._markerZIndex = cfg.markerZIndex || randomZIndex;
12079
- this._labelZIndex = cfg.labelZIndex || randomZIndex;
12080
12082
  this._values = cfg.values || {};
12081
12083
 
12082
12084
  /**
@@ -12152,8 +12154,6 @@ class AnnotationsPlugin extends Plugin {
12152
12154
  * @param {Number[]} [params.look] Optional World-space position for {@link Camera#look}, used when this Annotation is associated with a {@link Camera} position.
12153
12155
  * @param {Number[]} [params.up] Optional World-space position for {@link Camera#up}, used when this Annotation is associated with a {@link Camera} position.
12154
12156
  * @param {String} [params.projection] Optional projection type for {@link Camera#projection}, used when this Annotation is associated with a {@link Camera} position.
12155
- * @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
12156
- * @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
12157
12157
  * @returns {Annotation} The new {@link Annotation}.
12158
12158
  */
12159
12159
  createAnnotation(params) {
@@ -12205,9 +12205,7 @@ class AnnotationsPlugin extends Plugin {
12205
12205
  markerElement: markerElement,
12206
12206
  labelElement: labelElement,
12207
12207
  markerHTML: params.markerHTML || this._markerHTML,
12208
- markerZIndex : params.markerZIndex || this._markerZIndex,
12209
12208
  labelHTML: params.labelHTML || this._labelHTML,
12210
- labelZIndex : params.labelZIndex || this._labelZIndex,
12211
12209
  occludable: params.occludable,
12212
12210
  values: utils.apply(params.values, utils.apply(this._values, {})),
12213
12211
  markerShown: params.markerShown,
@@ -323,6 +323,7 @@ class ContextMenu {
323
323
  * @param {Object} [cfg.context] The context, which is passed into the item callbacks. This can also be dynamically set on {@link ContextMenu#context}. This must be set before calling {@link ContextMenu#show}.
324
324
  * @param {Boolean} [cfg.enabled=true] Whether this ````ContextMenu```` is initially enabled. {@link ContextMenu#show} does nothing while this is ````false````.
325
325
  * @param {Boolean} [cfg.hideOnMouseDown=true] Whether this ````ContextMenu```` automatically hides whenever we mouse-down or tap anywhere in the page.
326
+ * @param {Boolean} [cfg.hideOnAction=true] Whether this ````ContextMenu```` automatically hides after we select a menu item. Se false if we want the menu to remain shown and show any updates to its item titles, after we've selected an item.
326
327
  */
327
328
  constructor(cfg = {}) {
328
329
 
@@ -361,6 +362,8 @@ class ContextMenu {
361
362
  this.items = cfg.items;
362
363
  }
363
364
 
365
+ this._hideOnAction = (cfg.hideOnAction !== false);
366
+
364
367
  this.context = cfg.context;
365
368
  this.enabled = cfg.enabled !== false;
366
369
  this.hide();
@@ -789,7 +792,6 @@ class ContextMenu {
789
792
 
790
793
  item.itemElement.addEventListener("click", (event) => {
791
794
  event.preventDefault();
792
- self.hide();
793
795
  if (!self._context) {
794
796
  return;
795
797
  }
@@ -799,9 +801,13 @@ class ContextMenu {
799
801
  if (item.doAction) {
800
802
  item.doAction(self._context);
801
803
  }
804
+ if (this._hideOnAction) {
805
+ self.hide();
806
+ } else {
807
+ self._updateItemsTitles();
808
+ self._updateItemsEnabledStatus();
809
+ }
802
810
  });
803
-
804
-
805
811
  item.itemElement.addEventListener("mouseenter", (event) => {
806
812
  event.preventDefault();
807
813
  if (item.enabled === false) {
@@ -11515,12 +11521,12 @@ class Annotation extends Marker {
11515
11521
  const canvasPos = this.canvasPos;
11516
11522
  this._marker.style.left = (Math.floor(left + canvasPos[0]) - 12) + "px";
11517
11523
  this._marker.style.top = (Math.floor(top + canvasPos[1]) - 12) + "px";
11518
- this._marker.style["z-index"] = cfg._markerZIndex;
11524
+ this._marker.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
11519
11525
  const offsetX = 20;
11520
11526
  const offsetY = -17;
11521
11527
  this._label.style.left = 20 + Math.floor(left + canvasPos[0] + offsetX) + "px";
11522
11528
  this._label.style.top = Math.floor(top + canvasPos[1] + offsetY) + "px";
11523
- this._label.style["z-index"] = cfg._labelZIndex;
11529
+ this._label.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
11524
11530
  }
11525
11531
 
11526
11532
  /**
@@ -12057,8 +12063,6 @@ class AnnotationsPlugin extends Plugin {
12057
12063
  * @param {String} [cfg.id="Annotations"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
12058
12064
  * @param {String} [cfg.markerHTML] HTML text template for Annotation markers. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````markerElementId````.
12059
12065
  * @param {String} [cfg.labelHTML] HTML text template for Annotation labels. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````labelElementId````.
12060
- * @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
12061
- * @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
12062
12066
  * @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
12063
12067
  * @param {{String:(String|Number)}} [cfg.values={}] Map of default values to insert into the HTML templates for the marker and label.
12064
12068
  * @param {Number} [cfg.surfaceOffset=0.3] The amount by which each {@link Annotation} is offset from the surface of
@@ -12067,12 +12071,10 @@ class AnnotationsPlugin extends Plugin {
12067
12071
  constructor(viewer, cfg) {
12068
12072
 
12069
12073
  super("Annotations", viewer);
12070
- const randomZIndex = 90005 + Math.floor(this._viewPos[2]) + 1;
12074
+
12071
12075
  this._labelHTML = cfg.labelHTML || "<div></div>";
12072
12076
  this._markerHTML = cfg.markerHTML || "<div></div>";
12073
12077
  this._container = cfg.container || document.body;
12074
- this._markerZIndex = cfg.markerZIndex || randomZIndex;
12075
- this._labelZIndex = cfg.labelZIndex || randomZIndex;
12076
12078
  this._values = cfg.values || {};
12077
12079
 
12078
12080
  /**
@@ -12148,8 +12150,6 @@ class AnnotationsPlugin extends Plugin {
12148
12150
  * @param {Number[]} [params.look] Optional World-space position for {@link Camera#look}, used when this Annotation is associated with a {@link Camera} position.
12149
12151
  * @param {Number[]} [params.up] Optional World-space position for {@link Camera#up}, used when this Annotation is associated with a {@link Camera} position.
12150
12152
  * @param {String} [params.projection] Optional projection type for {@link Camera#projection}, used when this Annotation is associated with a {@link Camera} position.
12151
- * @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
12152
- * @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
12153
12153
  * @returns {Annotation} The new {@link Annotation}.
12154
12154
  */
12155
12155
  createAnnotation(params) {
@@ -12201,9 +12201,7 @@ class AnnotationsPlugin extends Plugin {
12201
12201
  markerElement: markerElement,
12202
12202
  labelElement: labelElement,
12203
12203
  markerHTML: params.markerHTML || this._markerHTML,
12204
- markerZIndex : params.markerZIndex || this._markerZIndex,
12205
12204
  labelHTML: params.labelHTML || this._labelHTML,
12206
- labelZIndex : params.labelZIndex || this._labelZIndex,
12207
12205
  occludable: params.occludable,
12208
12206
  values: utils.apply(params.values, utils.apply(this._values, {})),
12209
12207
  markerShown: params.markerShown,