@shapediver/viewer.shared.node-tree 1.15.7 → 2.0.0
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/{AbstractTreeNodeData.d.ts → implementation/AbstractTreeNodeData.d.ts} +1 -1
- package/dist/implementation/AbstractTreeNodeData.d.ts.map +1 -0
- package/dist/{AbstractTreeNodeData.js → implementation/AbstractTreeNodeData.js} +0 -0
- package/dist/implementation/AbstractTreeNodeData.js.map +1 -0
- package/dist/implementation/Tree.d.ts +13 -0
- package/dist/implementation/Tree.d.ts.map +1 -0
- package/dist/{Tree.js → implementation/Tree.js} +17 -54
- package/dist/implementation/Tree.js.map +1 -0
- package/dist/implementation/TreeNode.d.ts +57 -0
- package/dist/implementation/TreeNode.d.ts.map +1 -0
- package/dist/{TreeNode.js → implementation/TreeNode.js} +91 -96
- package/dist/implementation/TreeNode.js.map +1 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{Tree.d.ts → interfaces/ITree.d.ts} +16 -22
- package/dist/interfaces/ITree.d.ts.map +1 -0
- package/dist/interfaces/ITree.js +3 -0
- package/dist/interfaces/ITree.js.map +1 -0
- package/dist/interfaces/ITreeNode.d.ts +115 -0
- package/dist/interfaces/ITreeNode.d.ts.map +1 -0
- package/dist/interfaces/ITreeNode.js +3 -0
- package/dist/interfaces/ITreeNode.js.map +1 -0
- package/package.json +12 -9
- package/src/implementation/AbstractTreeNodeData.ts +62 -0
- package/src/implementation/Tree.ts +120 -0
- package/src/implementation/TreeNode.ts +321 -0
- package/src/index.ts +21 -0
- package/src/interfaces/ISDObject.ts +11 -0
- package/src/interfaces/ITree.ts +56 -0
- package/src/interfaces/ITreeNode.ts +150 -0
- package/src/interfaces/ITreeNodeData.ts +6 -0
- package/tsconfig.json +17 -0
- package/dist/AbstractTreeNodeData.d.ts.map +0 -1
- package/dist/AbstractTreeNodeData.js.map +0 -1
- package/dist/Tree.d.ts.map +0 -1
- package/dist/Tree.js.map +0 -1
- package/dist/TreeNode.d.ts +0 -93
- package/dist/TreeNode.d.ts.map +0 -1
- package/dist/TreeNode.js.map +0 -1
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { mat4 } from 'gl-matrix'
|
|
2
|
+
import { container } from 'tsyringe'
|
|
3
|
+
import { UuidGenerator } from '@shapediver/viewer.shared.services'
|
|
4
|
+
import { Box, IBox } from '@shapediver/viewer.shared.math'
|
|
5
|
+
|
|
6
|
+
import { ITransformation, ITreeNode } from '../interfaces/ITreeNode'
|
|
7
|
+
import { ITreeNodeData } from '../interfaces/ITreeNodeData'
|
|
8
|
+
import { ISDObject } from '../interfaces/ISDObject'
|
|
9
|
+
|
|
10
|
+
export class TreeNode implements ITreeNode {
|
|
11
|
+
// #region Properties (13)
|
|
12
|
+
|
|
13
|
+
readonly #uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
|
|
14
|
+
|
|
15
|
+
readonly #children: ITreeNode[] = [];
|
|
16
|
+
readonly #data: ITreeNodeData[] = [];
|
|
17
|
+
#transformations: ITransformation[] = [];
|
|
18
|
+
|
|
19
|
+
readonly #id: string;
|
|
20
|
+
readonly #name: string = '';
|
|
21
|
+
#version: string;
|
|
22
|
+
#parent?: ITreeNode;
|
|
23
|
+
|
|
24
|
+
readonly #boundingBox: IBox = new Box();
|
|
25
|
+
readonly #transformedNodes: {
|
|
26
|
+
[key: string]: ISDObject
|
|
27
|
+
} = {};
|
|
28
|
+
|
|
29
|
+
#excludeViewports: string[] = [];
|
|
30
|
+
#restrictViewports: string[] = [];
|
|
31
|
+
|
|
32
|
+
#visible: boolean = true;
|
|
33
|
+
|
|
34
|
+
// #endregion Properties (13)
|
|
35
|
+
|
|
36
|
+
// #region Constructors (1)
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creation of a node that can be used in the node tree.
|
|
40
|
+
*
|
|
41
|
+
* @param name the name of the node
|
|
42
|
+
* @param parent the parent of this node
|
|
43
|
+
* @param data the array of data
|
|
44
|
+
* @param transformations the array of transformations
|
|
45
|
+
*/
|
|
46
|
+
constructor(
|
|
47
|
+
name: string = 'node',
|
|
48
|
+
parent?: ITreeNode,
|
|
49
|
+
data: ITreeNodeData[] = [],
|
|
50
|
+
transformations: ITransformation[] = []
|
|
51
|
+
) {
|
|
52
|
+
this.#name = name.replace(/\./g, "_");
|
|
53
|
+
this.#parent = parent;
|
|
54
|
+
this.#data = data;
|
|
55
|
+
this.#transformations = transformations;
|
|
56
|
+
|
|
57
|
+
this.#id = this.#uuidGenerator.create();
|
|
58
|
+
this.#version = this.#uuidGenerator.create();
|
|
59
|
+
this.#parent?.addChild(this);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// #endregion Constructors (1)
|
|
63
|
+
|
|
64
|
+
// #region Public Accessors (19)
|
|
65
|
+
|
|
66
|
+
public get boundingBox(): IBox {
|
|
67
|
+
return this.#boundingBox;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public get children(): ITreeNode[] {
|
|
71
|
+
return this.#children;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public get data(): ITreeNodeData[] {
|
|
75
|
+
return this.#data;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public get excludeViewports(): string[] {
|
|
79
|
+
return this.#excludeViewports;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public set excludeViewports(value: string[]) {
|
|
83
|
+
this.#excludeViewports = value;
|
|
84
|
+
this.updateVersion();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public get id(): string {
|
|
88
|
+
return this.#id;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public get name(): string {
|
|
92
|
+
return this.#name;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public get nodeMatrix(): mat4 {
|
|
96
|
+
const matrix: mat4 = mat4.create();
|
|
97
|
+
for (let transform of this.#transformations)
|
|
98
|
+
if (transform.id !== 'sdtf') mat4.multiply(matrix, matrix, transform.matrix);
|
|
99
|
+
return matrix;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public get parent(): ITreeNode | undefined {
|
|
103
|
+
return this.#parent;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public set parent(value: ITreeNode | undefined) {
|
|
107
|
+
// check if it was removed from previous parent
|
|
108
|
+
if (this.#parent)
|
|
109
|
+
this.#parent.removeChild(this);
|
|
110
|
+
|
|
111
|
+
// check if it is in children of new parent
|
|
112
|
+
if (value)
|
|
113
|
+
value.addChild(this);
|
|
114
|
+
|
|
115
|
+
this.#parent = value;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public get restrictViewports(): string[] {
|
|
119
|
+
return this.#restrictViewports;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public set restrictViewports(value: string[]) {
|
|
123
|
+
this.#restrictViewports = value;
|
|
124
|
+
this.updateVersion();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public get transformations(): ITransformation[] {
|
|
128
|
+
return this.#transformations;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public set transformations(value: ITransformation[]) {
|
|
132
|
+
this.#transformations = value;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public get transformedNodes(): {
|
|
136
|
+
[key: string]: ISDObject
|
|
137
|
+
} {
|
|
138
|
+
return this.#transformedNodes;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public get version(): string {
|
|
142
|
+
return this.#version;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public set version(value: string) {
|
|
146
|
+
this.#version = value;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public get visible(): boolean {
|
|
150
|
+
return this.#visible;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public set visible(value: boolean) {
|
|
154
|
+
this.#visible = value;
|
|
155
|
+
this.updateVersion();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public get worldMatrix(): mat4 {
|
|
159
|
+
const matrix: mat4 = mat4.create();
|
|
160
|
+
|
|
161
|
+
for (let transform of this.#transformations)
|
|
162
|
+
mat4.multiply(matrix, matrix, transform.matrix);
|
|
163
|
+
|
|
164
|
+
let node: ITreeNode = this;
|
|
165
|
+
while (node.parent) {
|
|
166
|
+
mat4.multiply(matrix, node.parent.nodeMatrix, matrix);
|
|
167
|
+
node = node.parent;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return matrix;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// #endregion Public Accessors (19)
|
|
174
|
+
|
|
175
|
+
// #region Public Methods (16)
|
|
176
|
+
|
|
177
|
+
public addChild(child: ITreeNode): boolean {
|
|
178
|
+
if (this.hasChild(child)) return false;
|
|
179
|
+
|
|
180
|
+
this.#children.push(child);
|
|
181
|
+
if (child.parent)
|
|
182
|
+
child.parent.removeChild(child);
|
|
183
|
+
(<ITreeNode | undefined>child.parent) = this;
|
|
184
|
+
this.updateVersion();
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public addData(data: ITreeNodeData): boolean {
|
|
189
|
+
this.#data.push(data);
|
|
190
|
+
this.updateVersion();
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public addTransformation(transformation: ITransformation): boolean {
|
|
195
|
+
this.#transformations.push(transformation);
|
|
196
|
+
this.updateVersion();
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public clone(): ITreeNode {
|
|
201
|
+
const clone = new TreeNode(this.name);
|
|
202
|
+
clone.visible = this.visible;
|
|
203
|
+
for (let child of this.#children)
|
|
204
|
+
clone.addChild(child.clone());
|
|
205
|
+
for (let data of this.#data)
|
|
206
|
+
clone.data.push(data.clone());
|
|
207
|
+
for (let transform of this.#transformations)
|
|
208
|
+
clone.addTransformation({
|
|
209
|
+
id: transform.id,
|
|
210
|
+
matrix: mat4.clone(transform.matrix)
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
return clone;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public cloneInstance(): ITreeNode {
|
|
217
|
+
const clone = new TreeNode(this.name);
|
|
218
|
+
clone.visible = this.visible;
|
|
219
|
+
for (let child of this.#children)
|
|
220
|
+
clone.addChild(child.cloneInstance());
|
|
221
|
+
for (let data of this.#data)
|
|
222
|
+
clone.data.push(data);
|
|
223
|
+
for (let transform of this.#transformations)
|
|
224
|
+
clone.addTransformation({
|
|
225
|
+
id: transform.id,
|
|
226
|
+
matrix: mat4.clone(transform.matrix)
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
return clone;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public getChild(id: string): ITreeNode | undefined {
|
|
233
|
+
for (let i = 0; i < this.#children.length; i++)
|
|
234
|
+
if (this.#children[i].id === id)
|
|
235
|
+
return this.#children[i];
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
public getData(id: string): ITreeNodeData | undefined {
|
|
240
|
+
for (let i = 0; i < this.#data.length; i++)
|
|
241
|
+
if (this.#data[i].id === id)
|
|
242
|
+
return this.#data[i];
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
public getPath(): string {
|
|
247
|
+
let path = this.name;
|
|
248
|
+
let node: ITreeNode | undefined = this.parent;
|
|
249
|
+
while (node) {
|
|
250
|
+
path = node.name + '.' + path;
|
|
251
|
+
node = node.parent;
|
|
252
|
+
}
|
|
253
|
+
return path;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public getTransformation(id: string): ITransformation | undefined {
|
|
257
|
+
for (let i = 0; i < this.#transformations.length; i++)
|
|
258
|
+
if (this.#transformations[i].id === id)
|
|
259
|
+
return this.#transformations[i];
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
public hasChild(child: ITreeNode): boolean {
|
|
264
|
+
return this.#children.includes(child);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
public hasData(data: ITreeNodeData): boolean {
|
|
268
|
+
return this.#data.includes(data);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
public hasTransformation(transformation: ITransformation): boolean {
|
|
272
|
+
return this.#transformations.includes(transformation);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
public removeChild(child: ITreeNode): boolean {
|
|
276
|
+
const index = this.#children.indexOf(child);
|
|
277
|
+
if (index === -1) return false;
|
|
278
|
+
this.#children.splice(index, 1);
|
|
279
|
+
(<ITreeNode | undefined>child.parent) = undefined;
|
|
280
|
+
this.updateVersion();
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
public removeData(data: ITreeNodeData): boolean {
|
|
285
|
+
const index = this.#data.indexOf(data);
|
|
286
|
+
if (index === -1) return false;
|
|
287
|
+
this.#data.splice(index, 1);
|
|
288
|
+
this.updateVersion();
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
public removeTransformation(transformation: ITransformation): boolean {
|
|
293
|
+
const index = this.#transformations.indexOf(transformation);
|
|
294
|
+
if (index === -1) return false;
|
|
295
|
+
this.#transformations.splice(index, 1);
|
|
296
|
+
this.updateVersion();
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
public traverse(callback: (node: ITreeNode) => void): void {
|
|
301
|
+
callback(this);
|
|
302
|
+
|
|
303
|
+
for(let i = 0; i < this.children.length; i++)
|
|
304
|
+
this.children[i].traverse(callback);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
public updateVersion(): void {
|
|
308
|
+
let node = <ITreeNode>this;
|
|
309
|
+
while (node.parent) {
|
|
310
|
+
node = node.parent;
|
|
311
|
+
(<any>node.version) = this.#uuidGenerator.create();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
for (let i = 0; i < this.#children.length; i++)
|
|
315
|
+
this.#children[i].updateVersion();
|
|
316
|
+
|
|
317
|
+
this.#version = this.#uuidGenerator.create();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// #endregion Public Methods (16)
|
|
321
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ITreeNodeData } from './interfaces/ITreeNodeData'
|
|
2
|
+
import { AbstractTreeNodeData } from './implementation/AbstractTreeNodeData'
|
|
3
|
+
import { ISDObject } from './interfaces/ISDObject'
|
|
4
|
+
import { ITree } from './interfaces/ITree'
|
|
5
|
+
import { Tree } from './implementation/Tree'
|
|
6
|
+
import { ITransformation, ITreeNode } from './interfaces/ITreeNode'
|
|
7
|
+
import { TreeNode } from './implementation/TreeNode'
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
ITree, Tree
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
ITreeNode, TreeNode, ITransformation
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
ITreeNodeData,
|
|
19
|
+
ISDObject,
|
|
20
|
+
AbstractTreeNodeData
|
|
21
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ITreeNode } from "./ITreeNode";
|
|
2
|
+
|
|
3
|
+
export interface ITree {
|
|
4
|
+
// #region Properties (1)
|
|
5
|
+
|
|
6
|
+
readonly root: ITreeNode;
|
|
7
|
+
|
|
8
|
+
// #endregion Properties (1)
|
|
9
|
+
|
|
10
|
+
// #region Public Methods (5)
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Add the node as a child of the corresponding parent node.
|
|
14
|
+
*
|
|
15
|
+
* @param node the node to be added
|
|
16
|
+
* @param parent the targeted parent node
|
|
17
|
+
* @param root optional root at which the process begins, root node will be used per default
|
|
18
|
+
*/
|
|
19
|
+
addNode(node: ITreeNode, parent?: ITreeNode, root?: ITreeNode): boolean;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Add the node at the corresponding path. (paths are dot separated ids)
|
|
23
|
+
*
|
|
24
|
+
* @param node the node to be added
|
|
25
|
+
* @param path the path at which the node should be added
|
|
26
|
+
* @param root optional root at which the process begins, root node will be used per default
|
|
27
|
+
*/
|
|
28
|
+
addNodeAtPath(node: ITreeNode, path?: string, root?: ITreeNode): boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get the node at the provided path.
|
|
32
|
+
*
|
|
33
|
+
* @param path
|
|
34
|
+
* @param root
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
getNodeAtPath(path?: string, root?: ITreeNode): ITreeNode | null;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Remove a node from the tree.
|
|
41
|
+
*
|
|
42
|
+
* @param node the node to remove
|
|
43
|
+
* @param root optional root at which the process begins, root node will be used per default
|
|
44
|
+
*/
|
|
45
|
+
removeNode(node: ITreeNode, root?: ITreeNode): boolean;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Remove a node via the path of it.
|
|
49
|
+
*
|
|
50
|
+
* @param path the path of the node to be removed
|
|
51
|
+
* @param root optional root at which the process begins, root node will be used per default
|
|
52
|
+
*/
|
|
53
|
+
removeNodeAtPath(path: string, root?: ITreeNode): boolean;
|
|
54
|
+
|
|
55
|
+
// #endregion Public Methods (5)
|
|
56
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { mat4 } from 'gl-matrix'
|
|
2
|
+
import { IBox } from '@shapediver/viewer.shared.math'
|
|
3
|
+
import { ITreeNodeData } from './ITreeNodeData'
|
|
4
|
+
import { ISDObject } from './ISDObject'
|
|
5
|
+
|
|
6
|
+
export interface ITransformation {
|
|
7
|
+
// #region Properties (2)
|
|
8
|
+
|
|
9
|
+
id: string,
|
|
10
|
+
matrix: mat4
|
|
11
|
+
|
|
12
|
+
// #endregion Properties (2)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ITreeNode {
|
|
16
|
+
// #region Properties (16)
|
|
17
|
+
|
|
18
|
+
readonly children: ITreeNode[];
|
|
19
|
+
readonly data: ITreeNodeData[];
|
|
20
|
+
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly version: string;
|
|
24
|
+
readonly parent?: ITreeNode;
|
|
25
|
+
|
|
26
|
+
readonly nodeMatrix: mat4;
|
|
27
|
+
readonly worldMatrix: mat4;
|
|
28
|
+
|
|
29
|
+
readonly boundingBox: IBox;
|
|
30
|
+
readonly transformedNodes: {
|
|
31
|
+
[key: string]: ISDObject
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
excludeViewports: string[];
|
|
35
|
+
restrictViewports: string[];
|
|
36
|
+
|
|
37
|
+
transformations: ITransformation[];
|
|
38
|
+
visible: boolean;
|
|
39
|
+
|
|
40
|
+
// #endregion Properties (16)
|
|
41
|
+
|
|
42
|
+
// #region Public Methods (13)
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Add a child to the children of this node.
|
|
46
|
+
*
|
|
47
|
+
* @param child the child to add
|
|
48
|
+
*/
|
|
49
|
+
addChild(child: ITreeNode): boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Add a data item to node.
|
|
53
|
+
*
|
|
54
|
+
* @param data the data to add
|
|
55
|
+
*/
|
|
56
|
+
addData(data: ITreeNodeData): boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Add a transformation to this node.
|
|
60
|
+
*
|
|
61
|
+
* @param transformation the transformation to add
|
|
62
|
+
*/
|
|
63
|
+
addTransformation(transformation: ITransformation): boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Clones this node and all its children.
|
|
67
|
+
*/
|
|
68
|
+
clone(): ITreeNode;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Clones this node and all its children.
|
|
72
|
+
*/
|
|
73
|
+
cloneInstance(): ITreeNode;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns the child with the specified id
|
|
77
|
+
*/
|
|
78
|
+
getChild(id: string): ITreeNode | undefined;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Returns the data item with the specified id
|
|
82
|
+
*/
|
|
83
|
+
getData(id: string): ITreeNodeData | undefined;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns the transformation with the specified id
|
|
87
|
+
*/
|
|
88
|
+
getTransformation(id: string): ITransformation | undefined;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Return the path to this node.
|
|
92
|
+
*/
|
|
93
|
+
getPath(): string;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Check for existence of a child from the children of this node.
|
|
97
|
+
*
|
|
98
|
+
* @param child the child to check
|
|
99
|
+
*/
|
|
100
|
+
hasChild(child: ITreeNode): boolean;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Check for existence of a data item of this node.
|
|
104
|
+
*
|
|
105
|
+
* @param data the data item to check
|
|
106
|
+
*/
|
|
107
|
+
hasData(data: ITreeNodeData): boolean;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Check for existence of a transformation of this node.
|
|
111
|
+
*
|
|
112
|
+
* @param data the transformation to check
|
|
113
|
+
*/
|
|
114
|
+
hasTransformation(transformation: ITransformation): boolean;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Remove a child from the children of this node.
|
|
118
|
+
*
|
|
119
|
+
* @param child the child to remove
|
|
120
|
+
*/
|
|
121
|
+
removeChild(child: ITreeNode): boolean;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Remove a data item from this node.
|
|
125
|
+
*
|
|
126
|
+
* @param data the data to remove
|
|
127
|
+
*/
|
|
128
|
+
removeData(data: ITreeNodeData): boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Remove a transformation from this node.
|
|
132
|
+
*
|
|
133
|
+
* @param transformation the transformation to remove
|
|
134
|
+
*/
|
|
135
|
+
removeTransformation(transformation: ITransformation): boolean;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Traverse this node and all it's children and executes the callback for all of them
|
|
139
|
+
*
|
|
140
|
+
* @param callback
|
|
141
|
+
*/
|
|
142
|
+
traverse(callback: (node: ITreeNode) => void): void;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Update the version
|
|
146
|
+
*/
|
|
147
|
+
updateVersion(): void;
|
|
148
|
+
|
|
149
|
+
// #endregion Public Methods (13)
|
|
150
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractTreeNodeData.d.ts","sourceRoot":"","sources":["../src/AbstractTreeNodeData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAE1D,8BAAsB,oBAAqB,YAAW,aAAa;;IAajE;;;;OAIG;gBACS,EAAE,CAAC,EAAE,MAAM;IASvB,IAAW,EAAE,IAAI,MAAM,CAEtB;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;IAMD;;OAEG;IACI,aAAa,IAAI,IAAI;IAQ5B;;OAEG;aACa,KAAK,IAAI,aAAa;CAGvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractTreeNodeData.js","sourceRoot":"","sources":["../src/AbstractTreeNodeData.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAoC;AACpC,+EAA0F;AAI1F,MAAsB,oBAAoB;IASxC,4BAA4B;IAE5B,2BAA2B;IAE3B;;;;OAIG;IACH,YAAY,EAAW;QAjBvB,yBAAyB;QAEzB,gDAAiB;QAEjB,2CAAqB;QACrB,8CAAwD,oBAAS,CAAC,OAAO,CAAC,sCAAa,CAAC,EAAC;QACzF,4CAAkD,oBAAS,CAAC,OAAO,CAAC,oCAAW,CAAC,EAAC;QAY/E,uBAAA,IAAI,4BAAO,EAAE,IAAI,uBAAA,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AAI,CAAC,MAAM,CAAC,CAAC;YAErE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;gBACrD,IAAG,GAAG;oBAAE,OAAO,GAAG,CAAC;aACpB;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CAGF,CAAA;;AAtJY,IAAI;IADhB,oBAAS,EAAE;;GACC,IAAI,CAsJhB;AAtJY,oBAAI"}
|
package/dist/TreeNode.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { mat4 } from 'gl-matrix';
|
|
2
|
-
import { Box } from '@shapediver/viewer.shared.math';
|
|
3
|
-
import { ITreeNodeData } from './interfaces/ITreeNodeData';
|
|
4
|
-
import { ISDObject } from './interfaces/ISDObject';
|
|
5
|
-
export interface ITransformation {
|
|
6
|
-
id: string;
|
|
7
|
-
matrix: mat4;
|
|
8
|
-
}
|
|
9
|
-
export declare class TreeNode {
|
|
10
|
-
#private;
|
|
11
|
-
/**
|
|
12
|
-
* Creation of a node that can be used in the node tree.
|
|
13
|
-
*
|
|
14
|
-
* @param name the name of the node
|
|
15
|
-
* @param parent the parent of this node
|
|
16
|
-
* @param data the array of data
|
|
17
|
-
* @param transformations the array of transformations
|
|
18
|
-
*/
|
|
19
|
-
constructor(name?: string, parent?: TreeNode | null, data?: ITreeNodeData[], transformations?: ITransformation[]);
|
|
20
|
-
get bone(): boolean;
|
|
21
|
-
set bone(value: boolean);
|
|
22
|
-
get boundingBox(): Box;
|
|
23
|
-
set boundingBox(value: Box);
|
|
24
|
-
get children(): TreeNode[];
|
|
25
|
-
get data(): ITreeNodeData[];
|
|
26
|
-
get excludeViewers(): string[];
|
|
27
|
-
set excludeViewers(value: string[]);
|
|
28
|
-
get id(): string;
|
|
29
|
-
set id(value: string);
|
|
30
|
-
get includeViewers(): string[];
|
|
31
|
-
set includeViewers(value: string[]);
|
|
32
|
-
get name(): string;
|
|
33
|
-
get nodeMatrix(): mat4;
|
|
34
|
-
get nodeMatrixSDTF(): mat4;
|
|
35
|
-
get parent(): TreeNode | null;
|
|
36
|
-
set parent(value: TreeNode | null);
|
|
37
|
-
get transformations(): ITransformation[];
|
|
38
|
-
set transformations(value: ITransformation[]);
|
|
39
|
-
get transformedNodes(): {
|
|
40
|
-
[key: string]: ISDObject;
|
|
41
|
-
};
|
|
42
|
-
set transformedNodes(value: {
|
|
43
|
-
[key: string]: ISDObject;
|
|
44
|
-
});
|
|
45
|
-
get version(): string;
|
|
46
|
-
get visible(): boolean;
|
|
47
|
-
set visible(value: boolean);
|
|
48
|
-
get worldMatrix(): mat4;
|
|
49
|
-
/**
|
|
50
|
-
* Add a child from the children of this node.
|
|
51
|
-
*
|
|
52
|
-
* @param child the child to add
|
|
53
|
-
*/
|
|
54
|
-
addChild(child: TreeNode): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Clones this node and all its children.
|
|
57
|
-
*/
|
|
58
|
-
clone(): TreeNode;
|
|
59
|
-
/**
|
|
60
|
-
* Clones this node and all its children.
|
|
61
|
-
*/
|
|
62
|
-
cloneInstance(): TreeNode;
|
|
63
|
-
/**
|
|
64
|
-
* Returns the child with the specified id
|
|
65
|
-
* @return {TreeNode}
|
|
66
|
-
*/
|
|
67
|
-
getChild(id: string): TreeNode | null;
|
|
68
|
-
/**
|
|
69
|
-
* Return the path to this node.
|
|
70
|
-
*/
|
|
71
|
-
getPath(): string;
|
|
72
|
-
/**
|
|
73
|
-
* Check for existence of a child from the children of this node.
|
|
74
|
-
*
|
|
75
|
-
* @param child the child to check
|
|
76
|
-
*/
|
|
77
|
-
hasChild(child: TreeNode): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Remove a child from the children of this node.
|
|
80
|
-
*
|
|
81
|
-
* @param child the child to remove
|
|
82
|
-
*/
|
|
83
|
-
removeChild(child: TreeNode): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Update the version
|
|
86
|
-
*/
|
|
87
|
-
updateVersion(): void;
|
|
88
|
-
/**
|
|
89
|
-
* Only updates the version of this node.
|
|
90
|
-
*/
|
|
91
|
-
updateVersionAtomic(): void;
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=TreeNode.d.ts.map
|