@shapediver/viewer.shared.node-tree 3.16.8 → 3.16.10
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/implementation/AbstractTreeNodeData.d.ts +33 -33
- package/dist/implementation/AbstractTreeNodeData.js +81 -81
- package/dist/implementation/AbstractTreeNodeData.js.map +1 -1
- package/dist/implementation/Tree.d.ts +13 -13
- package/dist/implementation/Tree.js +115 -115
- package/dist/implementation/Tree.js.map +1 -1
- package/dist/implementation/TreeNode.d.ts +78 -78
- package/dist/implementation/TreeNode.js +432 -432
- package/dist/implementation/TreeNode.js.map +1 -1
- package/dist/implementation/data/AnimationData.d.ts +32 -32
- package/dist/implementation/data/AnimationData.js +290 -290
- package/dist/implementation/data/AnimationData.js.map +1 -1
- package/dist/implementation/data/ChunkData.d.ts +14 -14
- package/dist/implementation/data/ChunkData.js +46 -46
- package/dist/implementation/data/ChunkData.js.map +1 -1
- package/dist/implementation/data/CustomData.d.ts +24 -24
- package/dist/implementation/data/CustomData.js +50 -50
- package/dist/implementation/data/GeometryData.d.ts +100 -100
- package/dist/implementation/data/GeometryData.js +326 -326
- package/dist/implementation/data/GeometryData.js.map +1 -1
- package/dist/implementation/data/HTMLElementAnchorData.d.ts +102 -102
- package/dist/implementation/data/HTMLElementAnchorData.js +273 -273
- package/dist/implementation/data/HTMLElementAnchorData.js.map +1 -1
- package/dist/implementation/data/InstanceData.d.ts +21 -21
- package/dist/implementation/data/InstanceData.js +58 -58
- package/dist/implementation/material/AbstractMaterialData.d.ts +68 -68
- package/dist/implementation/material/AbstractMaterialData.js +224 -224
- package/dist/implementation/material/MapData.d.ts +53 -53
- package/dist/implementation/material/MapData.js +190 -190
- package/dist/implementation/material/MaterialBasicLineData.d.ts +14 -14
- package/dist/implementation/material/MaterialBasicLineData.js +90 -90
- package/dist/implementation/material/MaterialGemData.d.ts +46 -46
- package/dist/implementation/material/MaterialGemData.js +288 -288
- package/dist/implementation/material/MaterialLambertData.d.ts +21 -21
- package/dist/implementation/material/MaterialLambertData.js +146 -146
- package/dist/implementation/material/MaterialMultiPointData.d.ts +99 -99
- package/dist/implementation/material/MaterialMultiPointData.js +650 -650
- package/dist/implementation/material/MaterialPhongData.d.ts +25 -25
- package/dist/implementation/material/MaterialPhongData.js +170 -170
- package/dist/implementation/material/MaterialPointData.d.ts +19 -19
- package/dist/implementation/material/MaterialPointData.js +131 -131
- package/dist/implementation/material/MaterialShadowData.d.ts +14 -14
- package/dist/implementation/material/MaterialShadowData.js +35 -35
- package/dist/implementation/material/MaterialSpecularGlossinessData.d.ts +27 -27
- package/dist/implementation/material/MaterialSpecularGlossinessData.js +179 -179
- package/dist/implementation/material/MaterialStandardData.d.ts +75 -75
- package/dist/implementation/material/MaterialStandardData.js +467 -467
- package/dist/implementation/material/MaterialUnlitData.d.ts +17 -17
- package/dist/implementation/material/MaterialUnlitData.js +119 -119
- package/dist/implementation/material/MaterialVariantsData.d.ts +15 -15
- package/dist/implementation/material/MaterialVariantsData.js +61 -61
- package/dist/implementation/material/MaterialVariantsData.js.map +1 -1
- package/dist/implementation/sdtf/SDTFAttributesData.d.ts +22 -22
- package/dist/implementation/sdtf/SDTFAttributesData.js +99 -99
- package/dist/implementation/sdtf/SDTFAttributesData.js.map +1 -1
- package/dist/implementation/sdtf/SDTFItemData.d.ts +18 -18
- package/dist/implementation/sdtf/SDTFItemData.js +59 -59
- package/dist/implementation/sdtf/SDTFItemData.js.map +1 -1
- package/dist/implementation/sdtf/SDTFOverviewData.d.ts +12 -12
- package/dist/implementation/sdtf/SDTFOverviewData.js +106 -106
- package/dist/implementation/sdtf/SDTFOverviewData.js.map +1 -1
- package/dist/index.d.ts +35 -35
- package/dist/index.js +59 -59
- package/package.json +6 -6
|
@@ -1,433 +1,433 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _TreeNode_boundingBox, _TreeNode_boundingBoxViewport, _TreeNode_children, _TreeNode_dataProxy, _TreeNode_id, _TreeNode_uuidGenerator, _TreeNode_convertedObject, _TreeNode_displayName, _TreeNode_excludeViewports, _TreeNode_intersectionTest, _TreeNode_name, _TreeNode_originalId, _TreeNode_originalName, _TreeNode_parent, _TreeNode_restrictViewports, _TreeNode_transformations, _TreeNode_updateCallback, _TreeNode_updateCallbackConvertedObject, _TreeNode_version, _TreeNode_visible;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.TreeNode = void 0;
|
|
16
|
-
const viewer_shared_math_1 = require("@shapediver/viewer.shared.math");
|
|
17
|
-
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
18
|
-
const gl_matrix_1 = require("gl-matrix");
|
|
19
|
-
class TreeNode {
|
|
20
|
-
/**
|
|
21
|
-
* Creation of a node that can be used in the node tree.
|
|
22
|
-
*
|
|
23
|
-
* @param name the name of the node
|
|
24
|
-
* @param parent the parent of this node
|
|
25
|
-
* @param data the array of data
|
|
26
|
-
* @param transformations the array of transformations
|
|
27
|
-
*/
|
|
28
|
-
constructor(name = "node", parent, data = [], transformations = []) {
|
|
29
|
-
var _a;
|
|
30
|
-
_TreeNode_boundingBox.set(this, new viewer_shared_math_1.Box());
|
|
31
|
-
_TreeNode_boundingBoxViewport.set(this, {});
|
|
32
|
-
_TreeNode_children.set(this, []);
|
|
33
|
-
_TreeNode_dataProxy.set(this, new viewer_shared_services_1.ObservableArray({
|
|
34
|
-
initialData: [],
|
|
35
|
-
onChanged: this.onDataChanged.bind(this),
|
|
36
|
-
}));
|
|
37
|
-
_TreeNode_id.set(this, void 0);
|
|
38
|
-
_TreeNode_uuidGenerator.set(this, viewer_shared_services_1.UuidGenerator.instance);
|
|
39
|
-
_TreeNode_convertedObject.set(this, {});
|
|
40
|
-
_TreeNode_displayName.set(this, void 0);
|
|
41
|
-
_TreeNode_excludeViewports.set(this, []);
|
|
42
|
-
_TreeNode_intersectionTest.set(this, true);
|
|
43
|
-
_TreeNode_name.set(this, "");
|
|
44
|
-
_TreeNode_originalId.set(this, void 0);
|
|
45
|
-
_TreeNode_originalName.set(this, void 0);
|
|
46
|
-
_TreeNode_parent.set(this, void 0);
|
|
47
|
-
_TreeNode_restrictViewports.set(this, []);
|
|
48
|
-
_TreeNode_transformations.set(this, []);
|
|
49
|
-
_TreeNode_updateCallback.set(this, null);
|
|
50
|
-
_TreeNode_updateCallbackConvertedObject.set(this, null);
|
|
51
|
-
_TreeNode_version.set(this, void 0);
|
|
52
|
-
_TreeNode_visible.set(this, true);
|
|
53
|
-
__classPrivateFieldSet(this, _TreeNode_name, name, "f");
|
|
54
|
-
__classPrivateFieldSet(this, _TreeNode_parent, parent, "f");
|
|
55
|
-
__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").setData(data);
|
|
56
|
-
__classPrivateFieldSet(this, _TreeNode_transformations, transformations, "f");
|
|
57
|
-
__classPrivateFieldSet(this, _TreeNode_id, __classPrivateFieldGet(this, _TreeNode_uuidGenerator, "f").create(), "f");
|
|
58
|
-
__classPrivateFieldSet(this, _TreeNode_originalId, __classPrivateFieldGet(this, _TreeNode_id, "f"), "f");
|
|
59
|
-
__classPrivateFieldSet(this, _TreeNode_version, __classPrivateFieldGet(this, _TreeNode_uuidGenerator, "f").create(), "f");
|
|
60
|
-
(_a = __classPrivateFieldGet(this, _TreeNode_parent, "f")) === null || _a === void 0 ? void 0 : _a.addChild(this);
|
|
61
|
-
}
|
|
62
|
-
get boundingBox() {
|
|
63
|
-
return __classPrivateFieldGet(this, _TreeNode_boundingBox, "f");
|
|
64
|
-
}
|
|
65
|
-
get boundingBoxViewport() {
|
|
66
|
-
return __classPrivateFieldGet(this, _TreeNode_boundingBoxViewport, "f");
|
|
67
|
-
}
|
|
68
|
-
get children() {
|
|
69
|
-
return __classPrivateFieldGet(this, _TreeNode_children, "f");
|
|
70
|
-
}
|
|
71
|
-
get convertedObject() {
|
|
72
|
-
return __classPrivateFieldGet(this, _TreeNode_convertedObject, "f");
|
|
73
|
-
}
|
|
74
|
-
set convertedObject(value) {
|
|
75
|
-
__classPrivateFieldSet(this, _TreeNode_convertedObject, value, "f");
|
|
76
|
-
}
|
|
77
|
-
get data() {
|
|
78
|
-
return __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value;
|
|
79
|
-
}
|
|
80
|
-
get displayName() {
|
|
81
|
-
return __classPrivateFieldGet(this, _TreeNode_displayName, "f");
|
|
82
|
-
}
|
|
83
|
-
set displayName(value) {
|
|
84
|
-
__classPrivateFieldSet(this, _TreeNode_displayName, value, "f");
|
|
85
|
-
}
|
|
86
|
-
get excludeViewports() {
|
|
87
|
-
return __classPrivateFieldGet(this, _TreeNode_excludeViewports, "f");
|
|
88
|
-
}
|
|
89
|
-
set excludeViewports(value) {
|
|
90
|
-
__classPrivateFieldSet(this, _TreeNode_excludeViewports, value, "f");
|
|
91
|
-
}
|
|
92
|
-
get id() {
|
|
93
|
-
return __classPrivateFieldGet(this, _TreeNode_id, "f");
|
|
94
|
-
}
|
|
95
|
-
get intersectionTest() {
|
|
96
|
-
return __classPrivateFieldGet(this, _TreeNode_intersectionTest, "f");
|
|
97
|
-
}
|
|
98
|
-
set intersectionTest(value) {
|
|
99
|
-
__classPrivateFieldSet(this, _TreeNode_intersectionTest, value, "f");
|
|
100
|
-
}
|
|
101
|
-
get name() {
|
|
102
|
-
return __classPrivateFieldGet(this, _TreeNode_name, "f");
|
|
103
|
-
}
|
|
104
|
-
set name(value) {
|
|
105
|
-
__classPrivateFieldSet(this, _TreeNode_name, value, "f");
|
|
106
|
-
}
|
|
107
|
-
get nodeMatrix() {
|
|
108
|
-
const matrix = gl_matrix_1.mat4.create();
|
|
109
|
-
for (const transform of __classPrivateFieldGet(this, _TreeNode_transformations, "f"))
|
|
110
|
-
if (transform.id !== "sdtf")
|
|
111
|
-
gl_matrix_1.mat4.multiply(matrix, matrix, transform.matrix);
|
|
112
|
-
return matrix;
|
|
113
|
-
}
|
|
114
|
-
get originalId() {
|
|
115
|
-
return __classPrivateFieldGet(this, _TreeNode_originalId, "f");
|
|
116
|
-
}
|
|
117
|
-
set originalId(value) {
|
|
118
|
-
__classPrivateFieldSet(this, _TreeNode_originalId, value, "f");
|
|
119
|
-
}
|
|
120
|
-
get originalName() {
|
|
121
|
-
return __classPrivateFieldGet(this, _TreeNode_originalName, "f");
|
|
122
|
-
}
|
|
123
|
-
set originalName(value) {
|
|
124
|
-
__classPrivateFieldSet(this, _TreeNode_originalName, value, "f");
|
|
125
|
-
}
|
|
126
|
-
get parent() {
|
|
127
|
-
return __classPrivateFieldGet(this, _TreeNode_parent, "f");
|
|
128
|
-
}
|
|
129
|
-
set parent(value) {
|
|
130
|
-
// check if it was removed from previous parent
|
|
131
|
-
if (__classPrivateFieldGet(this, _TreeNode_parent, "f"))
|
|
132
|
-
__classPrivateFieldGet(this, _TreeNode_parent, "f").removeChild(this);
|
|
133
|
-
// check if it is in children of new parent
|
|
134
|
-
if (value)
|
|
135
|
-
value.addChild(this);
|
|
136
|
-
__classPrivateFieldSet(this, _TreeNode_parent, value, "f");
|
|
137
|
-
}
|
|
138
|
-
get restrictViewports() {
|
|
139
|
-
return __classPrivateFieldGet(this, _TreeNode_restrictViewports, "f");
|
|
140
|
-
}
|
|
141
|
-
set restrictViewports(value) {
|
|
142
|
-
__classPrivateFieldSet(this, _TreeNode_restrictViewports, value, "f");
|
|
143
|
-
}
|
|
144
|
-
get transformations() {
|
|
145
|
-
return __classPrivateFieldGet(this, _TreeNode_transformations, "f");
|
|
146
|
-
}
|
|
147
|
-
set transformations(value) {
|
|
148
|
-
__classPrivateFieldSet(this, _TreeNode_transformations, value, "f");
|
|
149
|
-
}
|
|
150
|
-
get updateCallback() {
|
|
151
|
-
return __classPrivateFieldGet(this, _TreeNode_updateCallback, "f");
|
|
152
|
-
}
|
|
153
|
-
set updateCallback(value) {
|
|
154
|
-
__classPrivateFieldSet(this, _TreeNode_updateCallback, value, "f");
|
|
155
|
-
}
|
|
156
|
-
get updateCallbackConvertedObject() {
|
|
157
|
-
return __classPrivateFieldGet(this, _TreeNode_updateCallbackConvertedObject, "f");
|
|
158
|
-
}
|
|
159
|
-
set updateCallbackConvertedObject(value) {
|
|
160
|
-
__classPrivateFieldSet(this, _TreeNode_updateCallbackConvertedObject, value, "f");
|
|
161
|
-
}
|
|
162
|
-
get version() {
|
|
163
|
-
return __classPrivateFieldGet(this, _TreeNode_version, "f");
|
|
164
|
-
}
|
|
165
|
-
set version(value) {
|
|
166
|
-
__classPrivateFieldSet(this, _TreeNode_version, value, "f");
|
|
167
|
-
}
|
|
168
|
-
get visible() {
|
|
169
|
-
return __classPrivateFieldGet(this, _TreeNode_visible, "f");
|
|
170
|
-
}
|
|
171
|
-
set visible(value) {
|
|
172
|
-
__classPrivateFieldSet(this, _TreeNode_visible, value, "f");
|
|
173
|
-
}
|
|
174
|
-
get worldMatrix() {
|
|
175
|
-
const matrix = gl_matrix_1.mat4.create();
|
|
176
|
-
for (const transform of __classPrivateFieldGet(this, _TreeNode_transformations, "f"))
|
|
177
|
-
gl_matrix_1.mat4.multiply(matrix, matrix, transform.matrix);
|
|
178
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
179
|
-
let node = this;
|
|
180
|
-
while (node.parent) {
|
|
181
|
-
gl_matrix_1.mat4.multiply(matrix, node.parent.nodeMatrix, matrix);
|
|
182
|
-
node = node.parent;
|
|
183
|
-
}
|
|
184
|
-
return matrix;
|
|
185
|
-
}
|
|
186
|
-
addChild(child) {
|
|
187
|
-
if (Array.isArray(child)) {
|
|
188
|
-
let allAdded = true;
|
|
189
|
-
for (const c of child) {
|
|
190
|
-
const added = this.addChild(c);
|
|
191
|
-
if (!added)
|
|
192
|
-
allAdded = false;
|
|
193
|
-
}
|
|
194
|
-
return allAdded;
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
if (this.hasChild(child))
|
|
198
|
-
return false;
|
|
199
|
-
__classPrivateFieldGet(this, _TreeNode_children, "f").push(child);
|
|
200
|
-
if (child.parent)
|
|
201
|
-
child.parent.removeChild(child);
|
|
202
|
-
child.parent = this;
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
addData(data) {
|
|
207
|
-
const currentData = [...__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value];
|
|
208
|
-
if (Array.isArray(data)) {
|
|
209
|
-
currentData.push(...data);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
currentData.push(data);
|
|
213
|
-
}
|
|
214
|
-
__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").setData(currentData);
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
|
-
addTransformation(transformation) {
|
|
218
|
-
__classPrivateFieldGet(this, _TreeNode_transformations, "f").push(transformation);
|
|
219
|
-
return true;
|
|
220
|
-
}
|
|
221
|
-
clone() {
|
|
222
|
-
const clone = new this.constructor();
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
224
|
-
// @ts-ignore
|
|
225
|
-
clone.name = this.name;
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
227
|
-
// @ts-ignore
|
|
228
|
-
clone.originalId = this.originalId;
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
230
|
-
// @ts-ignore
|
|
231
|
-
clone.originalName = this.originalName;
|
|
232
|
-
clone.displayName = this.displayName;
|
|
233
|
-
clone.excludeViewports = this.excludeViewports;
|
|
234
|
-
clone.restrictViewports = this.restrictViewports;
|
|
235
|
-
clone.intersectionTest = this.intersectionTest;
|
|
236
|
-
clone.visible = this.visible;
|
|
237
|
-
for (const child of __classPrivateFieldGet(this, _TreeNode_children, "f"))
|
|
238
|
-
clone.addChild(child.clone());
|
|
239
|
-
for (const data of __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value)
|
|
240
|
-
clone.data.push(data.clone());
|
|
241
|
-
for (const transform of __classPrivateFieldGet(this, _TreeNode_transformations, "f"))
|
|
242
|
-
clone.addTransformation({
|
|
243
|
-
id: transform.id,
|
|
244
|
-
matrix: gl_matrix_1.mat4.clone(transform.matrix),
|
|
245
|
-
});
|
|
246
|
-
return clone;
|
|
247
|
-
}
|
|
248
|
-
cloneInstance() {
|
|
249
|
-
const clone = new this.constructor();
|
|
250
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
251
|
-
// @ts-ignore
|
|
252
|
-
clone.name = this.name;
|
|
253
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
254
|
-
// @ts-ignore
|
|
255
|
-
clone.originalId = this.originalId;
|
|
256
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
257
|
-
// @ts-ignore
|
|
258
|
-
clone.originalName = this.originalName;
|
|
259
|
-
clone.displayName = this.displayName;
|
|
260
|
-
clone.excludeViewports = this.excludeViewports;
|
|
261
|
-
clone.restrictViewports = this.restrictViewports;
|
|
262
|
-
clone.intersectionTest = this.intersectionTest;
|
|
263
|
-
clone.visible = this.visible;
|
|
264
|
-
for (const child of __classPrivateFieldGet(this, _TreeNode_children, "f"))
|
|
265
|
-
clone.addChild(child.cloneInstance());
|
|
266
|
-
for (const data of __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value)
|
|
267
|
-
clone.data.push(data);
|
|
268
|
-
for (const transform of __classPrivateFieldGet(this, _TreeNode_transformations, "f"))
|
|
269
|
-
clone.addTransformation({
|
|
270
|
-
id: transform.id,
|
|
271
|
-
matrix: gl_matrix_1.mat4.clone(transform.matrix),
|
|
272
|
-
});
|
|
273
|
-
return clone;
|
|
274
|
-
}
|
|
275
|
-
getChild(id) {
|
|
276
|
-
for (let i = 0; i < __classPrivateFieldGet(this, _TreeNode_children, "f").length; i++)
|
|
277
|
-
if (__classPrivateFieldGet(this, _TreeNode_children, "f")[i].id === id)
|
|
278
|
-
return __classPrivateFieldGet(this, _TreeNode_children, "f")[i];
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
getData(id) {
|
|
282
|
-
for (let i = 0; i < __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value.length; i++)
|
|
283
|
-
if (__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value[i].id === id)
|
|
284
|
-
return __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value[i];
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
getNodesByName(name) {
|
|
288
|
-
const nodes = [];
|
|
289
|
-
if (name === this.name)
|
|
290
|
-
nodes.push(this);
|
|
291
|
-
this.traverse((n) => {
|
|
292
|
-
if (name === n.name)
|
|
293
|
-
nodes.push(n);
|
|
294
|
-
});
|
|
295
|
-
return nodes;
|
|
296
|
-
}
|
|
297
|
-
getNodesByNameWithRegex(regex) {
|
|
298
|
-
const nodes = [];
|
|
299
|
-
if (regex.test(this.name))
|
|
300
|
-
nodes.push(this);
|
|
301
|
-
this.traverse((n) => {
|
|
302
|
-
if (regex.test(n.name))
|
|
303
|
-
nodes.push(n);
|
|
304
|
-
});
|
|
305
|
-
return nodes;
|
|
306
|
-
}
|
|
307
|
-
getOriginalNamePath() {
|
|
308
|
-
let path = this.originalName || "";
|
|
309
|
-
let node = this.parent;
|
|
310
|
-
while (node) {
|
|
311
|
-
path = (node.originalName || "") + "." + path;
|
|
312
|
-
node = node.parent;
|
|
313
|
-
}
|
|
314
|
-
return path;
|
|
315
|
-
}
|
|
316
|
-
getPath() {
|
|
317
|
-
let path = this.name;
|
|
318
|
-
let node = this.parent;
|
|
319
|
-
while (node) {
|
|
320
|
-
path = node.name + "." + path;
|
|
321
|
-
node = node.parent;
|
|
322
|
-
}
|
|
323
|
-
return path;
|
|
324
|
-
}
|
|
325
|
-
getTransformation(id) {
|
|
326
|
-
for (let i = 0; i < __classPrivateFieldGet(this, _TreeNode_transformations, "f").length; i++)
|
|
327
|
-
if (__classPrivateFieldGet(this, _TreeNode_transformations, "f")[i].id === id)
|
|
328
|
-
return __classPrivateFieldGet(this, _TreeNode_transformations, "f")[i];
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
hasChild(child) {
|
|
332
|
-
return __classPrivateFieldGet(this, _TreeNode_children, "f").includes(child);
|
|
333
|
-
}
|
|
334
|
-
hasData(data) {
|
|
335
|
-
return __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value.includes(data);
|
|
336
|
-
}
|
|
337
|
-
hasTransformation(transformation) {
|
|
338
|
-
return __classPrivateFieldGet(this, _TreeNode_transformations, "f").includes(transformation);
|
|
339
|
-
}
|
|
340
|
-
removeChild(child) {
|
|
341
|
-
if (Array.isArray(child)) {
|
|
342
|
-
let allRemoved = true;
|
|
343
|
-
for (const c of child) {
|
|
344
|
-
const removed = this.removeChild(c);
|
|
345
|
-
if (!removed)
|
|
346
|
-
allRemoved = false;
|
|
347
|
-
}
|
|
348
|
-
return allRemoved;
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
const index = __classPrivateFieldGet(this, _TreeNode_children, "f").indexOf(child);
|
|
352
|
-
if (index === -1)
|
|
353
|
-
return false;
|
|
354
|
-
__classPrivateFieldGet(this, _TreeNode_children, "f").splice(index, 1);
|
|
355
|
-
child.parent = undefined;
|
|
356
|
-
return true;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
removeData(data) {
|
|
360
|
-
const currentData = [...__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value];
|
|
361
|
-
if (Array.isArray(data)) {
|
|
362
|
-
let allRemoved = true;
|
|
363
|
-
for (const d of data) {
|
|
364
|
-
const index = currentData.indexOf(d);
|
|
365
|
-
if (index === -1) {
|
|
366
|
-
allRemoved = false;
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
currentData.splice(index, 1);
|
|
370
|
-
}
|
|
371
|
-
__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").setData(currentData);
|
|
372
|
-
return allRemoved;
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
const index = currentData.indexOf(data);
|
|
376
|
-
if (index === -1)
|
|
377
|
-
return false;
|
|
378
|
-
currentData.splice(index, 1);
|
|
379
|
-
__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").setData(currentData);
|
|
380
|
-
return true;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
removeTransformation(transformation) {
|
|
384
|
-
const index = __classPrivateFieldGet(this, _TreeNode_transformations, "f").indexOf(transformation);
|
|
385
|
-
if (index === -1)
|
|
386
|
-
return false;
|
|
387
|
-
__classPrivateFieldGet(this, _TreeNode_transformations, "f").splice(index, 1);
|
|
388
|
-
return true;
|
|
389
|
-
}
|
|
390
|
-
traverse(callback) {
|
|
391
|
-
callback(this);
|
|
392
|
-
for (let i = 0; i < this.children.length; i++)
|
|
393
|
-
this.children[i].traverse(callback);
|
|
394
|
-
}
|
|
395
|
-
traverseData(callback) {
|
|
396
|
-
for (let j = 0; j < __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value.length; j++)
|
|
397
|
-
callback(__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value[j]);
|
|
398
|
-
for (let i = 0; i < this.children.length; i++)
|
|
399
|
-
this.children[i].traverseData(callback);
|
|
400
|
-
}
|
|
401
|
-
updateVersion(parents = true, children = true) {
|
|
402
|
-
if (parents === true) {
|
|
403
|
-
let node = this;
|
|
404
|
-
while (node.parent) {
|
|
405
|
-
node = node.parent;
|
|
406
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
407
|
-
// @ts-ignore
|
|
408
|
-
node.version = __classPrivateFieldGet(this, _TreeNode_uuidGenerator, "f").create();
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
if (children === true) {
|
|
412
|
-
for (let i = 0; i < __classPrivateFieldGet(this, _TreeNode_children, "f").length; i++)
|
|
413
|
-
__classPrivateFieldGet(this, _TreeNode_children, "f")[i].updateVersion(parents, children);
|
|
414
|
-
}
|
|
415
|
-
const oldVersion = __classPrivateFieldGet(this, _TreeNode_version, "f");
|
|
416
|
-
__classPrivateFieldSet(this, _TreeNode_version, __classPrivateFieldGet(this, _TreeNode_uuidGenerator, "f").create(), "f");
|
|
417
|
-
if (__classPrivateFieldGet(this, _TreeNode_updateCallback, "f"))
|
|
418
|
-
__classPrivateFieldGet(this, _TreeNode_updateCallback, "f").call(this, __classPrivateFieldGet(this, _TreeNode_version, "f"), oldVersion);
|
|
419
|
-
}
|
|
420
|
-
onDataChanged(data) {
|
|
421
|
-
// ensure parent update versions are set
|
|
422
|
-
data.forEach((d) => {
|
|
423
|
-
if (d.parentsUpdateVersions[this.id] === undefined) {
|
|
424
|
-
d.parentsUpdateVersions[this.id] = () => {
|
|
425
|
-
this.updateVersion(true, false);
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
exports.TreeNode = TreeNode;
|
|
432
|
-
_TreeNode_boundingBox = new WeakMap(), _TreeNode_boundingBoxViewport = new WeakMap(), _TreeNode_children = new WeakMap(), _TreeNode_dataProxy = new WeakMap(), _TreeNode_id = new WeakMap(), _TreeNode_uuidGenerator = new WeakMap(), _TreeNode_convertedObject = new WeakMap(), _TreeNode_displayName = new WeakMap(), _TreeNode_excludeViewports = new WeakMap(), _TreeNode_intersectionTest = new WeakMap(), _TreeNode_name = new WeakMap(), _TreeNode_originalId = new WeakMap(), _TreeNode_originalName = new WeakMap(), _TreeNode_parent = new WeakMap(), _TreeNode_restrictViewports = new WeakMap(), _TreeNode_transformations = new WeakMap(), _TreeNode_updateCallback = new WeakMap(), _TreeNode_updateCallbackConvertedObject = new WeakMap(), _TreeNode_version = new WeakMap(), _TreeNode_visible = new WeakMap();
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _TreeNode_boundingBox, _TreeNode_boundingBoxViewport, _TreeNode_children, _TreeNode_dataProxy, _TreeNode_id, _TreeNode_uuidGenerator, _TreeNode_convertedObject, _TreeNode_displayName, _TreeNode_excludeViewports, _TreeNode_intersectionTest, _TreeNode_name, _TreeNode_originalId, _TreeNode_originalName, _TreeNode_parent, _TreeNode_restrictViewports, _TreeNode_transformations, _TreeNode_updateCallback, _TreeNode_updateCallbackConvertedObject, _TreeNode_version, _TreeNode_visible;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TreeNode = void 0;
|
|
16
|
+
const viewer_shared_math_1 = require("@shapediver/viewer.shared.math");
|
|
17
|
+
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
18
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
19
|
+
class TreeNode {
|
|
20
|
+
/**
|
|
21
|
+
* Creation of a node that can be used in the node tree.
|
|
22
|
+
*
|
|
23
|
+
* @param name the name of the node
|
|
24
|
+
* @param parent the parent of this node
|
|
25
|
+
* @param data the array of data
|
|
26
|
+
* @param transformations the array of transformations
|
|
27
|
+
*/
|
|
28
|
+
constructor(name = "node", parent, data = [], transformations = []) {
|
|
29
|
+
var _a;
|
|
30
|
+
_TreeNode_boundingBox.set(this, new viewer_shared_math_1.Box());
|
|
31
|
+
_TreeNode_boundingBoxViewport.set(this, {});
|
|
32
|
+
_TreeNode_children.set(this, []);
|
|
33
|
+
_TreeNode_dataProxy.set(this, new viewer_shared_services_1.ObservableArray({
|
|
34
|
+
initialData: [],
|
|
35
|
+
onChanged: this.onDataChanged.bind(this),
|
|
36
|
+
}));
|
|
37
|
+
_TreeNode_id.set(this, void 0);
|
|
38
|
+
_TreeNode_uuidGenerator.set(this, viewer_shared_services_1.UuidGenerator.instance);
|
|
39
|
+
_TreeNode_convertedObject.set(this, {});
|
|
40
|
+
_TreeNode_displayName.set(this, void 0);
|
|
41
|
+
_TreeNode_excludeViewports.set(this, []);
|
|
42
|
+
_TreeNode_intersectionTest.set(this, true);
|
|
43
|
+
_TreeNode_name.set(this, "");
|
|
44
|
+
_TreeNode_originalId.set(this, void 0);
|
|
45
|
+
_TreeNode_originalName.set(this, void 0);
|
|
46
|
+
_TreeNode_parent.set(this, void 0);
|
|
47
|
+
_TreeNode_restrictViewports.set(this, []);
|
|
48
|
+
_TreeNode_transformations.set(this, []);
|
|
49
|
+
_TreeNode_updateCallback.set(this, null);
|
|
50
|
+
_TreeNode_updateCallbackConvertedObject.set(this, null);
|
|
51
|
+
_TreeNode_version.set(this, void 0);
|
|
52
|
+
_TreeNode_visible.set(this, true);
|
|
53
|
+
__classPrivateFieldSet(this, _TreeNode_name, name, "f");
|
|
54
|
+
__classPrivateFieldSet(this, _TreeNode_parent, parent, "f");
|
|
55
|
+
__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").setData(data);
|
|
56
|
+
__classPrivateFieldSet(this, _TreeNode_transformations, transformations, "f");
|
|
57
|
+
__classPrivateFieldSet(this, _TreeNode_id, __classPrivateFieldGet(this, _TreeNode_uuidGenerator, "f").create(), "f");
|
|
58
|
+
__classPrivateFieldSet(this, _TreeNode_originalId, __classPrivateFieldGet(this, _TreeNode_id, "f"), "f");
|
|
59
|
+
__classPrivateFieldSet(this, _TreeNode_version, __classPrivateFieldGet(this, _TreeNode_uuidGenerator, "f").create(), "f");
|
|
60
|
+
(_a = __classPrivateFieldGet(this, _TreeNode_parent, "f")) === null || _a === void 0 ? void 0 : _a.addChild(this);
|
|
61
|
+
}
|
|
62
|
+
get boundingBox() {
|
|
63
|
+
return __classPrivateFieldGet(this, _TreeNode_boundingBox, "f");
|
|
64
|
+
}
|
|
65
|
+
get boundingBoxViewport() {
|
|
66
|
+
return __classPrivateFieldGet(this, _TreeNode_boundingBoxViewport, "f");
|
|
67
|
+
}
|
|
68
|
+
get children() {
|
|
69
|
+
return __classPrivateFieldGet(this, _TreeNode_children, "f");
|
|
70
|
+
}
|
|
71
|
+
get convertedObject() {
|
|
72
|
+
return __classPrivateFieldGet(this, _TreeNode_convertedObject, "f");
|
|
73
|
+
}
|
|
74
|
+
set convertedObject(value) {
|
|
75
|
+
__classPrivateFieldSet(this, _TreeNode_convertedObject, value, "f");
|
|
76
|
+
}
|
|
77
|
+
get data() {
|
|
78
|
+
return __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value;
|
|
79
|
+
}
|
|
80
|
+
get displayName() {
|
|
81
|
+
return __classPrivateFieldGet(this, _TreeNode_displayName, "f");
|
|
82
|
+
}
|
|
83
|
+
set displayName(value) {
|
|
84
|
+
__classPrivateFieldSet(this, _TreeNode_displayName, value, "f");
|
|
85
|
+
}
|
|
86
|
+
get excludeViewports() {
|
|
87
|
+
return __classPrivateFieldGet(this, _TreeNode_excludeViewports, "f");
|
|
88
|
+
}
|
|
89
|
+
set excludeViewports(value) {
|
|
90
|
+
__classPrivateFieldSet(this, _TreeNode_excludeViewports, value, "f");
|
|
91
|
+
}
|
|
92
|
+
get id() {
|
|
93
|
+
return __classPrivateFieldGet(this, _TreeNode_id, "f");
|
|
94
|
+
}
|
|
95
|
+
get intersectionTest() {
|
|
96
|
+
return __classPrivateFieldGet(this, _TreeNode_intersectionTest, "f");
|
|
97
|
+
}
|
|
98
|
+
set intersectionTest(value) {
|
|
99
|
+
__classPrivateFieldSet(this, _TreeNode_intersectionTest, value, "f");
|
|
100
|
+
}
|
|
101
|
+
get name() {
|
|
102
|
+
return __classPrivateFieldGet(this, _TreeNode_name, "f");
|
|
103
|
+
}
|
|
104
|
+
set name(value) {
|
|
105
|
+
__classPrivateFieldSet(this, _TreeNode_name, value, "f");
|
|
106
|
+
}
|
|
107
|
+
get nodeMatrix() {
|
|
108
|
+
const matrix = gl_matrix_1.mat4.create();
|
|
109
|
+
for (const transform of __classPrivateFieldGet(this, _TreeNode_transformations, "f"))
|
|
110
|
+
if (transform.id !== "sdtf")
|
|
111
|
+
gl_matrix_1.mat4.multiply(matrix, matrix, transform.matrix);
|
|
112
|
+
return matrix;
|
|
113
|
+
}
|
|
114
|
+
get originalId() {
|
|
115
|
+
return __classPrivateFieldGet(this, _TreeNode_originalId, "f");
|
|
116
|
+
}
|
|
117
|
+
set originalId(value) {
|
|
118
|
+
__classPrivateFieldSet(this, _TreeNode_originalId, value, "f");
|
|
119
|
+
}
|
|
120
|
+
get originalName() {
|
|
121
|
+
return __classPrivateFieldGet(this, _TreeNode_originalName, "f");
|
|
122
|
+
}
|
|
123
|
+
set originalName(value) {
|
|
124
|
+
__classPrivateFieldSet(this, _TreeNode_originalName, value, "f");
|
|
125
|
+
}
|
|
126
|
+
get parent() {
|
|
127
|
+
return __classPrivateFieldGet(this, _TreeNode_parent, "f");
|
|
128
|
+
}
|
|
129
|
+
set parent(value) {
|
|
130
|
+
// check if it was removed from previous parent
|
|
131
|
+
if (__classPrivateFieldGet(this, _TreeNode_parent, "f"))
|
|
132
|
+
__classPrivateFieldGet(this, _TreeNode_parent, "f").removeChild(this);
|
|
133
|
+
// check if it is in children of new parent
|
|
134
|
+
if (value)
|
|
135
|
+
value.addChild(this);
|
|
136
|
+
__classPrivateFieldSet(this, _TreeNode_parent, value, "f");
|
|
137
|
+
}
|
|
138
|
+
get restrictViewports() {
|
|
139
|
+
return __classPrivateFieldGet(this, _TreeNode_restrictViewports, "f");
|
|
140
|
+
}
|
|
141
|
+
set restrictViewports(value) {
|
|
142
|
+
__classPrivateFieldSet(this, _TreeNode_restrictViewports, value, "f");
|
|
143
|
+
}
|
|
144
|
+
get transformations() {
|
|
145
|
+
return __classPrivateFieldGet(this, _TreeNode_transformations, "f");
|
|
146
|
+
}
|
|
147
|
+
set transformations(value) {
|
|
148
|
+
__classPrivateFieldSet(this, _TreeNode_transformations, value, "f");
|
|
149
|
+
}
|
|
150
|
+
get updateCallback() {
|
|
151
|
+
return __classPrivateFieldGet(this, _TreeNode_updateCallback, "f");
|
|
152
|
+
}
|
|
153
|
+
set updateCallback(value) {
|
|
154
|
+
__classPrivateFieldSet(this, _TreeNode_updateCallback, value, "f");
|
|
155
|
+
}
|
|
156
|
+
get updateCallbackConvertedObject() {
|
|
157
|
+
return __classPrivateFieldGet(this, _TreeNode_updateCallbackConvertedObject, "f");
|
|
158
|
+
}
|
|
159
|
+
set updateCallbackConvertedObject(value) {
|
|
160
|
+
__classPrivateFieldSet(this, _TreeNode_updateCallbackConvertedObject, value, "f");
|
|
161
|
+
}
|
|
162
|
+
get version() {
|
|
163
|
+
return __classPrivateFieldGet(this, _TreeNode_version, "f");
|
|
164
|
+
}
|
|
165
|
+
set version(value) {
|
|
166
|
+
__classPrivateFieldSet(this, _TreeNode_version, value, "f");
|
|
167
|
+
}
|
|
168
|
+
get visible() {
|
|
169
|
+
return __classPrivateFieldGet(this, _TreeNode_visible, "f");
|
|
170
|
+
}
|
|
171
|
+
set visible(value) {
|
|
172
|
+
__classPrivateFieldSet(this, _TreeNode_visible, value, "f");
|
|
173
|
+
}
|
|
174
|
+
get worldMatrix() {
|
|
175
|
+
const matrix = gl_matrix_1.mat4.create();
|
|
176
|
+
for (const transform of __classPrivateFieldGet(this, _TreeNode_transformations, "f"))
|
|
177
|
+
gl_matrix_1.mat4.multiply(matrix, matrix, transform.matrix);
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
179
|
+
let node = this;
|
|
180
|
+
while (node.parent) {
|
|
181
|
+
gl_matrix_1.mat4.multiply(matrix, node.parent.nodeMatrix, matrix);
|
|
182
|
+
node = node.parent;
|
|
183
|
+
}
|
|
184
|
+
return matrix;
|
|
185
|
+
}
|
|
186
|
+
addChild(child) {
|
|
187
|
+
if (Array.isArray(child)) {
|
|
188
|
+
let allAdded = true;
|
|
189
|
+
for (const c of child) {
|
|
190
|
+
const added = this.addChild(c);
|
|
191
|
+
if (!added)
|
|
192
|
+
allAdded = false;
|
|
193
|
+
}
|
|
194
|
+
return allAdded;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
if (this.hasChild(child))
|
|
198
|
+
return false;
|
|
199
|
+
__classPrivateFieldGet(this, _TreeNode_children, "f").push(child);
|
|
200
|
+
if (child.parent)
|
|
201
|
+
child.parent.removeChild(child);
|
|
202
|
+
child.parent = this;
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
addData(data) {
|
|
207
|
+
const currentData = [...__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value];
|
|
208
|
+
if (Array.isArray(data)) {
|
|
209
|
+
currentData.push(...data);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
currentData.push(data);
|
|
213
|
+
}
|
|
214
|
+
__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").setData(currentData);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
addTransformation(transformation) {
|
|
218
|
+
__classPrivateFieldGet(this, _TreeNode_transformations, "f").push(transformation);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
clone() {
|
|
222
|
+
const clone = new this.constructor();
|
|
223
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
224
|
+
// @ts-ignore
|
|
225
|
+
clone.name = this.name;
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
227
|
+
// @ts-ignore
|
|
228
|
+
clone.originalId = this.originalId;
|
|
229
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
clone.originalName = this.originalName;
|
|
232
|
+
clone.displayName = this.displayName;
|
|
233
|
+
clone.excludeViewports = this.excludeViewports;
|
|
234
|
+
clone.restrictViewports = this.restrictViewports;
|
|
235
|
+
clone.intersectionTest = this.intersectionTest;
|
|
236
|
+
clone.visible = this.visible;
|
|
237
|
+
for (const child of __classPrivateFieldGet(this, _TreeNode_children, "f"))
|
|
238
|
+
clone.addChild(child.clone());
|
|
239
|
+
for (const data of __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value)
|
|
240
|
+
clone.data.push(data.clone());
|
|
241
|
+
for (const transform of __classPrivateFieldGet(this, _TreeNode_transformations, "f"))
|
|
242
|
+
clone.addTransformation({
|
|
243
|
+
id: transform.id,
|
|
244
|
+
matrix: gl_matrix_1.mat4.clone(transform.matrix),
|
|
245
|
+
});
|
|
246
|
+
return clone;
|
|
247
|
+
}
|
|
248
|
+
cloneInstance() {
|
|
249
|
+
const clone = new this.constructor();
|
|
250
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
251
|
+
// @ts-ignore
|
|
252
|
+
clone.name = this.name;
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
254
|
+
// @ts-ignore
|
|
255
|
+
clone.originalId = this.originalId;
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
257
|
+
// @ts-ignore
|
|
258
|
+
clone.originalName = this.originalName;
|
|
259
|
+
clone.displayName = this.displayName;
|
|
260
|
+
clone.excludeViewports = this.excludeViewports;
|
|
261
|
+
clone.restrictViewports = this.restrictViewports;
|
|
262
|
+
clone.intersectionTest = this.intersectionTest;
|
|
263
|
+
clone.visible = this.visible;
|
|
264
|
+
for (const child of __classPrivateFieldGet(this, _TreeNode_children, "f"))
|
|
265
|
+
clone.addChild(child.cloneInstance());
|
|
266
|
+
for (const data of __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value)
|
|
267
|
+
clone.data.push(data);
|
|
268
|
+
for (const transform of __classPrivateFieldGet(this, _TreeNode_transformations, "f"))
|
|
269
|
+
clone.addTransformation({
|
|
270
|
+
id: transform.id,
|
|
271
|
+
matrix: gl_matrix_1.mat4.clone(transform.matrix),
|
|
272
|
+
});
|
|
273
|
+
return clone;
|
|
274
|
+
}
|
|
275
|
+
getChild(id) {
|
|
276
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _TreeNode_children, "f").length; i++)
|
|
277
|
+
if (__classPrivateFieldGet(this, _TreeNode_children, "f")[i].id === id)
|
|
278
|
+
return __classPrivateFieldGet(this, _TreeNode_children, "f")[i];
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
getData(id) {
|
|
282
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value.length; i++)
|
|
283
|
+
if (__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value[i].id === id)
|
|
284
|
+
return __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value[i];
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
getNodesByName(name) {
|
|
288
|
+
const nodes = [];
|
|
289
|
+
if (name === this.name)
|
|
290
|
+
nodes.push(this);
|
|
291
|
+
this.traverse((n) => {
|
|
292
|
+
if (name === n.name)
|
|
293
|
+
nodes.push(n);
|
|
294
|
+
});
|
|
295
|
+
return nodes;
|
|
296
|
+
}
|
|
297
|
+
getNodesByNameWithRegex(regex) {
|
|
298
|
+
const nodes = [];
|
|
299
|
+
if (regex.test(this.name))
|
|
300
|
+
nodes.push(this);
|
|
301
|
+
this.traverse((n) => {
|
|
302
|
+
if (regex.test(n.name))
|
|
303
|
+
nodes.push(n);
|
|
304
|
+
});
|
|
305
|
+
return nodes;
|
|
306
|
+
}
|
|
307
|
+
getOriginalNamePath() {
|
|
308
|
+
let path = this.originalName || "";
|
|
309
|
+
let node = this.parent;
|
|
310
|
+
while (node) {
|
|
311
|
+
path = (node.originalName || "") + "." + path;
|
|
312
|
+
node = node.parent;
|
|
313
|
+
}
|
|
314
|
+
return path;
|
|
315
|
+
}
|
|
316
|
+
getPath() {
|
|
317
|
+
let path = this.name;
|
|
318
|
+
let node = this.parent;
|
|
319
|
+
while (node) {
|
|
320
|
+
path = node.name + "." + path;
|
|
321
|
+
node = node.parent;
|
|
322
|
+
}
|
|
323
|
+
return path;
|
|
324
|
+
}
|
|
325
|
+
getTransformation(id) {
|
|
326
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _TreeNode_transformations, "f").length; i++)
|
|
327
|
+
if (__classPrivateFieldGet(this, _TreeNode_transformations, "f")[i].id === id)
|
|
328
|
+
return __classPrivateFieldGet(this, _TreeNode_transformations, "f")[i];
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
hasChild(child) {
|
|
332
|
+
return __classPrivateFieldGet(this, _TreeNode_children, "f").includes(child);
|
|
333
|
+
}
|
|
334
|
+
hasData(data) {
|
|
335
|
+
return __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value.includes(data);
|
|
336
|
+
}
|
|
337
|
+
hasTransformation(transformation) {
|
|
338
|
+
return __classPrivateFieldGet(this, _TreeNode_transformations, "f").includes(transformation);
|
|
339
|
+
}
|
|
340
|
+
removeChild(child) {
|
|
341
|
+
if (Array.isArray(child)) {
|
|
342
|
+
let allRemoved = true;
|
|
343
|
+
for (const c of child) {
|
|
344
|
+
const removed = this.removeChild(c);
|
|
345
|
+
if (!removed)
|
|
346
|
+
allRemoved = false;
|
|
347
|
+
}
|
|
348
|
+
return allRemoved;
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
const index = __classPrivateFieldGet(this, _TreeNode_children, "f").indexOf(child);
|
|
352
|
+
if (index === -1)
|
|
353
|
+
return false;
|
|
354
|
+
__classPrivateFieldGet(this, _TreeNode_children, "f").splice(index, 1);
|
|
355
|
+
child.parent = undefined;
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
removeData(data) {
|
|
360
|
+
const currentData = [...__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value];
|
|
361
|
+
if (Array.isArray(data)) {
|
|
362
|
+
let allRemoved = true;
|
|
363
|
+
for (const d of data) {
|
|
364
|
+
const index = currentData.indexOf(d);
|
|
365
|
+
if (index === -1) {
|
|
366
|
+
allRemoved = false;
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
currentData.splice(index, 1);
|
|
370
|
+
}
|
|
371
|
+
__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").setData(currentData);
|
|
372
|
+
return allRemoved;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
const index = currentData.indexOf(data);
|
|
376
|
+
if (index === -1)
|
|
377
|
+
return false;
|
|
378
|
+
currentData.splice(index, 1);
|
|
379
|
+
__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").setData(currentData);
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
removeTransformation(transformation) {
|
|
384
|
+
const index = __classPrivateFieldGet(this, _TreeNode_transformations, "f").indexOf(transformation);
|
|
385
|
+
if (index === -1)
|
|
386
|
+
return false;
|
|
387
|
+
__classPrivateFieldGet(this, _TreeNode_transformations, "f").splice(index, 1);
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
traverse(callback) {
|
|
391
|
+
callback(this);
|
|
392
|
+
for (let i = 0; i < this.children.length; i++)
|
|
393
|
+
this.children[i].traverse(callback);
|
|
394
|
+
}
|
|
395
|
+
traverseData(callback) {
|
|
396
|
+
for (let j = 0; j < __classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value.length; j++)
|
|
397
|
+
callback(__classPrivateFieldGet(this, _TreeNode_dataProxy, "f").value[j]);
|
|
398
|
+
for (let i = 0; i < this.children.length; i++)
|
|
399
|
+
this.children[i].traverseData(callback);
|
|
400
|
+
}
|
|
401
|
+
updateVersion(parents = true, children = true) {
|
|
402
|
+
if (parents === true) {
|
|
403
|
+
let node = this;
|
|
404
|
+
while (node.parent) {
|
|
405
|
+
node = node.parent;
|
|
406
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
407
|
+
// @ts-ignore
|
|
408
|
+
node.version = __classPrivateFieldGet(this, _TreeNode_uuidGenerator, "f").create();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (children === true) {
|
|
412
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _TreeNode_children, "f").length; i++)
|
|
413
|
+
__classPrivateFieldGet(this, _TreeNode_children, "f")[i].updateVersion(parents, children);
|
|
414
|
+
}
|
|
415
|
+
const oldVersion = __classPrivateFieldGet(this, _TreeNode_version, "f");
|
|
416
|
+
__classPrivateFieldSet(this, _TreeNode_version, __classPrivateFieldGet(this, _TreeNode_uuidGenerator, "f").create(), "f");
|
|
417
|
+
if (__classPrivateFieldGet(this, _TreeNode_updateCallback, "f"))
|
|
418
|
+
__classPrivateFieldGet(this, _TreeNode_updateCallback, "f").call(this, __classPrivateFieldGet(this, _TreeNode_version, "f"), oldVersion);
|
|
419
|
+
}
|
|
420
|
+
onDataChanged(data) {
|
|
421
|
+
// ensure parent update versions are set
|
|
422
|
+
data.forEach((d) => {
|
|
423
|
+
if (d.parentsUpdateVersions[this.id] === undefined) {
|
|
424
|
+
d.parentsUpdateVersions[this.id] = () => {
|
|
425
|
+
this.updateVersion(true, false);
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
exports.TreeNode = TreeNode;
|
|
432
|
+
_TreeNode_boundingBox = new WeakMap(), _TreeNode_boundingBoxViewport = new WeakMap(), _TreeNode_children = new WeakMap(), _TreeNode_dataProxy = new WeakMap(), _TreeNode_id = new WeakMap(), _TreeNode_uuidGenerator = new WeakMap(), _TreeNode_convertedObject = new WeakMap(), _TreeNode_displayName = new WeakMap(), _TreeNode_excludeViewports = new WeakMap(), _TreeNode_intersectionTest = new WeakMap(), _TreeNode_name = new WeakMap(), _TreeNode_originalId = new WeakMap(), _TreeNode_originalName = new WeakMap(), _TreeNode_parent = new WeakMap(), _TreeNode_restrictViewports = new WeakMap(), _TreeNode_transformations = new WeakMap(), _TreeNode_updateCallback = new WeakMap(), _TreeNode_updateCallbackConvertedObject = new WeakMap(), _TreeNode_version = new WeakMap(), _TreeNode_visible = new WeakMap();
|
|
433
433
|
//# sourceMappingURL=TreeNode.js.map
|