root / trunk / web / dojo / dojox / charting / Chart3D.js @ 10
History | View | Annotate | Download (1.94 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.charting.Chart3D"]){ |
9 |
dojo._hasResource["dojox.charting.Chart3D"]=true; |
10 |
dojo.provide("dojox.charting.Chart3D");
|
11 |
dojo.require("dojox.gfx3d");
|
12 |
(function(){
|
13 |
var _1={x:0,y:0,z:1},v=dojox.gfx3d.vector,n=dojox.gfx.normalizedLength; |
14 |
dojo.declare("dojox.charting.Chart3D",null,{constructor:function(_2,_3,_4,_5){ |
15 |
this.node=dojo.byId(_2);
|
16 |
this.surface=dojox.gfx.createSurface(this.node,n(this.node.style.width),n(this.node.style.height)); |
17 |
this.view=this.surface.createViewport(); |
18 |
this.view.setLights(_3.lights,_3.ambient,_3.specular);
|
19 |
this.view.setCameraTransform(_4);
|
20 |
this.theme=_5;
|
21 |
this.walls=[];
|
22 |
this.plots=[];
|
23 |
},generate:function(){ |
24 |
return this._generateWalls()._generatePlots(); |
25 |
},invalidate:function(){ |
26 |
this.view.invalidate();
|
27 |
return this; |
28 |
},render:function(){ |
29 |
this.view.render();
|
30 |
return this; |
31 |
},addPlot:function(_6){ |
32 |
return this._add(this.plots,_6); |
33 |
},removePlot:function(_7){ |
34 |
return this._remove(this.plots,_7); |
35 |
},addWall:function(_8){ |
36 |
return this._add(this.walls,_8); |
37 |
},removeWall:function(_9){ |
38 |
return this._remove(this.walls,_9); |
39 |
},_add:function(_a,_b){ |
40 |
if(!dojo.some(_a,function(i){ |
41 |
return i==_b;
|
42 |
})){ |
43 |
_a.push(_b); |
44 |
this.view.invalidate();
|
45 |
} |
46 |
return this; |
47 |
},_remove:function(_c,_d){ |
48 |
var a=dojo.filter(_c,function(i){ |
49 |
return i!=_d;
|
50 |
}); |
51 |
return a.length<_c.length?(_c=a,this.invalidate()):this; |
52 |
},_generateWalls:function(){ |
53 |
for(var i=0;i<this.walls.length;++i){ |
54 |
if(v.dotProduct(_1,this.walls[i].normal)>0){ |
55 |
this.walls[i].generate(this); |
56 |
} |
57 |
} |
58 |
return this; |
59 |
},_generatePlots:function(){ |
60 |
var _e=0,m=dojox.gfx3d.matrix,i=0; |
61 |
for(;i<this.plots.length;++i){ |
62 |
_e+=this.plots[i].getDepth();
|
63 |
} |
64 |
for(--i;i>=0;--i){ |
65 |
var _f=this.view.createScene(); |
66 |
_f.setTransform(m.translate(0,0,-_e)); |
67 |
this.plots[i].generate(this,_f); |
68 |
_e-=this.plots[i].getDepth();
|
69 |
} |
70 |
return this; |
71 |
}}); |
72 |
})(); |
73 |
} |