@xeokit/xeokit-sdk 2.4.0-alpha-15 → 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.
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -327,7 +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.
|
|
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.
|
|
331
331
|
*/
|
|
332
332
|
constructor(cfg = {}) {
|
|
333
333
|
|
|
@@ -366,7 +366,7 @@ class ContextMenu {
|
|
|
366
366
|
this.items = cfg.items;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
this.
|
|
369
|
+
this._hideOnAction = (cfg.hideOnAction !== false);
|
|
370
370
|
|
|
371
371
|
this.context = cfg.context;
|
|
372
372
|
this.enabled = cfg.enabled !== false;
|
|
@@ -805,7 +805,7 @@ class ContextMenu {
|
|
|
805
805
|
if (item.doAction) {
|
|
806
806
|
item.doAction(self._context);
|
|
807
807
|
}
|
|
808
|
-
if (this.
|
|
808
|
+
if (this._hideOnAction) {
|
|
809
809
|
self.hide();
|
|
810
810
|
} else {
|
|
811
811
|
self._updateItemsTitles();
|
|
@@ -11525,12 +11525,12 @@ class Annotation extends Marker {
|
|
|
11525
11525
|
const canvasPos = this.canvasPos;
|
|
11526
11526
|
this._marker.style.left = (Math.floor(left + canvasPos[0]) - 12) + "px";
|
|
11527
11527
|
this._marker.style.top = (Math.floor(top + canvasPos[1]) - 12) + "px";
|
|
11528
|
-
this._marker.style["z-index"] =
|
|
11528
|
+
this._marker.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
|
|
11529
11529
|
const offsetX = 20;
|
|
11530
11530
|
const offsetY = -17;
|
|
11531
11531
|
this._label.style.left = 20 + Math.floor(left + canvasPos[0] + offsetX) + "px";
|
|
11532
11532
|
this._label.style.top = Math.floor(top + canvasPos[1] + offsetY) + "px";
|
|
11533
|
-
this._label.style["z-index"] =
|
|
11533
|
+
this._label.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
|
|
11534
11534
|
}
|
|
11535
11535
|
|
|
11536
11536
|
/**
|
|
@@ -12067,8 +12067,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
12067
12067
|
* @param {String} [cfg.id="Annotations"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
|
|
12068
12068
|
* @param {String} [cfg.markerHTML] HTML text template for Annotation markers. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````markerElementId````.
|
|
12069
12069
|
* @param {String} [cfg.labelHTML] HTML text template for Annotation labels. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````labelElementId````.
|
|
12070
|
-
* @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
12071
|
-
* @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
12072
12070
|
* @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
|
|
12073
12071
|
* @param {{String:(String|Number)}} [cfg.values={}] Map of default values to insert into the HTML templates for the marker and label.
|
|
12074
12072
|
* @param {Number} [cfg.surfaceOffset=0.3] The amount by which each {@link Annotation} is offset from the surface of
|
|
@@ -12077,12 +12075,10 @@ class AnnotationsPlugin extends Plugin {
|
|
|
12077
12075
|
constructor(viewer, cfg) {
|
|
12078
12076
|
|
|
12079
12077
|
super("Annotations", viewer);
|
|
12080
|
-
|
|
12078
|
+
|
|
12081
12079
|
this._labelHTML = cfg.labelHTML || "<div></div>";
|
|
12082
12080
|
this._markerHTML = cfg.markerHTML || "<div></div>";
|
|
12083
12081
|
this._container = cfg.container || document.body;
|
|
12084
|
-
this._markerZIndex = cfg.markerZIndex || randomZIndex;
|
|
12085
|
-
this._labelZIndex = cfg.labelZIndex || randomZIndex;
|
|
12086
12082
|
this._values = cfg.values || {};
|
|
12087
12083
|
|
|
12088
12084
|
/**
|
|
@@ -12158,8 +12154,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
12158
12154
|
* @param {Number[]} [params.look] Optional World-space position for {@link Camera#look}, used when this Annotation is associated with a {@link Camera} position.
|
|
12159
12155
|
* @param {Number[]} [params.up] Optional World-space position for {@link Camera#up}, used when this Annotation is associated with a {@link Camera} position.
|
|
12160
12156
|
* @param {String} [params.projection] Optional projection type for {@link Camera#projection}, used when this Annotation is associated with a {@link Camera} position.
|
|
12161
|
-
* @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
12162
|
-
* @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
12163
12157
|
* @returns {Annotation} The new {@link Annotation}.
|
|
12164
12158
|
*/
|
|
12165
12159
|
createAnnotation(params) {
|
|
@@ -12211,9 +12205,7 @@ class AnnotationsPlugin extends Plugin {
|
|
|
12211
12205
|
markerElement: markerElement,
|
|
12212
12206
|
labelElement: labelElement,
|
|
12213
12207
|
markerHTML: params.markerHTML || this._markerHTML,
|
|
12214
|
-
markerZIndex : params.markerZIndex || this._markerZIndex,
|
|
12215
12208
|
labelHTML: params.labelHTML || this._labelHTML,
|
|
12216
|
-
labelZIndex : params.labelZIndex || this._labelZIndex,
|
|
12217
12209
|
occludable: params.occludable,
|
|
12218
12210
|
values: utils.apply(params.values, utils.apply(this._values, {})),
|
|
12219
12211
|
markerShown: params.markerShown,
|
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -323,7 +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.
|
|
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.
|
|
327
327
|
*/
|
|
328
328
|
constructor(cfg = {}) {
|
|
329
329
|
|
|
@@ -362,7 +362,7 @@ class ContextMenu {
|
|
|
362
362
|
this.items = cfg.items;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
this.
|
|
365
|
+
this._hideOnAction = (cfg.hideOnAction !== false);
|
|
366
366
|
|
|
367
367
|
this.context = cfg.context;
|
|
368
368
|
this.enabled = cfg.enabled !== false;
|
|
@@ -801,7 +801,7 @@ class ContextMenu {
|
|
|
801
801
|
if (item.doAction) {
|
|
802
802
|
item.doAction(self._context);
|
|
803
803
|
}
|
|
804
|
-
if (this.
|
|
804
|
+
if (this._hideOnAction) {
|
|
805
805
|
self.hide();
|
|
806
806
|
} else {
|
|
807
807
|
self._updateItemsTitles();
|
|
@@ -11521,12 +11521,12 @@ class Annotation extends Marker {
|
|
|
11521
11521
|
const canvasPos = this.canvasPos;
|
|
11522
11522
|
this._marker.style.left = (Math.floor(left + canvasPos[0]) - 12) + "px";
|
|
11523
11523
|
this._marker.style.top = (Math.floor(top + canvasPos[1]) - 12) + "px";
|
|
11524
|
-
this._marker.style["z-index"] =
|
|
11524
|
+
this._marker.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
|
|
11525
11525
|
const offsetX = 20;
|
|
11526
11526
|
const offsetY = -17;
|
|
11527
11527
|
this._label.style.left = 20 + Math.floor(left + canvasPos[0] + offsetX) + "px";
|
|
11528
11528
|
this._label.style.top = Math.floor(top + canvasPos[1] + offsetY) + "px";
|
|
11529
|
-
this._label.style["z-index"] =
|
|
11529
|
+
this._label.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
|
|
11530
11530
|
}
|
|
11531
11531
|
|
|
11532
11532
|
/**
|
|
@@ -12063,8 +12063,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
12063
12063
|
* @param {String} [cfg.id="Annotations"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
|
|
12064
12064
|
* @param {String} [cfg.markerHTML] HTML text template for Annotation markers. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````markerElementId````.
|
|
12065
12065
|
* @param {String} [cfg.labelHTML] HTML text template for Annotation labels. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````labelElementId````.
|
|
12066
|
-
* @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
12067
|
-
* @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
12068
12066
|
* @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
|
|
12069
12067
|
* @param {{String:(String|Number)}} [cfg.values={}] Map of default values to insert into the HTML templates for the marker and label.
|
|
12070
12068
|
* @param {Number} [cfg.surfaceOffset=0.3] The amount by which each {@link Annotation} is offset from the surface of
|
|
@@ -12073,12 +12071,10 @@ class AnnotationsPlugin extends Plugin {
|
|
|
12073
12071
|
constructor(viewer, cfg) {
|
|
12074
12072
|
|
|
12075
12073
|
super("Annotations", viewer);
|
|
12076
|
-
|
|
12074
|
+
|
|
12077
12075
|
this._labelHTML = cfg.labelHTML || "<div></div>";
|
|
12078
12076
|
this._markerHTML = cfg.markerHTML || "<div></div>";
|
|
12079
12077
|
this._container = cfg.container || document.body;
|
|
12080
|
-
this._markerZIndex = cfg.markerZIndex || randomZIndex;
|
|
12081
|
-
this._labelZIndex = cfg.labelZIndex || randomZIndex;
|
|
12082
12078
|
this._values = cfg.values || {};
|
|
12083
12079
|
|
|
12084
12080
|
/**
|
|
@@ -12154,8 +12150,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
12154
12150
|
* @param {Number[]} [params.look] Optional World-space position for {@link Camera#look}, used when this Annotation is associated with a {@link Camera} position.
|
|
12155
12151
|
* @param {Number[]} [params.up] Optional World-space position for {@link Camera#up}, used when this Annotation is associated with a {@link Camera} position.
|
|
12156
12152
|
* @param {String} [params.projection] Optional projection type for {@link Camera#projection}, used when this Annotation is associated with a {@link Camera} position.
|
|
12157
|
-
* @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
12158
|
-
* @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
12159
12153
|
* @returns {Annotation} The new {@link Annotation}.
|
|
12160
12154
|
*/
|
|
12161
12155
|
createAnnotation(params) {
|
|
@@ -12207,9 +12201,7 @@ class AnnotationsPlugin extends Plugin {
|
|
|
12207
12201
|
markerElement: markerElement,
|
|
12208
12202
|
labelElement: labelElement,
|
|
12209
12203
|
markerHTML: params.markerHTML || this._markerHTML,
|
|
12210
|
-
markerZIndex : params.markerZIndex || this._markerZIndex,
|
|
12211
12204
|
labelHTML: params.labelHTML || this._labelHTML,
|
|
12212
|
-
labelZIndex : params.labelZIndex || this._labelZIndex,
|
|
12213
12205
|
occludable: params.occludable,
|
|
12214
12206
|
values: utils.apply(params.values, utils.apply(this._values, {})),
|
|
12215
12207
|
markerShown: params.markerShown,
|
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -248,7 +248,7 @@ this.groups=[];this.menuElement=null;this.shown=false;this.mouseOver=0;});/**
|
|
|
248
248
|
* @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}.
|
|
249
249
|
* @param {Boolean} [cfg.enabled=true] Whether this ````ContextMenu```` is initially enabled. {@link ContextMenu#show} does nothing while this is ````false````.
|
|
250
250
|
* @param {Boolean} [cfg.hideOnMouseDown=true] Whether this ````ContextMenu```` automatically hides whenever we mouse-down or tap anywhere in the page.
|
|
251
|
-
* @param {Boolean} [cfg.
|
|
251
|
+
* @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.
|
|
252
252
|
*/function ContextMenu(){var _this=this;var cfg=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,ContextMenu);this._id=idMap.addItem();this._context=null;this._enabled=false;// True when the ContextMenu is enabled
|
|
253
253
|
this._itemsCfg=[];// Items as given as configs
|
|
254
254
|
this._rootMenu=null;// The root Menu in the tree
|
|
@@ -260,7 +260,7 @@ this._shown=false;// True when the ContextMenu is visible
|
|
|
260
260
|
this._nextId=0;/**
|
|
261
261
|
* Subscriptions to events fired at this ContextMenu.
|
|
262
262
|
* @private
|
|
263
|
-
*/this._eventSubs={};if(cfg.hideOnMouseDown!==false){document.addEventListener("mousedown",function(event){if(!event.target.classList.contains("xeokit-context-menu-item")){_this.hide();}});document.addEventListener("touchstart",this._canvasTouchStartHandler=function(event){if(!event.target.classList.contains("xeokit-context-menu-item")){_this.hide();}});}if(cfg.items){this.items=cfg.items;}this.
|
|
263
|
+
*/this._eventSubs={};if(cfg.hideOnMouseDown!==false){document.addEventListener("mousedown",function(event){if(!event.target.classList.contains("xeokit-context-menu-item")){_this.hide();}});document.addEventListener("touchstart",this._canvasTouchStartHandler=function(event){if(!event.target.classList.contains("xeokit-context-menu-item")){_this.hide();}});}if(cfg.items){this.items=cfg.items;}this._hideOnAction=cfg.hideOnAction!==false;this.context=cfg.context;this.enabled=cfg.enabled!==false;this.hide();}/**
|
|
264
264
|
Subscribes to an event fired at this ````ContextMenu````.
|
|
265
265
|
|
|
266
266
|
@param {String} event The event
|
|
@@ -337,7 +337,7 @@ var groups=menu.groups;var html=[];html.push('<div class="xeokit-context-menu '+
|
|
|
337
337
|
var self=this;var lastSubMenu=null;if(groups){for(var _i6=0,_len2=groups.length;_i6<_len2;_i6++){var _group=groups[_i6];var _groupItems=_group.items;if(_groupItems){var _loop2=function _loop2(_j,_lenj){var item=_groupItems[_j];var itemSubMenu=item.subMenu;item.itemElement=document.getElementById(item.id);if(!item.itemElement){console.error("ContextMenu item element not found: "+item.id);return"continue";}item.itemElement.addEventListener("mouseenter",function(event){event.preventDefault();var subMenu=item.subMenu;if(!subMenu){if(lastSubMenu){self._hideMenu(lastSubMenu.id);lastSubMenu=null;}return;}if(lastSubMenu&&lastSubMenu.id!==subMenu.id){self._hideMenu(lastSubMenu.id);lastSubMenu=null;}if(item.enabled===false){return;}var itemElement=item.itemElement;var subMenuElement=subMenu.menuElement;var itemRect=itemElement.getBoundingClientRect();subMenuElement.getBoundingClientRect();var subMenuWidth=200;// TODO
|
|
338
338
|
var showOnLeft=itemRect.right+subMenuWidth>window.innerWidth;if(showOnLeft){self._showMenu(subMenu.id,itemRect.left-subMenuWidth,itemRect.top-1);}else{self._showMenu(subMenu.id,itemRect.right-5,itemRect.top-1);}lastSubMenu=subMenu;});if(!itemSubMenu){// Item without sub-menu
|
|
339
339
|
// clicking item fires the item's action callback
|
|
340
|
-
item.itemElement.addEventListener("click",function(event){event.preventDefault();if(!self._context){return;}if(item.enabled===false){return;}if(item.doAction){item.doAction(self._context);}if(_this4.
|
|
340
|
+
item.itemElement.addEventListener("click",function(event){event.preventDefault();if(!self._context){return;}if(item.enabled===false){return;}if(item.doAction){item.doAction(self._context);}if(_this4._hideOnAction){self.hide();}else{self._updateItemsTitles();self._updateItemsEnabledStatus();}});item.itemElement.addEventListener("mouseenter",function(event){event.preventDefault();if(item.enabled===false){return;}if(item.doHover){item.doHover(self._context);}});}};for(var _j=0,_lenj=_groupItems.length;_j<_lenj;_j++){var _ret=_loop2(_j,_lenj);if(_ret==="continue")continue;}}}}}},{key:"_updateItemsTitles",value:function _updateItemsTitles(){// Dynamically updates the title of each Item to the result of Item#getTitle()
|
|
341
341
|
if(!this._context){return;}for(var _i7=0,len=this._itemList.length;_i7<len;_i7++){var item=this._itemList[_i7];var itemElement=item.itemElement;if(!itemElement){continue;}var getShown=item.getShown;if(!getShown||!getShown(this._context)){continue;}var title=item.getTitle(this._context);if(item.subMenu){itemElement.innerText=title;}else{itemElement.innerText=title;}}}},{key:"_updateItemsEnabledStatus",value:function _updateItemsEnabledStatus(){// Enables or disables each Item, depending on the result of Item#getEnabled()
|
|
342
342
|
if(!this._context){return;}for(var _i8=0,len=this._itemList.length;_i8<len;_i8++){var item=this._itemList[_i8];var itemElement=item.itemElement;if(!itemElement){continue;}var getEnabled=item.getEnabled;if(!getEnabled){continue;}var getShown=item.getShown;if(!getShown){continue;}var shown=getShown(this._context);item.shown=shown;if(!shown){itemElement.style.visibility="hidden";itemElement.style.height="0";itemElement.style.padding="0";continue;}else{itemElement.style.visibility="visible";itemElement.style.height="auto";itemElement.style.padding=null;}var enabled=getEnabled(this._context);item.enabled=enabled;if(!enabled){itemElement.classList.add("disabled");}else{itemElement.classList.remove("disabled");}}}},{key:"_showMenu",value:function _showMenu(menuId,pageX,pageY){// Shows the given menu, at the specified page coordinates
|
|
343
343
|
var menu=this._menuMap[menuId];if(!menu){console.error("Menu not found: "+menuId);return;}if(menu.shown){return;}var menuElement=menu.menuElement;if(menuElement){this._showMenuElement(menuElement,pageX,pageY);menu.shown=true;}}},{key:"_hideMenu",value:function _hideMenu(menuId){// Hides the given menu
|
|
@@ -2862,7 +2862,7 @@ _this13._currentAngleMeasurement.targetVisible=true;_this13._currentAngleMeasure
|
|
|
2862
2862
|
if(utils.isArray(markerHTML)){markerHTML=markerHTML.join("");}markerHTML=this._renderTemplate(markerHTML);var markerFragment=document.createRange().createContextualFragment(markerHTML);this._marker=markerFragment.firstChild;this._container.appendChild(this._marker);this._marker.style.visibility=this._markerShown?"visible":"hidden";this._marker.addEventListener("click",function(){_this17.plugin.fire("markerClicked",_this17);});this._marker.addEventListener("mouseenter",function(){_this17.plugin.fire("markerMouseEnter",_this17);});this._marker.addEventListener("mouseleave",function(){_this17.plugin.fire("markerMouseLeave",_this17);});}if(!this._labelExternal){if(this._label){this._container.removeChild(this._label);this._label=null;}var labelHTML=this._labelHTML||"<p></p>";// Make label
|
|
2863
2863
|
if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._renderTemplate(labelHTML);var labelFragment=document.createRange().createContextualFragment(labelHTML);this._label=labelFragment.firstChild;this._container.appendChild(this._label);this._label.style.visibility=this._markerShown&&this._labelShown?"visible":"hidden";}}/**
|
|
2864
2864
|
* @private
|
|
2865
|
-
*/},{key:"_updatePosition",value:function _updatePosition(){var boundary=this.scene.canvas.boundary;var left=boundary[0];var top=boundary[1];var canvasPos=this.canvasPos;this._marker.style.left=Math.floor(left+canvasPos[0])-12+"px";this._marker.style.top=Math.floor(top+canvasPos[1])-12+"px";this._marker.style["z-index"]=
|
|
2865
|
+
*/},{key:"_updatePosition",value:function _updatePosition(){var boundary=this.scene.canvas.boundary;var left=boundary[0];var top=boundary[1];var canvasPos=this.canvasPos;this._marker.style.left=Math.floor(left+canvasPos[0])-12+"px";this._marker.style.top=Math.floor(top+canvasPos[1])-12+"px";this._marker.style["z-index"]=90005+Math.floor(this._viewPos[2])+1;var offsetX=20;var offsetY=-17;this._label.style.left=20+Math.floor(left+canvasPos[0]+offsetX)+"px";this._label.style.top=Math.floor(top+canvasPos[1]+offsetY)+"px";this._label.style["z-index"]=90005+Math.floor(this._viewPos[2])+1;}/**
|
|
2866
2866
|
* @private
|
|
2867
2867
|
*/},{key:"_renderTemplate",value:function _renderTemplate(template){for(var key in this._values){if(this._values.hasOwnProperty(key)){var value=this._values[key];template=template.replace(new RegExp('{{'+key+'}}','g'),value);}}return template;}/**
|
|
2868
2868
|
* Sets whether or not to show this Annotation's marker.
|
|
@@ -3299,13 +3299,11 @@ if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._rende
|
|
|
3299
3299
|
* @param {String} [cfg.id="Annotations"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
|
|
3300
3300
|
* @param {String} [cfg.markerHTML] HTML text template for Annotation markers. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````markerElementId````.
|
|
3301
3301
|
* @param {String} [cfg.labelHTML] HTML text template for Annotation labels. Defaults to ````<div></div>````. Ignored on {@link Annotation}s configured with a ````labelElementId````.
|
|
3302
|
-
* @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
3303
|
-
* @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
3304
3302
|
* @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
|
|
3305
3303
|
* @param {{String:(String|Number)}} [cfg.values={}] Map of default values to insert into the HTML templates for the marker and label.
|
|
3306
3304
|
* @param {Number} [cfg.surfaceOffset=0.3] The amount by which each {@link Annotation} is offset from the surface of
|
|
3307
3305
|
* its {@link Entity} when we create the Annotation by supplying a {@link PickResult} to {@link AnnotationsPlugin#createAnnotation}.
|
|
3308
|
-
*/function AnnotationsPlugin(viewer,cfg){var _this18;_classCallCheck(this,AnnotationsPlugin);_this18=_super6.call(this,"Annotations",viewer);
|
|
3306
|
+
*/function AnnotationsPlugin(viewer,cfg){var _this18;_classCallCheck(this,AnnotationsPlugin);_this18=_super6.call(this,"Annotations",viewer);_this18._labelHTML=cfg.labelHTML||"<div></div>";_this18._markerHTML=cfg.markerHTML||"<div></div>";_this18._container=cfg.container||document.body;_this18._values=cfg.values||{};/**
|
|
3309
3307
|
* The {@link Annotation}s created by {@link AnnotationsPlugin#createAnnotation}, each mapped to its {@link Annotation#id}.
|
|
3310
3308
|
* @type {{String:Annotation}}
|
|
3311
3309
|
*/_this18.annotations={};_this18.surfaceOffset=cfg.surfaceOffset;return _this18;}/**
|
|
@@ -3350,10 +3348,8 @@ if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._rende
|
|
|
3350
3348
|
* @param {Number[]} [params.look] Optional World-space position for {@link Camera#look}, used when this Annotation is associated with a {@link Camera} position.
|
|
3351
3349
|
* @param {Number[]} [params.up] Optional World-space position for {@link Camera#up}, used when this Annotation is associated with a {@link Camera} position.
|
|
3352
3350
|
* @param {String} [params.projection] Optional projection type for {@link Camera#projection}, used when this Annotation is associated with a {@link Camera} position.
|
|
3353
|
-
* @param {Number} [cfg.markerZIndex] Custom value for Annotation markers z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
3354
|
-
* @param {Number} [cfg.labelZIndex] Custom value for Annotation labels z-index. Defaults to ````90005 + Math.floor(this._viewPos[2]) + 1````.
|
|
3355
3351
|
* @returns {Annotation} The new {@link Annotation}.
|
|
3356
|
-
*/,set:function set(surfaceOffset){if(surfaceOffset===undefined||surfaceOffset===null){surfaceOffset=0.3;}this._surfaceOffset=surfaceOffset;}},{key:"createAnnotation",value:function createAnnotation(params){var _this19=this;if(this.viewer.scene.components[params.id]){this.error("Viewer component with this ID already exists: "+params.id);delete params.id;}var worldPos;var entity;params.pickResult=params.pickResult||params.pickRecord;if(params.pickResult){var pickResult=params.pickResult;if(!pickResult.worldPos||!pickResult.worldNormal){this.error("Param 'pickResult' does not have both worldPos and worldNormal");}else{var normalizedWorldNormal=math.normalizeVec3(pickResult.worldNormal,tempVec3a$1h);var offsetVec=math.mulVec3Scalar(normalizedWorldNormal,this._surfaceOffset,tempVec3b$d);var offsetWorldPos=math.addVec3(pickResult.worldPos,offsetVec,tempVec3c$9);worldPos=offsetWorldPos;entity=pickResult.entity;}}else{worldPos=params.worldPos;entity=params.entity;}var markerElement=null;if(params.markerElementId){markerElement=document.getElementById(params.markerElementId);if(!markerElement){this.error("Can't find DOM element for 'markerElementId' value '"+params.markerElementId+"' - defaulting to internally-generated empty DIV");}}var labelElement=null;if(params.labelElementId){labelElement=document.getElementById(params.labelElementId);if(!labelElement){this.error("Can't find DOM element for 'labelElementId' value '"+params.labelElementId+"' - defaulting to internally-generated empty DIV");}}var annotation=new Annotation(this.viewer.scene,{id:params.id,plugin:this,entity:entity,worldPos:worldPos,container:this._container,markerElement:markerElement,labelElement:labelElement,markerHTML:params.markerHTML||this._markerHTML,
|
|
3352
|
+
*/,set:function set(surfaceOffset){if(surfaceOffset===undefined||surfaceOffset===null){surfaceOffset=0.3;}this._surfaceOffset=surfaceOffset;}},{key:"createAnnotation",value:function createAnnotation(params){var _this19=this;if(this.viewer.scene.components[params.id]){this.error("Viewer component with this ID already exists: "+params.id);delete params.id;}var worldPos;var entity;params.pickResult=params.pickResult||params.pickRecord;if(params.pickResult){var pickResult=params.pickResult;if(!pickResult.worldPos||!pickResult.worldNormal){this.error("Param 'pickResult' does not have both worldPos and worldNormal");}else{var normalizedWorldNormal=math.normalizeVec3(pickResult.worldNormal,tempVec3a$1h);var offsetVec=math.mulVec3Scalar(normalizedWorldNormal,this._surfaceOffset,tempVec3b$d);var offsetWorldPos=math.addVec3(pickResult.worldPos,offsetVec,tempVec3c$9);worldPos=offsetWorldPos;entity=pickResult.entity;}}else{worldPos=params.worldPos;entity=params.entity;}var markerElement=null;if(params.markerElementId){markerElement=document.getElementById(params.markerElementId);if(!markerElement){this.error("Can't find DOM element for 'markerElementId' value '"+params.markerElementId+"' - defaulting to internally-generated empty DIV");}}var labelElement=null;if(params.labelElementId){labelElement=document.getElementById(params.labelElementId);if(!labelElement){this.error("Can't find DOM element for 'labelElementId' value '"+params.labelElementId+"' - defaulting to internally-generated empty DIV");}}var annotation=new Annotation(this.viewer.scene,{id:params.id,plugin:this,entity:entity,worldPos:worldPos,container:this._container,markerElement:markerElement,labelElement:labelElement,markerHTML:params.markerHTML||this._markerHTML,labelHTML:params.labelHTML||this._labelHTML,occludable:params.occludable,values:utils.apply(params.values,utils.apply(this._values,{})),markerShown:params.markerShown,labelShown:params.labelShown,eye:params.eye,look:params.look,up:params.up,projection:params.projection,visible:params.visible!==false});this.annotations[annotation.id]=annotation;annotation.on("destroyed",function(){delete _this19.annotations[annotation.id];_this19.fire("annotationDestroyed",annotation.id);});this.fire("annotationCreated",annotation.id);return annotation;}/**
|
|
3357
3353
|
* Destroys an {@link Annotation}.
|
|
3358
3354
|
*
|
|
3359
3355
|
* @param {String} id ID of Annotation to destroy.
|