Commit f03a0d5a authored by Evgeny's avatar Evgeny

Add BSPTree.Node traverse method

parent 3eb25f2b
......@@ -923,14 +923,13 @@ define(['three'], function(THREE, BSPTree){
BSPTree.prototype.toArray = function(){
var output = [];
function traverse(node){
if(node){
traverse(node.back);
output.push(node.element);
traverse(node.front);
}
}
traverse(this.root);
if(this.root){
this.root.traverse(function(elem){
output.push(elem);
});
}
return output;
}
......@@ -1030,6 +1029,22 @@ define(['three'], function(THREE, BSPTree){
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){
......
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