@shapediver/viewer.shared.node-tree
Advanced tools
Comparing version 2.9.0 to 2.9.1
@@ -54,2 +54,4 @@ import { mat4 } from 'gl-matrix'; | ||
getData(id: string): U | undefined; | ||
getNodesByName(node: T, name: string): T[]; | ||
getNodesByNameWithRegex(node: T, regex: RegExp): T[]; | ||
getPath(): string; | ||
@@ -56,0 +58,0 @@ getTransformation(id: string): ITransformation | undefined; |
@@ -229,2 +229,24 @@ "use strict"; | ||
} | ||
getNodesByName(node, name) { | ||
let nodes = []; | ||
if (name === node.name) | ||
nodes.push(node); | ||
node.traverse((n) => { | ||
if (name === n.name) | ||
nodes.push(n); | ||
}); | ||
return nodes; | ||
} | ||
; | ||
getNodesByNameWithRegex(node, regex) { | ||
let nodes = []; | ||
if (regex.test(node.name)) | ||
nodes.push(node); | ||
node.traverse((n) => { | ||
if (regex.test(n.name)) | ||
nodes.push(n); | ||
}); | ||
return nodes; | ||
} | ||
; | ||
getPath() { | ||
@@ -231,0 +253,0 @@ let path = this.name; |
@@ -124,9 +124,21 @@ import { mat4 } from 'gl-matrix'; | ||
* Returns the child with the specified id | ||
*/ | ||
*/ | ||
getChild(id: string): T | undefined; | ||
/** | ||
* Returns the data item with the specified id | ||
*/ | ||
*/ | ||
getData(id: string): U | undefined; | ||
/** | ||
* Test this node and all it's descendents for nodes with the specified name and return them in an array. | ||
* @param node | ||
* @param name | ||
*/ | ||
getNodesByName(node: T, name: string): T[]; | ||
/** | ||
* Test this nodes name and all it's descendents name for nodes for the specified regex and return them in an array. | ||
* @param node | ||
* @param regex | ||
*/ | ||
getNodesByNameWithRegex(node: T, regex: RegExp): T[]; | ||
/** | ||
* Return the path to this node. | ||
@@ -133,0 +145,0 @@ */ |
{ | ||
"name": "@shapediver/viewer.shared.node-tree", | ||
"version": "2.9.0", | ||
"version": "2.9.1", | ||
"description": "", | ||
@@ -42,4 +42,4 @@ "keywords": [], | ||
"dependencies": { | ||
"@shapediver/viewer.shared.math": "2.9.0", | ||
"@shapediver/viewer.shared.services": "2.9.0", | ||
"@shapediver/viewer.shared.math": "2.9.1", | ||
"@shapediver/viewer.shared.services": "2.9.1", | ||
"@types/three": "0.149.0", | ||
@@ -49,3 +49,3 @@ "gl-matrix": "3.3.0", | ||
}, | ||
"gitHead": "6afb546a9c788a179b33091396819f3a738e25ad" | ||
"gitHead": "c7b6d22d492066831588ca0e9ce66844b921dc6f" | ||
} |
@@ -280,2 +280,20 @@ import { mat4 } from 'gl-matrix' | ||
public getNodesByName(node: T, name: string): T[] { | ||
let nodes: T[] = []; | ||
if (name === node.name) nodes.push(node); | ||
node.traverse((n) => { | ||
if (name === n.name) nodes.push(n); | ||
}); | ||
return nodes; | ||
}; | ||
public getNodesByNameWithRegex(node: T, regex: RegExp): T[] { | ||
let nodes: T[] = []; | ||
if (regex.test(node.name)) nodes.push(node); | ||
node.traverse((n) => { | ||
if (regex.test(n.name)) nodes.push(n); | ||
}); | ||
return nodes; | ||
}; | ||
public getPath(): string { | ||
@@ -282,0 +300,0 @@ let path = this.name; |
@@ -15,3 +15,3 @@ import { mat4 } from 'gl-matrix' | ||
export interface ITreeNode<T extends ITreeNode<any, ITreeNodeData<any>>, U extends ITreeNodeData<any>> { | ||
// #region Properties (17) | ||
// #region Properties (18) | ||
@@ -27,3 +27,3 @@ /** | ||
*/ | ||
readonly boundingBoxViewport: { [key: string]: IBox }; | ||
readonly boundingBoxViewport: { [key: string]: IBox }; | ||
/** | ||
@@ -103,5 +103,5 @@ * The children of this tree node. Can be added and remove via {@link addChild} and {@link removeChild}. | ||
// #endregion Properties (17) | ||
// #endregion Properties (18) | ||
// #region Public Methods (17) | ||
// #region Public Methods (20) | ||
@@ -139,9 +139,21 @@ /** | ||
* Returns the child with the specified id | ||
*/ | ||
*/ | ||
getChild(id: string): T | undefined; | ||
/** | ||
* Returns the data item with the specified id | ||
*/ | ||
*/ | ||
getData(id: string): U | undefined; | ||
/** | ||
* Test this node and all it's descendents for nodes with the specified name and return them in an array. | ||
* @param node | ||
* @param name | ||
*/ | ||
getNodesByName(node: T, name: string): T[] | ||
/** | ||
* Test this nodes name and all it's descendents name for nodes for the specified regex and return them in an array. | ||
* @param node | ||
* @param regex | ||
*/ | ||
getNodesByNameWithRegex(node: T, regex: RegExp): T[] | ||
/** | ||
* Return the path to this node. | ||
@@ -207,3 +219,3 @@ */ | ||
// #endregion Public Methods (17) | ||
// #endregion Public Methods (20) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
107785
1839
+ Added@shapediver/viewer.shared.build-data@2.9.1(transitive)
+ Added@shapediver/viewer.shared.math@2.9.1(transitive)
+ Added@shapediver/viewer.shared.services@2.9.1(transitive)
- Removed@shapediver/viewer.shared.build-data@2.9.0(transitive)
- Removed@shapediver/viewer.shared.math@2.9.0(transitive)
- Removed@shapediver/viewer.shared.services@2.9.0(transitive)