//>>built
define("dojox/gfx3d/scheduler",["dojo/_base/lang","dojo/_base/array","dojo/_base/declare","./_base","./vector"],function(k,g,n,e,f){e.scheduler={zOrder:function(b,a){a=a?a:e.scheduler.order;b.sort(function(c,d){return a(d)-a(c)});return b},bsp:function(b,a){a=a?a:e.scheduler.outline;var c=new e.scheduler.BinarySearchTree(b[0],a);g.forEach(b.slice(1),function(d){c.add(d,a)});return c.iterate(a)},order:function(b){return b.getZOrder()},outline:function(b){return b.getOutline()}};k=n("dojox.gfx3d.scheduler.BinarySearchTree",
null,{constructor:function(b,a){this.minus=this.plus=null;this.object=b;var c=a(b);this.orient=c[0];this.normal=f.normalize(c)},add:function(b,a){var c=a(b),d=this.normal,l=this.orient,m=e.scheduler.BinarySearchTree;if(g.every(c,function(h){return 0>=Math.floor(.5+f.dotProduct(d,f.substract(h,l)))}))this.minus?this.minus.add(b,a):this.minus=new m(b,a);else if(g.every(c,function(h){return 0<=Math.floor(.5+f.dotProduct(d,f.substract(h,l)))}))this.plus?this.plus.add(b,a):this.plus=new m(b,a);else throw"The case: polygon cross siblings' plate is not implemented yet";
},iterate:function(b){b=[];var a=null;a=0>=Math.floor(.5+f.dotProduct(this.normal,f.substract({x:0,y:0,z:-1E4},this.orient)))?[this.plus,this.minus]:[this.minus,this.plus];a[0]&&(b=b.concat(a[0].iterate()));b.push(this.object);a[1]&&(b=b.concat(a[1].iterate()));return b}});e.drawer={conservative:function(b,a,c){g.forEach(this.objects,function(d){d.destroy()});g.forEach(a,function(d){d.draw(c.lighting)})},chart:function(b,a,c){g.forEach(this.todos,function(d){d.draw(c.lighting)})}};return{scheduler:e.scheduler,
drawer:e.drawer,BinarySearchTree:k}});