@xeokit/xeokit-sdk 2.5.2-beta-4 → 2.5.2-beta-7
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 -182
- package/dist/xeokit-sdk.es.js +387 -269
- package/dist/xeokit-sdk.es5.js +55 -36
- 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/TreeViewNode.js +11 -7
- package/src/plugins/TreeViewPlugin/TreeViewPlugin.js +94 -151
- package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +2 -2
- package/src/viewer/scene/model/SceneModel.js +30 -26
- package/types/plugins/NavCubePlugin/NavCubePlugin.d.ts +2 -0
- package/types/plugins/TreeViewPlugin/TreeViewNode.d.ts +12 -14
- 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/viewer/scene/models/SceneModel.d.ts +17 -7
- package/types/plugins/TreeViewPlugin/ModelTreeView.d.ts +0 -24
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
|
|
|
7
7
|
|
|
8
8
|
const cubeColor = "lightgrey";
|
|
9
9
|
const cubeHighlightColor = cfg.hoverColor || "rgba(0,0,0,0.4)";
|
|
10
|
+
const textColor = cfg.textColor || "black";
|
|
10
11
|
|
|
11
12
|
const height = 500;
|
|
12
13
|
const width = height + (height / 3);
|
|
@@ -158,7 +159,7 @@ function CubeTextureCanvas(viewer, navCubeScene, cfg = {}) {
|
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
if (area.label) {
|
|
161
|
-
context.fillStyle =
|
|
162
|
+
context.fillStyle = textColor;
|
|
162
163
|
context.font = '60px sans-serif';
|
|
163
164
|
context.textAlign = "center";
|
|
164
165
|
var xcenter = xmin + (width * 0.5);
|
|
@@ -88,7 +88,7 @@ class NavCubePlugin extends Plugin {
|
|
|
88
88
|
* @param {String} [cfg.cameraFly=true] Whether the {@link Camera} flies or jumps to each selected axis or diagonal.
|
|
89
89
|
* @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.
|
|
90
90
|
* @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.
|
|
91
|
-
* @param {String} [cfg.color="lightgrey] Custom uniform color for the faces of the NavCube.
|
|
91
|
+
* @param {String} [cfg.color="lightgrey"] Custom uniform color for the faces of the NavCube.
|
|
92
92
|
* @param {String} [cfg.frontColor="#55FF55"] Custom color for the front face of the NavCube. Overrides ````color````.
|
|
93
93
|
* @param {String} [cfg.backColor="#55FF55"] Custom color for the back face of the NavCube. Overrides ````color````.
|
|
94
94
|
* @param {String} [cfg.leftColor="#FF5555"] Custom color for the left face of the NavCube. Overrides ````color````.
|
|
@@ -96,6 +96,7 @@ class NavCubePlugin extends Plugin {
|
|
|
96
96
|
* @param {String} [cfg.topColor="#5555FF"] Custom color for the top face of the NavCube. Overrides ````color````.
|
|
97
97
|
* @param {String} [cfg.bottomColor="#5555FF"] Custom color for the bottom face of the NavCube. Overrides ````color````.
|
|
98
98
|
* @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.
|
|
99
|
+
* @param {String} [cfg.textColor="black"] Custom text color for labels of the NavCube.
|
|
99
100
|
* @param {Boolean} [cfg.fitVisible=false] Sets whether the axis, corner and edge-aligned views will fit the
|
|
100
101
|
* 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````.
|
|
101
102
|
* @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.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @desc A {@link TreeViewPlugin} render class.
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
export class RenderService {
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Creates the root node of the tree.
|
|
9
|
+
* @return {HTMLElement} The root node of the tree.
|
|
10
|
+
*/
|
|
11
|
+
createRootNode() {
|
|
12
|
+
return document.createElement('ul')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Creates node of the tree.
|
|
17
|
+
* @param {Object} node The node to create.
|
|
18
|
+
|
|
19
|
+
* @return {HTMLElement} The html element for the node.
|
|
20
|
+
*/
|
|
21
|
+
createNodeElement(node, expandHandler, checkHandler, contextmenuHandler, titleClickHandler) {
|
|
22
|
+
const nodeElement = document.createElement('li');
|
|
23
|
+
nodeElement.id = node.nodeId;
|
|
24
|
+
|
|
25
|
+
if (node.xrayed) {
|
|
26
|
+
nodeElement.classList.add('xrayed-node');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (node.children.length > 0) {
|
|
30
|
+
const switchElement = document.createElement('a');
|
|
31
|
+
switchElement.href = '#';
|
|
32
|
+
switchElement.id = `switch-${node.nodeId}`;
|
|
33
|
+
switchElement.textContent = '+';
|
|
34
|
+
switchElement.classList.add('plus');
|
|
35
|
+
if (expandHandler) switchElement.addEventListener('click', expandHandler);
|
|
36
|
+
nodeElement.appendChild(switchElement);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const checkbox = document.createElement('input');
|
|
40
|
+
checkbox.id = `checkbox-${node.nodeId}`;
|
|
41
|
+
checkbox.type = "checkbox";
|
|
42
|
+
checkbox.checked = node.checked;
|
|
43
|
+
checkbox.style["pointer-events"] = "all";
|
|
44
|
+
if (checkHandler) checkbox.addEventListener("change", checkHandler);
|
|
45
|
+
nodeElement.appendChild(checkbox);
|
|
46
|
+
|
|
47
|
+
const span = document.createElement('span');
|
|
48
|
+
span.textContent = node.title;
|
|
49
|
+
nodeElement.appendChild(span);
|
|
50
|
+
|
|
51
|
+
if (contextmenuHandler) {
|
|
52
|
+
span.oncontextmenu = contextmenuHandler;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (titleClickHandler) {
|
|
56
|
+
span.onclick = titleClickHandler;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return nodeElement;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
createDisabledNodeElement(rootName) {
|
|
63
|
+
const li = document.createElement('li');
|
|
64
|
+
|
|
65
|
+
const switchElement = document.createElement('a');
|
|
66
|
+
switchElement.href = '#';
|
|
67
|
+
switchElement.textContent = '!';
|
|
68
|
+
switchElement.classList.add('warn');
|
|
69
|
+
switchElement.classList.add('warning');
|
|
70
|
+
li.appendChild(switchElement);
|
|
71
|
+
|
|
72
|
+
const span = document.createElement('span');
|
|
73
|
+
span.textContent = rootName;
|
|
74
|
+
li.appendChild(span);
|
|
75
|
+
|
|
76
|
+
return li;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
addChildren(element, nodes) {
|
|
80
|
+
const ul = document.createElement('ul');
|
|
81
|
+
nodes.forEach((nodeElement) => {
|
|
82
|
+
ul.appendChild(nodeElement);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
element.parentElement.appendChild(ul);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
expand(element, expandHandler, collapseHandler) {
|
|
89
|
+
element.classList.remove('plus');
|
|
90
|
+
element.classList.add('minus');
|
|
91
|
+
element.textContent = '-';
|
|
92
|
+
element.removeEventListener('click', expandHandler);
|
|
93
|
+
element.addEventListener('click', collapseHandler);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
collapse(element, expandHandler, collapseHandler) {
|
|
97
|
+
if (!element) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const parent = element.parentElement;
|
|
101
|
+
if (!parent) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const ul = parent.querySelector('ul');
|
|
105
|
+
if (!ul) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
parent.removeChild(ul);
|
|
109
|
+
element.classList.remove('minus');
|
|
110
|
+
element.classList.add('plus');
|
|
111
|
+
element.textContent = '+';
|
|
112
|
+
element.removeEventListener('click', collapseHandler);
|
|
113
|
+
element.addEventListener('click', expandHandler);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
isExpanded(element) {
|
|
117
|
+
const parentElement = element.parentElement;
|
|
118
|
+
return parentElement.getElementsByTagName('li')[0] !== undefined;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
getId(element) {
|
|
122
|
+
const parentElement = element.parentElement;
|
|
123
|
+
return parentElement.id;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
getIdFromCheckbox(element) {
|
|
127
|
+
return element.id.replace('checkbox-', '');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
getSwitchElement(nodeId) {
|
|
131
|
+
return document.getElementById(`switch-${nodeId}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
isChecked(element) {
|
|
135
|
+
return element.checked;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
setCheckbox(nodeId, checked) {
|
|
139
|
+
const checkbox = document.getElementById(`checkbox-${nodeId}`);
|
|
140
|
+
if (checkbox) {
|
|
141
|
+
if (checked !== checkbox.checked) {
|
|
142
|
+
checkbox.checked = checked;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
setXRayed(nodeId, xrayed) {
|
|
148
|
+
const treeNode = document.getElementById(nodeId);
|
|
149
|
+
if (treeNode) {
|
|
150
|
+
if (xrayed) {
|
|
151
|
+
treeNode.classList.add('xrayed-node');
|
|
152
|
+
} else {
|
|
153
|
+
treeNode.classList.remove('xrayed-node');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
setHighlighted(nodeId, highlighted) {
|
|
159
|
+
const treeNode = document.getElementById(nodeId);
|
|
160
|
+
if (treeNode) {
|
|
161
|
+
if (highlighted) {
|
|
162
|
+
treeNode.scrollIntoView({block: "center"});
|
|
163
|
+
treeNode.classList.add('highlighted-node');
|
|
164
|
+
} else {
|
|
165
|
+
treeNode.classList.remove('highlighted-node');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -28,12 +28,20 @@ class TreeViewNode {
|
|
|
28
28
|
get title() {
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/** Type of the corresponding {@link MetaObject}.
|
|
32
|
+
*
|
|
33
|
+
* @type {String}
|
|
34
|
+
* @abstract
|
|
35
|
+
*/
|
|
36
|
+
get type() {
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
/**
|
|
32
40
|
* ID of the corresponding {@link MetaObject}.
|
|
33
41
|
*
|
|
34
42
|
* This is only defined if the TreeViewNode represents an object.
|
|
35
43
|
*
|
|
36
|
-
* @type {
|
|
44
|
+
* @type {String}
|
|
37
45
|
* @abstract
|
|
38
46
|
*/
|
|
39
47
|
get objectId() {
|
|
@@ -54,7 +62,6 @@ class TreeViewNode {
|
|
|
54
62
|
* @abstract
|
|
55
63
|
*/
|
|
56
64
|
get parent() {
|
|
57
|
-
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
/** The number of {@link Entity}s within the subtree of this TreeViewNode.
|
|
@@ -72,7 +79,6 @@ class TreeViewNode {
|
|
|
72
79
|
* @abstract
|
|
73
80
|
*/
|
|
74
81
|
get numVisibleEntities() {
|
|
75
|
-
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
/** Whether or not the TreeViewNode is currently checked.
|
|
@@ -81,7 +87,6 @@ class TreeViewNode {
|
|
|
81
87
|
* @abstract
|
|
82
88
|
*/
|
|
83
89
|
get checked() {
|
|
84
|
-
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
/** Whether or not the TreeViewNode is currently xrayed.
|
|
@@ -89,9 +94,8 @@ class TreeViewNode {
|
|
|
89
94
|
* @type {Boolean}
|
|
90
95
|
* @abstract
|
|
91
96
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
get xrayed() {
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
|
|
97
|
-
export {TreeViewNode};
|
|
101
|
+
export {TreeViewNode};
|