Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / gfx3d / scheduler.js @ 9

History | View | Annotate | Download (2.27 KB)

1
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6

    
7

    
8
if(!dojo._hasResource["dojox.gfx3d.scheduler"]){
9
dojo._hasResource["dojox.gfx3d.scheduler"]=true;
10
dojo.provide("dojox.gfx3d.scheduler");
11
dojo.provide("dojox.gfx3d.drawer");
12
dojo.require("dojox.gfx3d.vector");
13
dojo.mixin(dojox.gfx3d.scheduler,{zOrder:function(_1,_2){
14
_2=_2?_2:dojox.gfx3d.scheduler.order;
15
_1.sort(function(a,b){
16
return _2(b)-_2(a);
17
});
18
return _1;
19
},bsp:function(_3,_4){
20
_4=_4?_4:dojox.gfx3d.scheduler.outline;
21
var p=new dojox.gfx3d.scheduler.BinarySearchTree(_3[0],_4);
22
dojo.forEach(_3.slice(1),function(_5){
23
p.add(_5,_4);
24
});
25
return p.iterate(_4);
26
},order:function(it){
27
return it.getZOrder();
28
},outline:function(it){
29
return it.getOutline();
30
}});
31
dojo.declare("dojox.gfx3d.scheduler.BinarySearchTree",null,{constructor:function(_6,_7){
32
this.plus=null;
33
this.minus=null;
34
this.object=_6;
35
var o=_7(_6);
36
this.orient=o[0];
37
this.normal=dojox.gfx3d.vector.normalize(o);
38
},add:function(_8,_9){
39
var _a=0.5,o=_9(_8),v=dojox.gfx3d.vector,n=this.normal,a=this.orient,_b=dojox.gfx3d.scheduler.BinarySearchTree;
40
if(dojo.every(o,function(_c){
41
return Math.floor(_a+v.dotProduct(n,v.substract(_c,a)))<=0;
42
})){
43
if(this.minus){
44
this.minus.add(_8,_9);
45
}else{
46
this.minus=new _b(_8,_9);
47
}
48
}else{
49
if(dojo.every(o,function(_d){
50
return Math.floor(_a+v.dotProduct(n,v.substract(_d,a)))>=0;
51
})){
52
if(this.plus){
53
this.plus.add(_8,_9);
54
}else{
55
this.plus=new _b(_8,_9);
56
}
57
}else{
58
throw "The case: polygon cross siblings' plate is not implemneted yet";
59
}
60
}
61
},iterate:function(_e){
62
var _f=0.5;
63
var v=dojox.gfx3d.vector;
64
var _10=[];
65
var _11=null;
66
var _12={x:0,y:0,z:-10000};
67
if(Math.floor(_f+v.dotProduct(this.normal,v.substract(_12,this.orient)))<=0){
68
_11=[this.plus,this.minus];
69
}else{
70
_11=[this.minus,this.plus];
71
}
72
if(_11[0]){
73
_10=_10.concat(_11[0].iterate());
74
}
75
_10.push(this.object);
76
if(_11[1]){
77
_10=_10.concat(_11[1].iterate());
78
}
79
return _10;
80
}});
81
dojo.mixin(dojox.gfx3d.drawer,{conservative:function(_13,_14,_15){
82
dojo.forEach(this.objects,function(_16){
83
_16.destroy();
84
});
85
dojo.forEach(_14,function(_17){
86
_17.draw(_15.lighting);
87
});
88
},chart:function(_18,_19,_1a){
89
dojo.forEach(this.todos,function(_1b){
90
_1b.draw(_1a.lighting);
91
});
92
}});
93
}