Commit f03a0d5a authored by Evgeny's avatar Evgeny

Add BSPTree.Node traverse method

parent 3eb25f2b
...@@ -923,14 +923,13 @@ define(['three'], function(THREE, BSPTree){ ...@@ -923,14 +923,13 @@ define(['three'], function(THREE, BSPTree){
BSPTree.prototype.toArray = function(){ BSPTree.prototype.toArray = function(){
var output = []; var output = [];
function traverse(node){
if(node){ if(this.root){
traverse(node.back); this.root.traverse(function(elem){
output.push(node.element); output.push(elem);
traverse(node.front); });
} }
}
traverse(this.root);
return output; return output;
} }
...@@ -1030,6 +1029,22 @@ define(['three'], function(THREE, BSPTree){ ...@@ -1030,6 +1029,22 @@ define(['three'], function(THREE, BSPTree){
return -1; return -1;
} }
} }
BSPTree.Node.prototype.traverse = function(callback){
if(!callback){
return;
}
if(this.back){
this.back.traverse(callback);
}
callback(this.element);
if(this.front){
this.front.traverse(callback);
}
}
BSPTree.LineNode = function(element){ BSPTree.LineNode = function(element){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment