@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.
- package/dist/xeokit-sdk.cjs.js +300 -164
- package/dist/xeokit-sdk.es.js +300 -164
- package/dist/xeokit-sdk.es5.js +41 -27
- package/dist/xeokit-sdk.min.cjs.js +3 -3
- package/dist/xeokit-sdk.min.es.js +3 -3
- package/dist/xeokit-sdk.min.es5.js +2 -2
- package/package.json +1 -1
- package/src/plugins/NavCubePlugin/CubeTextureCanvas.js +2 -1
- package/src/plugins/NavCubePlugin/NavCubePlugin.js +2 -1
- package/src/plugins/TreeViewPlugin/RenderService.js +169 -0
- package/src/plugins/TreeViewPlugin/TreeViewPlugin.js +94 -151
- package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +7 -6
- package/src/viewer/scene/core.js +9 -0
- package/src/viewer/scene/scene/Scene.js +15 -3
- package/types/plugins/NavCubePlugin/NavCubePlugin.d.ts +2 -0
- package/types/plugins/TreeViewPlugin/TreeViewPlugin.d.ts +18 -22
- package/types/plugins/TreeViewPlugin/renderService.d.ts +128 -0
- package/types/viewer/Configs.d.ts +26 -0
- package/types/viewer/Viewer.d.ts +10 -4
- package/types/plugins/TreeViewPlugin/ModelTreeView.d.ts +0 -24
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -7565,6 +7565,15 @@ function renderScenes() {
|
|
|
7565
7565
|
|
|
7566
7566
|
(window.requestPostAnimationFrame !== undefined) ? window.requestPostAnimationFrame(frame) : requestAnimationFrame(frame);
|
|
7567
7567
|
|
|
7568
|
+
function compileScenes() {
|
|
7569
|
+
|
|
7570
|
+
for (let id in core.scenes) {
|
|
7571
|
+
core.scenes[id].compile();
|
|
7572
|
+
}
|
|
7573
|
+
}
|
|
7574
|
+
|
|
7575
|
+
window.setInterval(compileScenes, 1000 / 60);
|
|
7576
|
+
|
|
7568
7577
|
/**
|
|
7569
7578
|
* @desc Base class for all xeokit components.
|
|
7570
7579
|
*
|
|
@@ -28895,7 +28904,7 @@ class Scene extends Component {
|
|
|
28895
28904
|
}
|
|
28896
28905
|
|
|
28897
28906
|
_deRegisterColorizedObject(entity) {
|
|
28898
|
-
|
|
28907
|
+
delete this.colorizedObjects[entity.id];
|
|
28899
28908
|
this._numColorizedObjects--;
|
|
28900
28909
|
this._colorizedObjectIds = null; // Lazy regenerate
|
|
28901
28910
|
}
|
|
@@ -28912,7 +28921,7 @@ class Scene extends Component {
|
|
|
28912
28921
|
}
|
|
28913
28922
|
|
|
28914
28923
|
_deRegisterOpacityObject(entity) {
|
|
28915
|
-
|
|
28924
|
+
delete this.opacityObjects[entity.id];
|
|
28916
28925
|
this._numOpacityObjects--;
|
|
28917
28926
|
this._opacityObjectIds = null; // Lazy regenerate
|
|
28918
28927
|
}
|
|
@@ -28929,7 +28938,7 @@ class Scene extends Component {
|
|
|
28929
28938
|
}
|
|
28930
28939
|
|
|
28931
28940
|
_deRegisterOffsetObject(entity) {
|
|
28932
|
-
|
|
28941
|
+
delete this.offsetObjects[entity.id];
|
|
28933
28942
|
this._numOffsetObjects--;
|
|
28934
28943
|
this._offsetObjectIds = null; // Lazy regenerate
|
|
28935
28944
|
}
|
|
@@ -29202,6 +29211,18 @@ class Scene extends Component {
|
|
|
29202
29211
|
this._saveAmbientColor();
|
|
29203
29212
|
}
|
|
29204
29213
|
|
|
29214
|
+
|
|
29215
|
+
/**
|
|
29216
|
+
* @private
|
|
29217
|
+
*/
|
|
29218
|
+
compile() {
|
|
29219
|
+
if (this._needRecompile) {
|
|
29220
|
+
this._recompile();
|
|
29221
|
+
this._renderer.imageDirty();
|
|
29222
|
+
this._needRecompile = false;
|
|
29223
|
+
}
|
|
29224
|
+
}
|
|
29225
|
+
|
|
29205
29226
|
_recompile() {
|
|
29206
29227
|
for (const id in this._compilables) {
|
|
29207
29228
|
if (this._compilables.hasOwnProperty(id)) {
|
|
@@ -113993,6 +114014,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
|
|
|
113993
114014
|
|
|
113994
114015
|
const cubeColor = "lightgrey";
|
|
113995
114016
|
const cubeHighlightColor = cfg.hoverColor || "rgba(0,0,0,0.4)";
|
|
114017
|
+
const textColor = cfg.textColor || "black";
|
|
113996
114018
|
|
|
113997
114019
|
const height = 500;
|
|
113998
114020
|
const width = height + (height / 3);
|
|
@@ -114142,7 +114164,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
|
|
|
114142
114164
|
}
|
|
114143
114165
|
}
|
|
114144
114166
|
if (area.label) {
|
|
114145
|
-
context.fillStyle =
|
|
114167
|
+
context.fillStyle = textColor;
|
|
114146
114168
|
context.font = '60px sans-serif';
|
|
114147
114169
|
context.textAlign = "center";
|
|
114148
114170
|
var xcenter = xmin + (width * 0.5);
|
|
@@ -114346,7 +114368,7 @@ class NavCubePlugin extends Plugin {
|
|
|
114346
114368
|
* @param {String} [cfg.cameraFly=true] Whether the {@link Camera} flies or jumps to each selected axis or diagonal.
|
|
114347
114369
|
* @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.
|
|
114348
114370
|
* @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.
|
|
114349
|
-
* @param {String} [cfg.color="lightgrey] Custom uniform color for the faces of the NavCube.
|
|
114371
|
+
* @param {String} [cfg.color="lightgrey"] Custom uniform color for the faces of the NavCube.
|
|
114350
114372
|
* @param {String} [cfg.frontColor="#55FF55"] Custom color for the front face of the NavCube. Overrides ````color````.
|
|
114351
114373
|
* @param {String} [cfg.backColor="#55FF55"] Custom color for the back face of the NavCube. Overrides ````color````.
|
|
114352
114374
|
* @param {String} [cfg.leftColor="#FF5555"] Custom color for the left face of the NavCube. Overrides ````color````.
|
|
@@ -114354,6 +114376,7 @@ class NavCubePlugin extends Plugin {
|
|
|
114354
114376
|
* @param {String} [cfg.topColor="#5555FF"] Custom color for the top face of the NavCube. Overrides ````color````.
|
|
114355
114377
|
* @param {String} [cfg.bottomColor="#5555FF"] Custom color for the bottom face of the NavCube. Overrides ````color````.
|
|
114356
114378
|
* @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.
|
|
114379
|
+
* @param {String} [cfg.textColor="black"] Custom text color for labels of the NavCube.
|
|
114357
114380
|
* @param {Boolean} [cfg.fitVisible=false] Sets whether the axis, corner and edge-aligned views will fit the
|
|
114358
114381
|
* 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````.
|
|
114359
114382
|
* @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.
|
|
@@ -121056,6 +121079,176 @@ class STLLoaderPlugin extends Plugin {
|
|
|
121056
121079
|
}
|
|
121057
121080
|
}
|
|
121058
121081
|
|
|
121082
|
+
/**
|
|
121083
|
+
* @desc A {@link TreeViewPlugin} render class.
|
|
121084
|
+
*
|
|
121085
|
+
*/
|
|
121086
|
+
class RenderService {
|
|
121087
|
+
|
|
121088
|
+
/*
|
|
121089
|
+
* Creates the root node of the tree.
|
|
121090
|
+
* @return {HTMLElement} The root node of the tree.
|
|
121091
|
+
*/
|
|
121092
|
+
createRootNode() {
|
|
121093
|
+
return document.createElement('ul')
|
|
121094
|
+
}
|
|
121095
|
+
|
|
121096
|
+
/*
|
|
121097
|
+
* Creates node of the tree.
|
|
121098
|
+
* @param {Object} node The node to create.
|
|
121099
|
+
|
|
121100
|
+
* @return {HTMLElement} The html element for the node.
|
|
121101
|
+
*/
|
|
121102
|
+
createNodeElement(node, expandHandler, checkHandler, contextmenuHandler, titleClickHandler) {
|
|
121103
|
+
const nodeElement = document.createElement('li');
|
|
121104
|
+
nodeElement.id = node.nodeId;
|
|
121105
|
+
|
|
121106
|
+
if (node.xrayed) {
|
|
121107
|
+
nodeElement.classList.add('xrayed-node');
|
|
121108
|
+
}
|
|
121109
|
+
|
|
121110
|
+
if (node.children.length > 0) {
|
|
121111
|
+
const switchElement = document.createElement('a');
|
|
121112
|
+
switchElement.href = '#';
|
|
121113
|
+
switchElement.id = `switch-${node.nodeId}`;
|
|
121114
|
+
switchElement.textContent = '+';
|
|
121115
|
+
switchElement.classList.add('plus');
|
|
121116
|
+
if (expandHandler) switchElement.addEventListener('click', expandHandler);
|
|
121117
|
+
nodeElement.appendChild(switchElement);
|
|
121118
|
+
}
|
|
121119
|
+
|
|
121120
|
+
const checkbox = document.createElement('input');
|
|
121121
|
+
checkbox.id = `checkbox-${node.nodeId}`;
|
|
121122
|
+
checkbox.type = "checkbox";
|
|
121123
|
+
checkbox.checked = node.checked;
|
|
121124
|
+
checkbox.style["pointer-events"] = "all";
|
|
121125
|
+
if (checkHandler) checkbox.addEventListener("change", checkHandler);
|
|
121126
|
+
nodeElement.appendChild(checkbox);
|
|
121127
|
+
|
|
121128
|
+
const span = document.createElement('span');
|
|
121129
|
+
span.textContent = node.title;
|
|
121130
|
+
nodeElement.appendChild(span);
|
|
121131
|
+
|
|
121132
|
+
if (contextmenuHandler) {
|
|
121133
|
+
span.oncontextmenu = contextmenuHandler;
|
|
121134
|
+
}
|
|
121135
|
+
|
|
121136
|
+
if (titleClickHandler) {
|
|
121137
|
+
span.onclick = titleClickHandler;
|
|
121138
|
+
}
|
|
121139
|
+
|
|
121140
|
+
return nodeElement;
|
|
121141
|
+
}
|
|
121142
|
+
|
|
121143
|
+
createDisabledNodeElement(rootName) {
|
|
121144
|
+
const li = document.createElement('li');
|
|
121145
|
+
|
|
121146
|
+
const switchElement = document.createElement('a');
|
|
121147
|
+
switchElement.href = '#';
|
|
121148
|
+
switchElement.textContent = '!';
|
|
121149
|
+
switchElement.classList.add('warn');
|
|
121150
|
+
switchElement.classList.add('warning');
|
|
121151
|
+
li.appendChild(switchElement);
|
|
121152
|
+
|
|
121153
|
+
const span = document.createElement('span');
|
|
121154
|
+
span.textContent = rootName;
|
|
121155
|
+
li.appendChild(span);
|
|
121156
|
+
|
|
121157
|
+
return li;
|
|
121158
|
+
}
|
|
121159
|
+
|
|
121160
|
+
addChildren(element, nodes) {
|
|
121161
|
+
const ul = document.createElement('ul');
|
|
121162
|
+
nodes.forEach((nodeElement) => {
|
|
121163
|
+
ul.appendChild(nodeElement);
|
|
121164
|
+
});
|
|
121165
|
+
|
|
121166
|
+
element.parentElement.appendChild(ul);
|
|
121167
|
+
}
|
|
121168
|
+
|
|
121169
|
+
expand(element, expandHandler, collapseHandler) {
|
|
121170
|
+
element.classList.remove('plus');
|
|
121171
|
+
element.classList.add('minus');
|
|
121172
|
+
element.textContent = '-';
|
|
121173
|
+
element.removeEventListener('click', expandHandler);
|
|
121174
|
+
element.addEventListener('click', collapseHandler);
|
|
121175
|
+
}
|
|
121176
|
+
|
|
121177
|
+
collapse(element, expandHandler, collapseHandler) {
|
|
121178
|
+
if (!element) {
|
|
121179
|
+
return;
|
|
121180
|
+
}
|
|
121181
|
+
const parent = element.parentElement;
|
|
121182
|
+
if (!parent) {
|
|
121183
|
+
return;
|
|
121184
|
+
}
|
|
121185
|
+
const ul = parent.querySelector('ul');
|
|
121186
|
+
if (!ul) {
|
|
121187
|
+
return;
|
|
121188
|
+
}
|
|
121189
|
+
parent.removeChild(ul);
|
|
121190
|
+
element.classList.remove('minus');
|
|
121191
|
+
element.classList.add('plus');
|
|
121192
|
+
element.textContent = '+';
|
|
121193
|
+
element.removeEventListener('click', collapseHandler);
|
|
121194
|
+
element.addEventListener('click', expandHandler);
|
|
121195
|
+
}
|
|
121196
|
+
|
|
121197
|
+
isExpanded(element) {
|
|
121198
|
+
const parentElement = element.parentElement;
|
|
121199
|
+
return parentElement.getElementsByTagName('li')[0] !== undefined;
|
|
121200
|
+
}
|
|
121201
|
+
|
|
121202
|
+
getId(element) {
|
|
121203
|
+
const parentElement = element.parentElement;
|
|
121204
|
+
return parentElement.id;
|
|
121205
|
+
}
|
|
121206
|
+
|
|
121207
|
+
getIdFromCheckbox(element) {
|
|
121208
|
+
return element.id.replace('checkbox-', '');
|
|
121209
|
+
}
|
|
121210
|
+
|
|
121211
|
+
getSwitchElement(nodeId) {
|
|
121212
|
+
return document.getElementById(`switch-${nodeId}`);
|
|
121213
|
+
}
|
|
121214
|
+
|
|
121215
|
+
isChecked(element) {
|
|
121216
|
+
return element.checked;
|
|
121217
|
+
}
|
|
121218
|
+
|
|
121219
|
+
setCheckbox(nodeId, checked) {
|
|
121220
|
+
const checkbox = document.getElementById(`checkbox-${nodeId}`);
|
|
121221
|
+
if (checkbox) {
|
|
121222
|
+
if (checked !== checkbox.checked) {
|
|
121223
|
+
checkbox.checked = checked;
|
|
121224
|
+
}
|
|
121225
|
+
}
|
|
121226
|
+
}
|
|
121227
|
+
|
|
121228
|
+
setXRayed(nodeId, xrayed) {
|
|
121229
|
+
const treeNode = document.getElementById(nodeId);
|
|
121230
|
+
if (treeNode) {
|
|
121231
|
+
if (xrayed) {
|
|
121232
|
+
treeNode.classList.add('xrayed-node');
|
|
121233
|
+
} else {
|
|
121234
|
+
treeNode.classList.remove('xrayed-node');
|
|
121235
|
+
}
|
|
121236
|
+
}
|
|
121237
|
+
}
|
|
121238
|
+
|
|
121239
|
+
setHighlighted(nodeId, highlighted) {
|
|
121240
|
+
const treeNode = document.getElementById(nodeId);
|
|
121241
|
+
if (treeNode) {
|
|
121242
|
+
if (highlighted) {
|
|
121243
|
+
treeNode.scrollIntoView({block: "center"});
|
|
121244
|
+
treeNode.classList.add('highlighted-node');
|
|
121245
|
+
} else {
|
|
121246
|
+
treeNode.classList.remove('highlighted-node');
|
|
121247
|
+
}
|
|
121248
|
+
}
|
|
121249
|
+
}
|
|
121250
|
+
}
|
|
121251
|
+
|
|
121059
121252
|
const treeViews = [];
|
|
121060
121253
|
|
|
121061
121254
|
/**
|
|
@@ -121415,6 +121608,7 @@ class TreeViewPlugin extends Plugin {
|
|
|
121415
121608
|
* ````IfcBuildingStorey```` nodes will be ordered spatially, from the highest storey down to the lowest, on the
|
|
121416
121609
|
* vertical World axis. For all hierarchy types, other node types will be ordered in the ascending alphanumeric order of their titles.
|
|
121417
121610
|
* @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.
|
|
121611
|
+
* @param {RenderService} [cfg.renderService] Optional {@link RenderService} to use. Defaults to the {@link TreeViewPlugin}'s default {@link RenderService}.
|
|
121418
121612
|
*/
|
|
121419
121613
|
constructor(viewer, cfg = {}) {
|
|
121420
121614
|
|
|
@@ -121454,7 +121648,6 @@ class TreeViewPlugin extends Plugin {
|
|
|
121454
121648
|
this._autoAddModels = (cfg.autoAddModels !== false);
|
|
121455
121649
|
this._autoExpandDepth = (cfg.autoExpandDepth || 0);
|
|
121456
121650
|
this._sortNodes = (cfg.sortNodes !== false);
|
|
121457
|
-
this._pruneEmptyNodes = (cfg.pruneEmptyNodes !== false);
|
|
121458
121651
|
this._viewer = viewer;
|
|
121459
121652
|
this._rootElement = null;
|
|
121460
121653
|
this._muteSceneEvents = false;
|
|
@@ -121462,10 +121655,15 @@ class TreeViewPlugin extends Plugin {
|
|
|
121462
121655
|
this._rootNodes = [];
|
|
121463
121656
|
this._objectNodes = {}; // Object ID -> Node
|
|
121464
121657
|
this._nodeNodes = {}; // Node ID -> Node
|
|
121465
|
-
this.
|
|
121658
|
+
this._rootNames = {}; // Node ID -> Root name
|
|
121466
121659
|
this._sortNodes = cfg.sortNodes;
|
|
121467
121660
|
this._pruneEmptyNodes = cfg.pruneEmptyNodes;
|
|
121468
121661
|
this._showListItemElementId = null;
|
|
121662
|
+
this._renderService = cfg.renderService || new RenderService();
|
|
121663
|
+
|
|
121664
|
+
if (!this._renderService) {
|
|
121665
|
+
throw new Error('TreeViewPlugin: no render service set');
|
|
121666
|
+
}
|
|
121469
121667
|
|
|
121470
121668
|
this._containerElement.oncontextmenu = (e) => {
|
|
121471
121669
|
e.preventDefault();
|
|
@@ -121492,10 +121690,9 @@ class TreeViewPlugin extends Plugin {
|
|
|
121492
121690
|
} else {
|
|
121493
121691
|
node.numVisibleEntities--;
|
|
121494
121692
|
}
|
|
121495
|
-
|
|
121496
|
-
|
|
121497
|
-
|
|
121498
|
-
}
|
|
121693
|
+
|
|
121694
|
+
this._renderService.setCheckbox(node.nodeId, visible);
|
|
121695
|
+
|
|
121499
121696
|
let parent = node.parent;
|
|
121500
121697
|
while (parent) {
|
|
121501
121698
|
parent.checked = visible;
|
|
@@ -121504,15 +121701,12 @@ class TreeViewPlugin extends Plugin {
|
|
|
121504
121701
|
} else {
|
|
121505
121702
|
parent.numVisibleEntities--;
|
|
121506
121703
|
}
|
|
121507
|
-
|
|
121508
|
-
|
|
121509
|
-
|
|
121510
|
-
if (newChecked !== parentCheckbox.checked) {
|
|
121511
|
-
parentCheckbox.checked = newChecked;
|
|
121512
|
-
}
|
|
121513
|
-
}
|
|
121704
|
+
|
|
121705
|
+
this._renderService.setCheckbox(parent.nodeId, (parent.numVisibleEntities > 0));
|
|
121706
|
+
|
|
121514
121707
|
parent = parent.parent;
|
|
121515
121708
|
}
|
|
121709
|
+
|
|
121516
121710
|
this._muteTreeEvents = false;
|
|
121517
121711
|
});
|
|
121518
121712
|
|
|
@@ -121532,15 +121726,8 @@ class TreeViewPlugin extends Plugin {
|
|
|
121532
121726
|
return;
|
|
121533
121727
|
}
|
|
121534
121728
|
node.xrayed = xrayed;
|
|
121535
|
-
|
|
121536
|
-
|
|
121537
|
-
if (listItemElement !== null) {
|
|
121538
|
-
if (xrayed) {
|
|
121539
|
-
listItemElement.classList.add('xrayed-node');
|
|
121540
|
-
} else {
|
|
121541
|
-
listItemElement.classList.remove('xrayed-node');
|
|
121542
|
-
}
|
|
121543
|
-
}
|
|
121729
|
+
|
|
121730
|
+
this._renderService.setXRayed(node.nodeId, xrayed);
|
|
121544
121731
|
this._muteTreeEvents = false;
|
|
121545
121732
|
});
|
|
121546
121733
|
|
|
@@ -121564,14 +121751,15 @@ class TreeViewPlugin extends Plugin {
|
|
|
121564
121751
|
}
|
|
121565
121752
|
this._muteSceneEvents = true;
|
|
121566
121753
|
const checkbox = event.target;
|
|
121567
|
-
const visible = checkbox
|
|
121568
|
-
const nodeId =
|
|
121754
|
+
const visible = this._renderService.isChecked(checkbox);
|
|
121755
|
+
const nodeId = this._renderService.getIdFromCheckbox(checkbox);
|
|
121756
|
+
|
|
121569
121757
|
const checkedNode = this._nodeNodes[nodeId];
|
|
121570
121758
|
const objects = this._viewer.scene.objects;
|
|
121571
121759
|
let numUpdated = 0;
|
|
121760
|
+
|
|
121572
121761
|
this._withNodeTree(checkedNode, (node) => {
|
|
121573
121762
|
const objectId = node.objectId;
|
|
121574
|
-
const checkBoxId = `checkbox-${node.nodeId}`;
|
|
121575
121763
|
const entity = objects[objectId];
|
|
121576
121764
|
const isLeaf = (node.children.length === 0);
|
|
121577
121765
|
node.numVisibleEntities = visible ? node.numEntities : 0;
|
|
@@ -121579,27 +121767,26 @@ class TreeViewPlugin extends Plugin {
|
|
|
121579
121767
|
numUpdated++;
|
|
121580
121768
|
}
|
|
121581
121769
|
node.checked = visible;
|
|
121582
|
-
|
|
121583
|
-
|
|
121584
|
-
|
|
121585
|
-
}
|
|
121770
|
+
|
|
121771
|
+
this._renderService.setCheckbox(node.nodeId, visible);
|
|
121772
|
+
|
|
121586
121773
|
if (entity) {
|
|
121587
121774
|
entity.visible = visible;
|
|
121588
121775
|
}
|
|
121589
121776
|
});
|
|
121777
|
+
|
|
121590
121778
|
let parent = checkedNode.parent;
|
|
121591
121779
|
while (parent) {
|
|
121592
121780
|
parent.checked = visible;
|
|
121593
|
-
|
|
121781
|
+
|
|
121594
121782
|
if (visible) {
|
|
121595
121783
|
parent.numVisibleEntities += numUpdated;
|
|
121596
121784
|
} else {
|
|
121597
121785
|
parent.numVisibleEntities -= numUpdated;
|
|
121598
121786
|
}
|
|
121599
|
-
|
|
121600
|
-
|
|
121601
|
-
|
|
121602
|
-
}
|
|
121787
|
+
|
|
121788
|
+
this._renderService.setCheckbox(parent.nodeId, (parent.numVisibleEntities > 0));
|
|
121789
|
+
|
|
121603
121790
|
parent = parent.parent;
|
|
121604
121791
|
}
|
|
121605
121792
|
this._muteSceneEvents = false;
|
|
@@ -121697,6 +121884,11 @@ class TreeViewPlugin extends Plugin {
|
|
|
121697
121884
|
return;
|
|
121698
121885
|
}
|
|
121699
121886
|
this._metaModels[modelId] = metaModel;
|
|
121887
|
+
|
|
121888
|
+
if (options && options.rootName) {
|
|
121889
|
+
this._rootNames[modelId] = options.rootName;
|
|
121890
|
+
}
|
|
121891
|
+
|
|
121700
121892
|
model.on("destroyed", () => {
|
|
121701
121893
|
this.removeModel(model.id);
|
|
121702
121894
|
});
|
|
@@ -121718,6 +121910,11 @@ class TreeViewPlugin extends Plugin {
|
|
|
121718
121910
|
if (!metaModel) {
|
|
121719
121911
|
return;
|
|
121720
121912
|
}
|
|
121913
|
+
|
|
121914
|
+
if (this._rootNames[modelId]) {
|
|
121915
|
+
delete this._rootNames[modelId];
|
|
121916
|
+
}
|
|
121917
|
+
|
|
121721
121918
|
delete this._metaModels[modelId];
|
|
121722
121919
|
this._createNodes();
|
|
121723
121920
|
}
|
|
@@ -121739,21 +121936,22 @@ class TreeViewPlugin extends Plugin {
|
|
|
121739
121936
|
* @param {String} objectId ID of the {@link Entity}.
|
|
121740
121937
|
*/
|
|
121741
121938
|
showNode(objectId) {
|
|
121742
|
-
|
|
121743
|
-
|
|
121744
|
-
}
|
|
121939
|
+
this.unShowNode();
|
|
121940
|
+
|
|
121745
121941
|
const node = this._objectNodes[objectId];
|
|
121746
121942
|
if (!node) {
|
|
121747
121943
|
return; // Node may not exist for the given object if (this._pruneEmptyNodes == true)
|
|
121748
121944
|
}
|
|
121945
|
+
|
|
121749
121946
|
const nodeId = node.nodeId;
|
|
121750
|
-
|
|
121751
|
-
const switchElement =
|
|
121947
|
+
|
|
121948
|
+
const switchElement = this._renderService.getSwitchElement(nodeId);
|
|
121752
121949
|
if (switchElement) {
|
|
121753
121950
|
this._expandSwitchElement(switchElement);
|
|
121754
121951
|
switchElement.scrollIntoView();
|
|
121755
|
-
return;
|
|
121952
|
+
return true;
|
|
121756
121953
|
}
|
|
121954
|
+
|
|
121757
121955
|
const path = [];
|
|
121758
121956
|
path.unshift(node);
|
|
121759
121957
|
let parent = node.parent;
|
|
@@ -121761,20 +121959,17 @@ class TreeViewPlugin extends Plugin {
|
|
|
121761
121959
|
path.unshift(parent);
|
|
121762
121960
|
parent = parent.parent;
|
|
121763
121961
|
}
|
|
121962
|
+
|
|
121764
121963
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
121765
|
-
const
|
|
121766
|
-
const nodeId = node.nodeId;
|
|
121767
|
-
const switchElementId = "switch-" + nodeId;
|
|
121768
|
-
const switchElement = document.getElementById(switchElementId);
|
|
121964
|
+
const switchElement = this._renderService.getSwitchElement(path[i].nodeId);
|
|
121769
121965
|
if (switchElement) {
|
|
121770
121966
|
this._expandSwitchElement(switchElement);
|
|
121771
121967
|
}
|
|
121772
121968
|
}
|
|
121773
|
-
|
|
121774
|
-
|
|
121775
|
-
|
|
121776
|
-
|
|
121777
|
-
this._showListItemElementId = listItemElementId;
|
|
121969
|
+
|
|
121970
|
+
this._renderService.setHighlighted(nodeId, true);
|
|
121971
|
+
|
|
121972
|
+
this._showListItemElementId = nodeId;
|
|
121778
121973
|
}
|
|
121779
121974
|
|
|
121780
121975
|
/**
|
|
@@ -121788,12 +121983,9 @@ class TreeViewPlugin extends Plugin {
|
|
|
121788
121983
|
if (!this._showListItemElementId) {
|
|
121789
121984
|
return;
|
|
121790
121985
|
}
|
|
121791
|
-
|
|
121792
|
-
|
|
121793
|
-
|
|
121794
|
-
return;
|
|
121795
|
-
}
|
|
121796
|
-
listItemElement.classList.remove("highlighted-node");
|
|
121986
|
+
|
|
121987
|
+
this._renderService.setHighlighted(this._showListItemElementId, false);
|
|
121988
|
+
|
|
121797
121989
|
this._showListItemElementId = null;
|
|
121798
121990
|
}
|
|
121799
121991
|
|
|
@@ -121810,9 +122002,8 @@ class TreeViewPlugin extends Plugin {
|
|
|
121810
122002
|
if (countDepth === depth) {
|
|
121811
122003
|
return;
|
|
121812
122004
|
}
|
|
121813
|
-
|
|
121814
|
-
const
|
|
121815
|
-
const switchElement = document.getElementById(switchElementId);
|
|
122005
|
+
|
|
122006
|
+
const switchElement = this._renderService.getSwitchElement(node.nodeId);
|
|
121816
122007
|
if (switchElement) {
|
|
121817
122008
|
this._expandSwitchElement(switchElement);
|
|
121818
122009
|
const childNodes = node.children;
|
|
@@ -121967,11 +122158,12 @@ class TreeViewPlugin extends Plugin {
|
|
|
121967
122158
|
|
|
121968
122159
|
_createDisabledNodes() {
|
|
121969
122160
|
|
|
121970
|
-
const
|
|
121971
|
-
this._rootElement =
|
|
121972
|
-
this._containerElement.appendChild(
|
|
122161
|
+
const rootNode = this._renderService.createRootNode();
|
|
122162
|
+
this._rootElement = rootNode;
|
|
122163
|
+
this._containerElement.appendChild(rootNode);
|
|
121973
122164
|
|
|
121974
122165
|
const rootMetaObjects = this._viewer.metaScene.rootMetaObjects;
|
|
122166
|
+
|
|
121975
122167
|
for (let objectId in rootMetaObjects) {
|
|
121976
122168
|
const rootMetaObject = rootMetaObjects[objectId];
|
|
121977
122169
|
const metaObjectType = rootMetaObject.type;
|
|
@@ -121979,17 +122171,9 @@ class TreeViewPlugin extends Plugin {
|
|
|
121979
122171
|
const rootName = ((metaObjectName && metaObjectName !== ""
|
|
121980
122172
|
&& metaObjectName !== "Undefined"
|
|
121981
122173
|
&& metaObjectName !== "Default") ? metaObjectName : metaObjectType);
|
|
121982
|
-
|
|
121983
|
-
|
|
121984
|
-
|
|
121985
|
-
switchElement.href = '#';
|
|
121986
|
-
switchElement.textContent = '!';
|
|
121987
|
-
switchElement.classList.add('warn');
|
|
121988
|
-
switchElement.classList.add('warning');
|
|
121989
|
-
li.appendChild(switchElement);
|
|
121990
|
-
const span = document.createElement('span');
|
|
121991
|
-
span.textContent = rootName;
|
|
121992
|
-
li.appendChild(span);
|
|
122174
|
+
|
|
122175
|
+
const childNode = this._renderService.createDisabledNodeElement(rootName);
|
|
122176
|
+
rootNode.appendChild(childNode);
|
|
121993
122177
|
}
|
|
121994
122178
|
}
|
|
121995
122179
|
|
|
@@ -122040,7 +122224,7 @@ class TreeViewPlugin extends Plugin {
|
|
|
122040
122224
|
buildingNode = {
|
|
122041
122225
|
nodeId: `${this._id}-${objectId}`,
|
|
122042
122226
|
objectId: objectId,
|
|
122043
|
-
title: this.
|
|
122227
|
+
title: this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
|
|
122044
122228
|
type: metaObjectType,
|
|
122045
122229
|
parent: null,
|
|
122046
122230
|
numEntities: 0,
|
|
@@ -122143,7 +122327,7 @@ class TreeViewPlugin extends Plugin {
|
|
|
122143
122327
|
rootNode = {
|
|
122144
122328
|
nodeId: `${this._id}-${objectId}`,
|
|
122145
122329
|
objectId: objectId,
|
|
122146
|
-
title: this.
|
|
122330
|
+
title: this._rootNames[metaObject.metaModels[0].id] || ((metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType),
|
|
122147
122331
|
type: metaObjectType,
|
|
122148
122332
|
parent: null,
|
|
122149
122333
|
numEntities: 0,
|
|
@@ -122224,7 +122408,7 @@ class TreeViewPlugin extends Plugin {
|
|
|
122224
122408
|
const node = {
|
|
122225
122409
|
nodeId: `${this._id}-${objectId}`,
|
|
122226
122410
|
objectId: objectId,
|
|
122227
|
-
title: (!parent) ? (this.
|
|
122411
|
+
title: (!parent) ? (this._rootNames[metaObject.metaModels[0].id] || metaObjectName) : (metaObjectName && metaObjectName !== "" && metaObjectName !== "Undefined" && metaObjectName !== "Default") ? metaObjectName : metaObjectType,
|
|
122228
122412
|
type: metaObjectType,
|
|
122229
122413
|
parent: parent,
|
|
122230
122414
|
numEntities: 0,
|
|
@@ -122372,112 +122556,63 @@ class TreeViewPlugin extends Plugin {
|
|
|
122372
122556
|
const rootNodeElements = this._rootNodes.map((rootNode) => {
|
|
122373
122557
|
return this._createNodeElement(rootNode);
|
|
122374
122558
|
});
|
|
122375
|
-
|
|
122559
|
+
|
|
122560
|
+
const rootNode = this._renderService.createRootNode();
|
|
122376
122561
|
rootNodeElements.forEach((nodeElement) => {
|
|
122377
|
-
|
|
122562
|
+
rootNode.appendChild(nodeElement);
|
|
122378
122563
|
});
|
|
122379
|
-
|
|
122380
|
-
this.
|
|
122564
|
+
|
|
122565
|
+
this._containerElement.appendChild(rootNode);
|
|
122566
|
+
this._rootElement = rootNode;
|
|
122381
122567
|
}
|
|
122382
122568
|
|
|
122383
122569
|
_createNodeElement(node) {
|
|
122384
|
-
const
|
|
122385
|
-
|
|
122386
|
-
|
|
122387
|
-
if (node.xrayed) {
|
|
122388
|
-
nodeElement.classList.add('xrayed-node');
|
|
122389
|
-
}
|
|
122390
|
-
nodeElement.id = nodeId;
|
|
122391
|
-
if (node.children.length > 0) {
|
|
122392
|
-
const switchElementId = "switch-" + nodeId;
|
|
122393
|
-
const switchElement = document.createElement('a');
|
|
122394
|
-
switchElement.href = '#';
|
|
122395
|
-
switchElement.id = switchElementId;
|
|
122396
|
-
switchElement.textContent = '+';
|
|
122397
|
-
switchElement.classList.add('plus');
|
|
122398
|
-
switchElement.addEventListener('click', this._switchExpandHandler);
|
|
122399
|
-
nodeElement.appendChild(switchElement);
|
|
122400
|
-
}
|
|
122401
|
-
const checkbox = document.createElement('input');
|
|
122402
|
-
checkbox.id = `checkbox-${nodeId}`;
|
|
122403
|
-
checkbox.type = "checkbox";
|
|
122404
|
-
checkbox.checked = node.checked;
|
|
122405
|
-
checkbox.style["pointer-events"] = "all";
|
|
122406
|
-
checkbox.addEventListener("change", this._checkboxChangeHandler);
|
|
122407
|
-
nodeElement.appendChild(checkbox);
|
|
122408
|
-
const span = document.createElement('span');
|
|
122409
|
-
span.textContent = node.title;
|
|
122410
|
-
nodeElement.appendChild(span);
|
|
122411
|
-
span.oncontextmenu = (e) => {
|
|
122412
|
-
this.fire("contextmenu", {
|
|
122413
|
-
event: e,
|
|
122570
|
+
const contextmenuHandler = (event) =>{
|
|
122571
|
+
this.fire("contextmenu", {
|
|
122572
|
+
event: event,
|
|
122414
122573
|
viewer: this._viewer,
|
|
122415
122574
|
treeViewPlugin: this,
|
|
122416
122575
|
treeViewNode: node
|
|
122417
122576
|
});
|
|
122418
|
-
|
|
122577
|
+
event.preventDefault();
|
|
122419
122578
|
};
|
|
122420
|
-
|
|
122579
|
+
const onclickHandler = (event) => {
|
|
122421
122580
|
this.fire("nodeTitleClicked", {
|
|
122422
|
-
event:
|
|
122581
|
+
event: event,
|
|
122423
122582
|
viewer: this._viewer,
|
|
122424
122583
|
treeViewPlugin: this,
|
|
122425
122584
|
treeViewNode: node
|
|
122426
122585
|
});
|
|
122427
|
-
|
|
122586
|
+
event.preventDefault();
|
|
122428
122587
|
};
|
|
122429
|
-
|
|
122588
|
+
|
|
122589
|
+
return this._renderService.createNodeElement(node, this._switchExpandHandler, this._checkboxChangeHandler, contextmenuHandler, onclickHandler);
|
|
122430
122590
|
}
|
|
122431
122591
|
|
|
122432
122592
|
_expandSwitchElement(switchElement) {
|
|
122433
|
-
const
|
|
122434
|
-
const expanded = parentElement.getElementsByTagName('li')[0];
|
|
122593
|
+
const expanded = this._renderService.isExpanded(switchElement);
|
|
122435
122594
|
if (expanded) {
|
|
122436
122595
|
return;
|
|
122437
122596
|
}
|
|
122438
|
-
|
|
122439
|
-
const
|
|
122440
|
-
|
|
122441
|
-
const nodeElements =
|
|
122597
|
+
|
|
122598
|
+
const nodeId = this._renderService.getId(switchElement);
|
|
122599
|
+
|
|
122600
|
+
const nodeElements = this._nodeNodes[nodeId].children.map((node) => {
|
|
122442
122601
|
return this._createNodeElement(node);
|
|
122443
122602
|
});
|
|
122444
|
-
|
|
122445
|
-
|
|
122446
|
-
|
|
122447
|
-
|
|
122448
|
-
|
|
122449
|
-
|
|
122450
|
-
|
|
122451
|
-
switchElement
|
|
122452
|
-
switchElement.removeEventListener('click', this._switchExpandHandler);
|
|
122453
|
-
switchElement.addEventListener('click', this._switchCollapseHandler);
|
|
122454
|
-
}
|
|
122455
|
-
|
|
122456
|
-
_collapseNode(objectId) {
|
|
122457
|
-
const nodeId = objectId;
|
|
122458
|
-
const switchElementId = "switch-" + nodeId;
|
|
122459
|
-
const switchElement = document.getElementById(switchElementId);
|
|
122603
|
+
|
|
122604
|
+
this._renderService.addChildren(switchElement, nodeElements);
|
|
122605
|
+
|
|
122606
|
+
this._renderService.expand(switchElement, this._switchExpandHandler, this._switchCollapseHandler);
|
|
122607
|
+
}
|
|
122608
|
+
|
|
122609
|
+
_collapseNode(nodeId) {
|
|
122610
|
+
const switchElement = this._renderService.getSwitchElement(nodeId);
|
|
122460
122611
|
this._collapseSwitchElement(switchElement);
|
|
122461
122612
|
}
|
|
122462
122613
|
|
|
122463
122614
|
_collapseSwitchElement(switchElement) {
|
|
122464
|
-
|
|
122465
|
-
return;
|
|
122466
|
-
}
|
|
122467
|
-
const parent = switchElement.parentElement;
|
|
122468
|
-
if (!parent) {
|
|
122469
|
-
return;
|
|
122470
|
-
}
|
|
122471
|
-
const ul = parent.querySelector('ul');
|
|
122472
|
-
if (!ul) {
|
|
122473
|
-
return;
|
|
122474
|
-
}
|
|
122475
|
-
parent.removeChild(ul);
|
|
122476
|
-
switchElement.classList.remove('minus');
|
|
122477
|
-
switchElement.classList.add('plus');
|
|
122478
|
-
switchElement.textContent = '+';
|
|
122479
|
-
switchElement.removeEventListener('click', this._switchCollapseHandler);
|
|
122480
|
-
switchElement.addEventListener('click', this._switchExpandHandler);
|
|
122615
|
+
this._renderService.collapse(switchElement, this._switchExpandHandler, this._switchCollapseHandler);
|
|
122481
122616
|
}
|
|
122482
122617
|
}
|
|
122483
122618
|
|
|
@@ -126962,9 +127097,9 @@ parsers[ParserV10.version] = ParserV10;
|
|
|
126962
127097
|
* }
|
|
126963
127098
|
*
|
|
126964
127099
|
* // Gets the contents of the given .XKT file in an arraybuffer
|
|
126965
|
-
* getXKT(
|
|
127100
|
+
* getXKT(xKTSrc, ok, error) {
|
|
126966
127101
|
* console.log("MyDataSource#getXKT(" + xKTSrc + ", ... )");
|
|
126967
|
-
* utils.loadArraybuffer(
|
|
127102
|
+
* utils.loadArraybuffer(xKTSrc,
|
|
126968
127103
|
* (arraybuffer) => {
|
|
126969
127104
|
* ok(arraybuffer);
|
|
126970
127105
|
* },
|
|
@@ -127564,13 +127699,14 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
127564
127699
|
sceneModel.once("destroyed", () => {
|
|
127565
127700
|
this.viewer.metaScene.destroyMetaModel(metaModel.id);
|
|
127566
127701
|
});
|
|
127567
|
-
|
|
127702
|
+
window.setTimeout(() => {
|
|
127703
|
+
|
|
127568
127704
|
if (sceneModel.destroyed) {
|
|
127569
127705
|
return;
|
|
127570
127706
|
}
|
|
127571
127707
|
sceneModel.scene.fire("modelLoaded", sceneModel.id); // FIXME: Assumes listeners know order of these two events
|
|
127572
127708
|
sceneModel.fire("loaded", true, false); // Don't forget the event, for late subscribers
|
|
127573
|
-
});
|
|
127709
|
+
}, 100);
|
|
127574
127710
|
};
|
|
127575
127711
|
|
|
127576
127712
|
const error = (errMsg) => {
|
|
@@ -127648,7 +127784,7 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
127648
127784
|
globalizeObjectIds: options.globalizeObjectIds
|
|
127649
127785
|
});
|
|
127650
127786
|
i++;
|
|
127651
|
-
|
|
127787
|
+
window.setTimeout( loadNext, 100);
|
|
127652
127788
|
}, error);
|
|
127653
127789
|
}
|
|
127654
127790
|
};
|
|
@@ -127663,7 +127799,7 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
127663
127799
|
this._dataSource.getXKT(`${baseDir}${xktFiles[i]}`, (arrayBuffer) => {
|
|
127664
127800
|
this._parseModel(arrayBuffer, params, options, sceneModel, metaModel, manifestCtx);
|
|
127665
127801
|
i++;
|
|
127666
|
-
|
|
127802
|
+
window.setTimeout(loadNext, 100);
|
|
127667
127803
|
}, error);
|
|
127668
127804
|
}
|
|
127669
127805
|
};
|