|
@@ -9,17 +9,43 @@ module INSPECTOR{
|
|
/* Overrides super */
|
|
/* Overrides super */
|
|
protected _getTree() : Array<TreeItem> {
|
|
protected _getTree() : Array<TreeItem> {
|
|
let arr = [];
|
|
let arr = [];
|
|
|
|
+ // Tab containign mesh already in results
|
|
|
|
+ let alreadyIn = [];
|
|
|
|
|
|
// Returns true if the id of the given object starts and ends with '###'
|
|
// Returns true if the id of the given object starts and ends with '###'
|
|
- let shouldExcludeThisMesh = (obj:BABYLON.AbstractMesh) : boolean => {
|
|
|
|
|
|
+ let shouldExcludeThisMesh = (obj:BABYLON.Node) : boolean => {
|
|
return (obj.name && obj.name.indexOf('###') == 0 && obj.name.lastIndexOf('###', 0) === 0);
|
|
return (obj.name && obj.name.indexOf('###') == 0 && obj.name.lastIndexOf('###', 0) === 0);
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+ // Recursive method building the tree panel
|
|
|
|
+ let createNode = (obj : BABYLON.AbstractMesh) => {
|
|
|
|
+ let descendants = obj.getDescendants(true);
|
|
|
|
+
|
|
|
|
+ if (descendants.length > 0) {
|
|
|
|
+ let node = new TreeItem(this, new MeshAdapter(obj));
|
|
|
|
+ alreadyIn.push(node);
|
|
|
|
+ for (let child of descendants) {
|
|
|
|
+ if (child instanceof BABYLON.AbstractMesh) {
|
|
|
|
+ if (!shouldExcludeThisMesh(child)) {
|
|
|
|
+ let n = createNode(child);
|
|
|
|
+ node.add(n);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ node.update();
|
|
|
|
+ return node;
|
|
|
|
+ } else {
|
|
|
|
+ alreadyIn.push(obj);
|
|
|
|
+ return new TreeItem(this, new MeshAdapter(obj));
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
|
|
// get all meshes from the first scene
|
|
// get all meshes from the first scene
|
|
let instances = this._inspector.scene;
|
|
let instances = this._inspector.scene;
|
|
for (let mesh of instances.meshes) {
|
|
for (let mesh of instances.meshes) {
|
|
- if (!shouldExcludeThisMesh(mesh)){
|
|
|
|
- arr.push(new TreeItem(this, new MeshAdapter(mesh)));
|
|
|
|
|
|
+ if (alreadyIn.indexOf(mesh) == -1) {
|
|
|
|
+ let node = createNode(mesh);
|
|
|
|
+ arr.push(node);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return arr;
|
|
return arr;
|