@xeokit/xeokit-sdk 2.5.2-beta-3 → 2.5.2-beta-5

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.
@@ -7569,6 +7569,15 @@ function renderScenes() {
7569
7569
 
7570
7570
  (window.requestPostAnimationFrame !== undefined) ? window.requestPostAnimationFrame(frame) : requestAnimationFrame(frame);
7571
7571
 
7572
+ function compileScenes() {
7573
+
7574
+ for (let id in core.scenes) {
7575
+ core.scenes[id].compile();
7576
+ }
7577
+ }
7578
+
7579
+ window.setInterval(compileScenes, 1000 / 60);
7580
+
7572
7581
  /**
7573
7582
  * @desc Base class for all xeokit components.
7574
7583
  *
@@ -28899,7 +28908,7 @@ class Scene extends Component {
28899
28908
  }
28900
28909
 
28901
28910
  _deRegisterColorizedObject(entity) {
28902
- delete this.colorizedObjects[entity.id];
28911
+ delete this.colorizedObjects[entity.id];
28903
28912
  this._numColorizedObjects--;
28904
28913
  this._colorizedObjectIds = null; // Lazy regenerate
28905
28914
  }
@@ -28916,7 +28925,7 @@ class Scene extends Component {
28916
28925
  }
28917
28926
 
28918
28927
  _deRegisterOpacityObject(entity) {
28919
- delete this.opacityObjects[entity.id];
28928
+ delete this.opacityObjects[entity.id];
28920
28929
  this._numOpacityObjects--;
28921
28930
  this._opacityObjectIds = null; // Lazy regenerate
28922
28931
  }
@@ -28933,7 +28942,7 @@ class Scene extends Component {
28933
28942
  }
28934
28943
 
28935
28944
  _deRegisterOffsetObject(entity) {
28936
- delete this.offsetObjects[entity.id];
28945
+ delete this.offsetObjects[entity.id];
28937
28946
  this._numOffsetObjects--;
28938
28947
  this._offsetObjectIds = null; // Lazy regenerate
28939
28948
  }
@@ -29206,6 +29215,18 @@ class Scene extends Component {
29206
29215
  this._saveAmbientColor();
29207
29216
  }
29208
29217
 
29218
+
29219
+ /**
29220
+ * @private
29221
+ */
29222
+ compile() {
29223
+ if (this._needRecompile) {
29224
+ this._recompile();
29225
+ this._renderer.imageDirty();
29226
+ this._needRecompile = false;
29227
+ }
29228
+ }
29229
+
29209
29230
  _recompile() {
29210
29231
  for (const id in this._compilables) {
29211
29232
  if (this._compilables.hasOwnProperty(id)) {
@@ -113997,6 +114018,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
113997
114018
 
113998
114019
  const cubeColor = "lightgrey";
113999
114020
  const cubeHighlightColor = cfg.hoverColor || "rgba(0,0,0,0.4)";
114021
+ const textColor = cfg.textColor || "black";
114000
114022
 
114001
114023
  const height = 500;
114002
114024
  const width = height + (height / 3);
@@ -114146,7 +114168,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
114146
114168
  }
114147
114169
  }
114148
114170
  if (area.label) {
114149
- context.fillStyle = "black";
114171
+ context.fillStyle = textColor;
114150
114172
  context.font = '60px sans-serif';
114151
114173
  context.textAlign = "center";
114152
114174
  var xcenter = xmin + (width * 0.5);
@@ -114350,7 +114372,7 @@ class NavCubePlugin extends Plugin {
114350
114372
  * @param {String} [cfg.cameraFly=true] Whether the {@link Camera} flies or jumps to each selected axis or diagonal.
114351
114373
  * @param {String} [cfg.cameraFitFOV=45] How much of the field-of-view, in degrees, that the 3D scene should fill the {@link Canvas} when the {@link Camera} moves to an axis or diagonal.
114352
114374
  * @param {String} [cfg.cameraFlyDuration=0.5] When flying the {@link Camera} to each new axis or diagonal, how long, in seconds, that the Camera takes to get there.
114353
- * @param {String} [cfg.color="lightgrey] Custom uniform color for the faces of the NavCube.
114375
+ * @param {String} [cfg.color="lightgrey"] Custom uniform color for the faces of the NavCube.
114354
114376
  * @param {String} [cfg.frontColor="#55FF55"] Custom color for the front face of the NavCube. Overrides ````color````.
114355
114377
  * @param {String} [cfg.backColor="#55FF55"] Custom color for the back face of the NavCube. Overrides ````color````.
114356
114378
  * @param {String} [cfg.leftColor="#FF5555"] Custom color for the left face of the NavCube. Overrides ````color````.
@@ -114358,6 +114380,7 @@ class NavCubePlugin extends Plugin {
114358
114380
  * @param {String} [cfg.topColor="#5555FF"] Custom color for the top face of the NavCube. Overrides ````color````.
114359
114381
  * @param {String} [cfg.bottomColor="#5555FF"] Custom color for the bottom face of the NavCube. Overrides ````color````.
114360
114382
  * @param {String} [cfg.hoverColor="rgba(0,0,0,0.4)"] Custom color for highlighting regions on the NavCube as we hover the pointer over them.
114383
+ * @param {String} [cfg.textColor="black"] Custom text color for labels of the NavCube.
114361
114384
  * @param {Boolean} [cfg.fitVisible=false] Sets whether the axis, corner and edge-aligned views will fit the
114362
114385
  * view to the entire {@link Scene} or just to visible object-{@link Entity}s. Entitys are visible objects when {@link Entity#isObject} and {@link Entity#visible} are both ````true````.
114363
114386
  * @param {Boolean} [cfg.synchProjection=false] Sets whether the NavCube switches between perspective and orthographic projections in synchrony with the {@link Camera}. When ````false````, the NavCube will always be rendered with perspective projection.
@@ -121060,6 +121083,176 @@ class STLLoaderPlugin extends Plugin {
121060
121083
  }
121061
121084
  }
121062
121085
 
121086
+ /**
121087
+ * @desc A {@link TreeViewPlugin} render class.
121088
+ *
121089
+ */
121090
+ class RenderService {
121091
+
121092
+ /*
121093
+ * Creates the root node of the tree.
121094
+ * @return {HTMLElement} The root node of the tree.
121095
+ */
121096
+ createRootNode() {
121097
+ return document.createElement('ul')
121098
+ }
121099
+
121100
+ /*
121101
+ * Creates node of the tree.
121102
+ * @param {Object} node The node to create.
121103
+
121104
+ * @return {HTMLElement} The html element for the node.
121105
+ */
121106
+ createNodeElement(node, expandHandler, checkHandler, contextmenuHandler, titleClickHandler) {
121107
+ const nodeElement = document.createElement('li');
121108
+ nodeElement.id = node.nodeId;
121109
+
121110
+ if (node.xrayed) {
121111
+ nodeElement.classList.add('xrayed-node');
121112
+ }
121113
+
121114
+ if (node.children.length > 0) {
121115
+ const switchElement = document.createElement('a');
121116
+ switchElement.href = '#';
121117
+ switchElement.id = `switch-${node.nodeId}`;
121118
+ switchElement.textContent = '+';
121119
+ switchElement.classList.add('plus');
121120
+ if (expandHandler) switchElement.addEventListener('click', expandHandler);
121121
+ nodeElement.appendChild(switchElement);
121122
+ }
121123
+
121124
+ const checkbox = document.createElement('input');
121125
+ checkbox.id = `checkbox-${node.nodeId}`;
121126
+ checkbox.type = "checkbox";
121127
+ checkbox.checked = node.checked;
121128
+ checkbox.style["pointer-events"] = "all";
121129
+ if (checkHandler) checkbox.addEventListener("change", checkHandler);
121130
+ nodeElement.appendChild(checkbox);
121131
+
121132
+ const span = document.createElement('span');
121133
+ span.textContent = node.title;
121134
+ nodeElement.appendChild(span);
121135
+
121136
+ if (contextmenuHandler) {
121137
+ span.oncontextmenu = contextmenuHandler;
121138
+ }
121139
+
121140
+ if (titleClickHandler) {
121141
+ span.onclick = titleClickHandler;
121142
+ }
121143
+
121144
+ return nodeElement;
121145
+ }
121146
+
121147
+ createDisabledNodeElement(rootName) {
121148
+ const li = document.createElement('li');
121149
+
121150
+ const switchElement = document.createElement('a');
121151
+ switchElement.href = '#';
121152
+ switchElement.textContent = '!';
121153
+ switchElement.classList.add('warn');
121154
+ switchElement.classList.add('warning');
121155
+ li.appendChild(switchElement);
121156
+
121157
+ const span = document.createElement('span');
121158
+ span.textContent = rootName;
121159
+ li.appendChild(span);
121160
+
121161
+ return li;
121162
+ }
121163
+
121164
+ addChildren(element, nodes) {
121165
+ const ul = document.createElement('ul');
121166
+ nodes.forEach((nodeElement) => {
121167
+ ul.appendChild(nodeElement);
121168
+ });
121169
+
121170
+ element.parentElement.appendChild(ul);
121171
+ }
121172
+
121173
+ expand(element, expandHandler, collapseHandler) {
121174
+ element.classList.remove('plus');
121175
+ element.classList.add('minus');
121176
+ element.textContent = '-';
121177
+ element.removeEventListener('click', expandHandler);
121178
+ element.addEventListener('click', collapseHandler);
121179
+ }
121180
+
121181
+ collapse(element, expandHandler, collapseHandler) {
121182
+ if (!element) {
121183
+ return;
121184
+ }
121185
+ const parent = element.parentElement;
121186
+ if (!parent) {
121187
+ return;
121188
+ }
121189
+ const ul = parent.querySelector('ul');
121190
+ if (!ul) {
121191
+ return;
121192
+ }
121193
+ parent.removeChild(ul);
121194
+ element.classList.remove('minus');
121195
+ element.classList.add('plus');
121196
+ element.textContent = '+';
121197
+ element.removeEventListener('click', collapseHandler);
121198
+ element.addEventListener('click', expandHandler);
121199
+ }
121200
+
121201
+ isExpanded(element) {
121202
+ const parentElement = element.parentElement;
121203
+ return parentElement.getElementsByTagName('li')[0] !== undefined;
121204
+ }
121205
+
121206
+ getId(element) {
121207
+ const parentElement = element.parentElement;
121208
+ return parentElement.id;
121209
+ }
121210
+
121211
+ getIdFromCheckbox(element) {
121212
+ return element.id.replace('checkbox-', '');
121213
+ }
121214
+
121215
+ getSwitchElement(nodeId) {
121216
+ return document.getElementById(`switch-${nodeId}`);
121217
+ }
121218
+
121219
+ isChecked(element) {
121220
+ return element.checked;
121221
+ }
121222
+
121223
+ setCheckbox(nodeId, checked) {
121224
+ const checkbox = document.getElementById(`checkbox-${nodeId}`);
121225
+ if (checkbox) {
121226
+ if (checked !== checkbox.checked) {
121227
+ checkbox.checked = checked;
121228
+ }
121229
+ }
121230
+ }
121231
+
121232
+ setXRayed(nodeId, xrayed) {
121233
+ const treeNode = document.getElementById(nodeId);
121234
+ if (treeNode) {
121235
+ if (xrayed) {
121236
+ treeNode.classList.add('xrayed-node');
121237
+ } else {
121238
+ treeNode.classList.remove('xrayed-node');
121239
+ }
121240
+ }
121241
+ }
121242
+
121243
+ setHighlighted(nodeId, highlighted) {
121244
+ const treeNode = document.getElementById(nodeId);
121245
+ if (treeNode) {
121246
+ if (highlighted) {
121247
+ treeNode.scrollIntoView({block: "center"});
121248
+ treeNode.classList.add('highlighted-node');
121249
+ } else {
121250
+ treeNode.classList.remove('highlighted-node');
121251
+ }
121252
+ }
121253
+ }
121254
+ }
121255
+
121063
121256
  const treeViews = [];
121064
121257
 
121065
121258
  /**
@@ -121419,6 +121612,7 @@ class TreeViewPlugin extends Plugin {
121419
121612
  * ````IfcBuildingStorey```` nodes will be ordered spatially, from the highest storey down to the lowest, on the
121420
121613
  * vertical World axis. For all hierarchy types, other node types will be ordered in the ascending alphanumeric order of their titles.
121421
121614
  * @param {Boolean} [cfg.pruneEmptyNodes=true] When true, will not contain nodes that don't have content in the {@link Scene}. These are nodes whose {@link MetaObject}s don't have {@link Entity}s.
121615
+ * @param {RenderService} [cfg.renderService] Optional {@link RenderService} to use. Defaults to the {@link TreeViewPlugin}'s default {@link RenderService}.
121422
121616
  */
121423
121617
  constructor(viewer, cfg = {}) {
121424
121618
 
@@ -121458,7 +121652,6 @@ class TreeViewPlugin extends Plugin {
121458
121652
  this._autoAddModels = (cfg.autoAddModels !== false);
121459
121653
  this._autoExpandDepth = (cfg.autoExpandDepth || 0);
121460
121654
  this._sortNodes = (cfg.sortNodes !== false);
121461
- this._pruneEmptyNodes = (cfg.pruneEmptyNodes !== false);
121462
121655
  this._viewer = viewer;
121463
121656
  this._rootElement = null;
121464
121657
  this._muteSceneEvents = false;
@@ -121466,10 +121659,15 @@ class TreeViewPlugin extends Plugin {
121466
121659
  this._rootNodes = [];
121467
121660
  this._objectNodes = {}; // Object ID -> Node
121468
121661
  this._nodeNodes = {}; // Node ID -> Node
121469
- this._rootName = cfg.rootName;
121662
+ this._rootNames = {}; // Node ID -> Root name
121470
121663
  this._sortNodes = cfg.sortNodes;
121471
121664
  this._pruneEmptyNodes = cfg.pruneEmptyNodes;
121472
121665
  this._showListItemElementId = null;
121666
+ this._renderService = cfg.renderService || new RenderService();
121667
+
121668
+ if (!this._renderService) {
121669
+ throw new Error('TreeViewPlugin: no render service set');
121670
+ }
121473
121671
 
121474
121672
  this._containerElement.oncontextmenu = (e) => {
121475
121673
  e.preventDefault();
@@ -121496,10 +121694,9 @@ class TreeViewPlugin extends Plugin {
121496
121694
  } else {
121497
121695
  node.numVisibleEntities--;
121498
121696
  }
121499
- const checkbox = document.getElementById(`checkbox-${node.nodeId}`);
121500
- if (checkbox) {
121501
- checkbox.checked = visible;
121502
- }
121697
+
121698
+ this._renderService.setCheckbox(node.nodeId, visible);
121699
+
121503
121700
  let parent = node.parent;
121504
121701
  while (parent) {
121505
121702
  parent.checked = visible;
@@ -121508,15 +121705,12 @@ class TreeViewPlugin extends Plugin {
121508
121705
  } else {
121509
121706
  parent.numVisibleEntities--;
121510
121707
  }
121511
- const parentCheckbox = document.getElementById(`checkbox-${parent.nodeId}`);
121512
- if (parentCheckbox) {
121513
- const newChecked = (parent.numVisibleEntities > 0);
121514
- if (newChecked !== parentCheckbox.checked) {
121515
- parentCheckbox.checked = newChecked;
121516
- }
121517
- }
121708
+
121709
+ this._renderService.setCheckbox(parent.nodeId, (parent.numVisibleEntities > 0));
121710
+
121518
121711
  parent = parent.parent;
121519
121712
  }
121713
+
121520
121714
  this._muteTreeEvents = false;
121521
121715
  });
121522
121716
 
@@ -121536,15 +121730,8 @@ class TreeViewPlugin extends Plugin {
121536
121730
  return;
121537
121731
  }
121538
121732
  node.xrayed = xrayed;
121539
- const listItemElementId = node.nodeId;
121540
- const listItemElement = document.getElementById(listItemElementId);
121541
- if (listItemElement !== null) {
121542
- if (xrayed) {
121543
- listItemElement.classList.add('xrayed-node');
121544
- } else {
121545
- listItemElement.classList.remove('xrayed-node');
121546
- }
121547
- }
121733
+
121734
+ this._renderService.setXRayed(node.nodeId, xrayed);
121548
121735
  this._muteTreeEvents = false;
121549
121736
  });
121550
121737
 
@@ -121568,14 +121755,15 @@ class TreeViewPlugin extends Plugin {
121568
121755
  }
121569
121756
  this._muteSceneEvents = true;
121570
121757
  const checkbox = event.target;
121571
- const visible = checkbox.checked;
121572
- const nodeId = checkbox.id.replace('checkbox-', '');
121758
+ const visible = this._renderService.isChecked(checkbox);
121759
+ const nodeId = this._renderService.getIdFromCheckbox(checkbox);
121760
+
121573
121761
  const checkedNode = this._nodeNodes[nodeId];
121574
121762
  const objects = this._viewer.scene.objects;
121575
121763
  let numUpdated = 0;
121764
+
121576
121765
  this._withNodeTree(checkedNode, (node) => {
121577
121766
  const objectId = node.objectId;
121578
- const checkBoxId = `checkbox-${node.nodeId}`;
121579
121767
  const entity = objects[objectId];
121580
121768
  const isLeaf = (node.children.length === 0);
121581
121769
  node.numVisibleEntities = visible ? node.numEntities : 0;
@@ -121583,27 +121771,26 @@ class TreeViewPlugin extends Plugin {
121583
121771
  numUpdated++;
121584
121772
  }
121585
121773
  node.checked = visible;
121586
- const checkbox2 = document.getElementById(checkBoxId);
121587
- if (checkbox2) {
121588
- checkbox2.checked = visible;
121589
- }
121774
+
121775
+ this._renderService.setCheckbox(node.nodeId, visible);
121776
+
121590
121777
  if (entity) {
121591
121778
  entity.visible = visible;
121592
121779
  }
121593
121780
  });
121781
+
121594
121782
  let parent = checkedNode.parent;
121595
121783
  while (parent) {
121596
121784
  parent.checked = visible;
121597
- const checkbox2 = document.getElementById(`checkbox-${parent.nodeId}`); // Parent checkboxes are always in DOM
121785
+
121598
121786
  if (visible) {
121599
121787
  parent.numVisibleEntities += numUpdated;
121600
121788
  } else {
121601
121789
  parent.numVisibleEntities -= numUpdated;
121602
121790
  }
121603
- const newChecked = (parent.numVisibleEntities > 0);
121604
- if (newChecked !== checkbox2.checked) {
121605
- checkbox2.checked = newChecked;
121606
- }
121791
+
121792
+ this._renderService.setCheckbox(parent.nodeId, (parent.numVisibleEntities > 0));
121793
+
121607
121794
  parent = parent.parent;
121608
121795
  }
121609
121796
  this._muteSceneEvents = false;
@@ -121701,6 +121888,11 @@ class TreeViewPlugin extends Plugin {
121701
121888
  return;
121702
121889
  }
121703
121890
  this._metaModels[modelId] = metaModel;
121891
+
121892
+ if (options && options.rootName) {
121893
+ this._rootNames[modelId] = options.rootName;
121894
+ }
121895
+
121704
121896
  model.on("destroyed", () => {
121705
121897
  this.removeModel(model.id);
121706
121898
  });
@@ -121722,6 +121914,11 @@ class TreeViewPlugin extends Plugin {
121722
121914
  if (!metaModel) {
121723
121915
  return;
121724
121916
  }
121917
+
121918
+ if (this._rootNames[modelId]) {
121919
+ delete this._rootNames[modelId];
121920
+ }
121921
+
121725
121922
  delete this._metaModels[modelId];
121726
121923
  this._createNodes();
121727
121924
  }
@@ -121743,21 +121940,22 @@ class TreeViewPlugin extends Plugin {
121743
121940
  * @param {String} objectId ID of the {@link Entity}.
121744
121941
  */
121745
121942
  showNode(objectId) {
121746
- if (this._showListItemElementId) {
121747
- this.unShowNode();
121748
- }
121943
+ this.unShowNode();
121944
+
121749
121945
  const node = this._objectNodes[objectId];
121750
121946
  if (!node) {
121751
121947
  return; // Node may not exist for the given object if (this._pruneEmptyNodes == true)
121752
121948
  }
121949
+
121753
121950
  const nodeId = node.nodeId;
121754
- const switchElementId = "switch-" + nodeId;
121755
- const switchElement = document.getElementById(switchElementId);
121951
+
121952
+ const switchElement = this._renderService.getSwitchElement(nodeId);
121756
121953
  if (switchElement) {
121757
121954
  this._expandSwitchElement(switchElement);
121758
121955
  switchElement.scrollIntoView();
121759
- return;
121956
+ return true;
121760
121957
  }
121958
+
121761
121959
  const path = [];
121762
121960
  path.unshift(node);
121763
121961
  let parent = node.parent;
@@ -121765,20 +121963,17 @@ class TreeViewPlugin extends Plugin {
121765
121963
  path.unshift(parent);
121766
121964
  parent = parent.parent;
121767
121965
  }
121966
+
121768
121967
  for (let i = 0, len = path.length; i < len; i++) {
121769
- const node = path[i];
121770
- const nodeId = node.nodeId;
121771
- const switchElementId = "switch-" + nodeId;
121772
- const switchElement = document.getElementById(switchElementId);
121968
+ const switchElement = this._renderService.getSwitchElement(path[i].nodeId);
121773
121969
  if (switchElement) {
121774
121970
  this._expandSwitchElement(switchElement);
121775
121971
  }
121776
121972
  }
121777
- const listItemElementId = nodeId;
121778
- const listItemElement = document.getElementById(listItemElementId);
121779
- listItemElement.scrollIntoView({block: "center"});
121780
- listItemElement.classList.add("highlighted-node");
121781
- this._showListItemElementId = listItemElementId;
121973
+
121974
+ this._renderService.setHighlighted(nodeId, true);
121975
+
121976
+ this._showListItemElementId = nodeId;
121782
121977
  }
121783
121978
 
121784
121979
  /**
@@ -121792,12 +121987,9 @@ class TreeViewPlugin extends Plugin {
121792
121987
  if (!this._showListItemElementId) {
121793
121988
  return;
121794
121989
  }
121795
- const listItemElement = document.getElementById(this._showListItemElementId);
121796
- if (!listItemElement) {
121797
- this._showListItemElementId = null;
121798
- return;
121799
- }
121800
- listItemElement.classList.remove("highlighted-node");
121990
+
121991
+ this._renderService.setHighlighted(this._showListItemElementId, false);
121992
+
121801
121993
  this._showListItemElementId = null;
121802
121994
  }
121803
121995
 
@@ -121814,9 +122006,8 @@ class TreeViewPlugin extends Plugin {
121814
122006
  if (countDepth === depth) {
121815
122007
  return;
121816
122008
  }
121817
- const nodeId = node.nodeId;
121818
- const switchElementId = "switch-" + nodeId;
121819
- const switchElement = document.getElementById(switchElementId);
122009
+
122010
+ const switchElement = this._renderService.getSwitchElement(node.nodeId);
121820
122011
  if (switchElement) {
121821
122012
  this._expandSwitchElement(switchElement);
121822
122013
  const childNodes = node.children;
@@ -121971,11 +122162,12 @@ class TreeViewPlugin extends Plugin {
121971
122162
 
121972
122163
  _createDisabledNodes() {
121973
122164
 
121974
- const ul = document.createElement('ul');
121975
- this._rootElement = ul;
121976
- this._containerElement.appendChild(ul);
122165
+ const rootNode = this._renderService.createRootNode();
122166
+ this._rootElement = rootNode;
122167
+ this._containerElement.appendChild(rootNode);
121977
122168
 
121978
122169
  const rootMetaObjects = this._viewer.metaScene.rootMetaObjects;
122170
+
121979
122171
  for (let objectId in rootMetaObjects) {
121980
122172
  const rootMetaObject = rootMetaObjects[objectId];
121981
122173
  const metaObjectType = rootMetaObject.type;
@@ -121983,17 +122175,9 @@ class TreeViewPlugin extends Plugin {
121983
122175
  const rootName = ((metaObjectName && metaObjectName !== ""
121984
122176
  && metaObjectName !== "Undefined"
121985
122177
  && metaObjectName !== "Default") ? metaObjectName : metaObjectType);
121986
- const li = document.createElement('li');
121987
- ul.appendChild(li);
121988
- const switchElement = document.createElement('a');
121989
- switchElement.href = '#';
121990
- switchElement.textContent = '!';
121991
- switchElement.classList.add('warn');
121992
- switchElement.classList.add('warning');
121993
- li.appendChild(switchElement);
121994
- const span = document.createElement('span');
121995
- span.textContent = rootName;
121996
- li.appendChild(span);
122178
+
122179
+ const childNode = this._renderService.createDisabledNodeElement(rootName);
122180
+ rootNode.appendChild(childNode);
121997
122181
  }
121998
122182
  }
121999
122183
 
@@ -122044,7 +122228,7 @@ class TreeViewPlugin extends Plugin {
122044
122228
  buildingNode = {
122045
122229
  nodeId: `${this._id}-${objectId}`,
122046
122230
  objectId: objectId,
122047
- title: this._rootName || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122231
+ title: this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122048
122232
  type: metaObjectType,
122049
122233
  parent: null,
122050
122234
  numEntities: 0,
@@ -122147,7 +122331,7 @@ class TreeViewPlugin extends Plugin {
122147
122331
  rootNode = {
122148
122332
  nodeId: `${this._id}-${objectId}`,
122149
122333
  objectId: objectId,
122150
- title: this._rootName || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122334
+ title: this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
122151
122335
  type: metaObjectType,
122152
122336
  parent: null,
122153
122337
  numEntities: 0,
@@ -122228,7 +122412,7 @@ class TreeViewPlugin extends Plugin {
122228
122412
  const node = {
122229
122413
  nodeId: `${this._id}-${objectId}`,
122230
122414
  objectId: objectId,
122231
- title: (!parent) ? (this._rootName || metaObjectName) : (metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType,
122415
+ title: (!parent) ? (this._rootNames[metaObject.metaModels[0].id] || metaObjectName) : (metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType,
122232
122416
  type: metaObjectType,
122233
122417
  parent: parent,
122234
122418
  numEntities: 0,
@@ -122376,112 +122560,63 @@ class TreeViewPlugin extends Plugin {
122376
122560
  const rootNodeElements = this._rootNodes.map((rootNode) => {
122377
122561
  return this._createNodeElement(rootNode);
122378
122562
  });
122379
- const ul = document.createElement('ul');
122563
+
122564
+ const rootNode = this._renderService.createRootNode();
122380
122565
  rootNodeElements.forEach((nodeElement) => {
122381
- ul.appendChild(nodeElement);
122566
+ rootNode.appendChild(nodeElement);
122382
122567
  });
122383
- this._containerElement.appendChild(ul);
122384
- this._rootElement = ul;
122568
+
122569
+ this._containerElement.appendChild(rootNode);
122570
+ this._rootElement = rootNode;
122385
122571
  }
122386
122572
 
122387
122573
  _createNodeElement(node) {
122388
- const nodeElement = document.createElement('li');
122389
- //const nodeId = this._objectToNodeID(node.objectId);
122390
- const nodeId = node.nodeId;
122391
- if (node.xrayed) {
122392
- nodeElement.classList.add('xrayed-node');
122393
- }
122394
- nodeElement.id = nodeId;
122395
- if (node.children.length > 0) {
122396
- const switchElementId = "switch-" + nodeId;
122397
- const switchElement = document.createElement('a');
122398
- switchElement.href = '#';
122399
- switchElement.id = switchElementId;
122400
- switchElement.textContent = '+';
122401
- switchElement.classList.add('plus');
122402
- switchElement.addEventListener('click', this._switchExpandHandler);
122403
- nodeElement.appendChild(switchElement);
122404
- }
122405
- const checkbox = document.createElement('input');
122406
- checkbox.id = `checkbox-${nodeId}`;
122407
- checkbox.type = "checkbox";
122408
- checkbox.checked = node.checked;
122409
- checkbox.style["pointer-events"] = "all";
122410
- checkbox.addEventListener("change", this._checkboxChangeHandler);
122411
- nodeElement.appendChild(checkbox);
122412
- const span = document.createElement('span');
122413
- span.textContent = node.title;
122414
- nodeElement.appendChild(span);
122415
- span.oncontextmenu = (e) => {
122416
- this.fire("contextmenu", {
122417
- event: e,
122574
+ const contextmenuHandler = (event) =>{
122575
+ this.fire("contextmenu", {
122576
+ event: event,
122418
122577
  viewer: this._viewer,
122419
122578
  treeViewPlugin: this,
122420
122579
  treeViewNode: node
122421
122580
  });
122422
- e.preventDefault();
122581
+ event.preventDefault();
122423
122582
  };
122424
- span.onclick = (e) => {
122583
+ const onclickHandler = (event) => {
122425
122584
  this.fire("nodeTitleClicked", {
122426
- event: e,
122585
+ event: event,
122427
122586
  viewer: this._viewer,
122428
122587
  treeViewPlugin: this,
122429
122588
  treeViewNode: node
122430
122589
  });
122431
- e.preventDefault();
122590
+ event.preventDefault();
122432
122591
  };
122433
- return nodeElement;
122592
+
122593
+ return this._renderService.createNodeElement(node, this._switchExpandHandler, this._checkboxChangeHandler, contextmenuHandler, onclickHandler);
122434
122594
  }
122435
122595
 
122436
122596
  _expandSwitchElement(switchElement) {
122437
- const parentElement = switchElement.parentElement;
122438
- const expanded = parentElement.getElementsByTagName('li')[0];
122597
+ const expanded = this._renderService.isExpanded(switchElement);
122439
122598
  if (expanded) {
122440
122599
  return;
122441
122600
  }
122442
- const nodeId = parentElement.id;
122443
- const switchNode = this._nodeNodes[nodeId];
122444
- const childNodes = switchNode.children;
122445
- const nodeElements = childNodes.map((node) => {
122601
+
122602
+ const nodeId = this._renderService.getId(switchElement);
122603
+
122604
+ const nodeElements = this._nodeNodes[nodeId].children.map((node) => {
122446
122605
  return this._createNodeElement(node);
122447
122606
  });
122448
- const ul = document.createElement('ul');
122449
- nodeElements.forEach((nodeElement) => {
122450
- ul.appendChild(nodeElement);
122451
- });
122452
- parentElement.appendChild(ul);
122453
- switchElement.classList.remove('plus');
122454
- switchElement.classList.add('minus');
122455
- switchElement.textContent = '-';
122456
- switchElement.removeEventListener('click', this._switchExpandHandler);
122457
- switchElement.addEventListener('click', this._switchCollapseHandler);
122458
- }
122459
-
122460
- _collapseNode(objectId) {
122461
- const nodeId = objectId;
122462
- const switchElementId = "switch-" + nodeId;
122463
- const switchElement = document.getElementById(switchElementId);
122607
+
122608
+ this._renderService.addChildren(switchElement, nodeElements);
122609
+
122610
+ this._renderService.expand(switchElement, this._switchExpandHandler, this._switchCollapseHandler);
122611
+ }
122612
+
122613
+ _collapseNode(nodeId) {
122614
+ const switchElement = this._renderService.getSwitchElement(nodeId);
122464
122615
  this._collapseSwitchElement(switchElement);
122465
122616
  }
122466
122617
 
122467
122618
  _collapseSwitchElement(switchElement) {
122468
- if (!switchElement) {
122469
- return;
122470
- }
122471
- const parent = switchElement.parentElement;
122472
- if (!parent) {
122473
- return;
122474
- }
122475
- const ul = parent.querySelector('ul');
122476
- if (!ul) {
122477
- return;
122478
- }
122479
- parent.removeChild(ul);
122480
- switchElement.classList.remove('minus');
122481
- switchElement.classList.add('plus');
122482
- switchElement.textContent = '+';
122483
- switchElement.removeEventListener('click', this._switchCollapseHandler);
122484
- switchElement.addEventListener('click', this._switchExpandHandler);
122619
+ this._renderService.collapse(switchElement, this._switchExpandHandler, this._switchCollapseHandler);
122485
122620
  }
122486
122621
  }
122487
122622
 
@@ -126966,9 +127101,9 @@ parsers[ParserV10.version] = ParserV10;
126966
127101
  * }
126967
127102
  *
126968
127103
  * // Gets the contents of the given .XKT file in an arraybuffer
126969
- * getXKT(src, ok, error) {
127104
+ * getXKT(xKTSrc, ok, error) {
126970
127105
  * console.log("MyDataSource#getXKT(" + xKTSrc + ", ... )");
126971
- * utils.loadArraybuffer(src,
127106
+ * utils.loadArraybuffer(xKTSrc,
126972
127107
  * (arraybuffer) => {
126973
127108
  * ok(arraybuffer);
126974
127109
  * },
@@ -127568,13 +127703,14 @@ class XKTLoaderPlugin extends Plugin {
127568
127703
  sceneModel.once("destroyed", () => {
127569
127704
  this.viewer.metaScene.destroyMetaModel(metaModel.id);
127570
127705
  });
127571
- sceneModel.scene.once("tick", () => {
127706
+ window.setTimeout(() => {
127707
+
127572
127708
  if (sceneModel.destroyed) {
127573
127709
  return;
127574
127710
  }
127575
127711
  sceneModel.scene.fire("modelLoaded", sceneModel.id); // FIXME: Assumes listeners know order of these two events
127576
127712
  sceneModel.fire("loaded", true, false); // Don't forget the event, for late subscribers
127577
- });
127713
+ }, 100);
127578
127714
  };
127579
127715
 
127580
127716
  const error = (errMsg) => {
@@ -127652,7 +127788,7 @@ class XKTLoaderPlugin extends Plugin {
127652
127788
  globalizeObjectIds: options.globalizeObjectIds
127653
127789
  });
127654
127790
  i++;
127655
- this.viewer.scene.once("tick", loadNext);
127791
+ window.setTimeout( loadNext, 100);
127656
127792
  }, error);
127657
127793
  }
127658
127794
  };
@@ -127667,7 +127803,7 @@ class XKTLoaderPlugin extends Plugin {
127667
127803
  this._dataSource.getXKT(`${baseDir}${xktFiles[i]}`, (arrayBuffer) => {
127668
127804
  this._parseModel(arrayBuffer, params, options, sceneModel, metaModel, manifestCtx);
127669
127805
  i++;
127670
- this.viewer.scene.once("tick", loadNext);
127806
+ window.setTimeout(loadNext, 100);
127671
127807
  }, error);
127672
127808
  }
127673
127809
  };