diff options
Diffstat (limited to 'js/lib/geom/circle.js')
-rwxr-xr-x | js/lib/geom/circle.js | 1600 |
1 files changed, 830 insertions, 770 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index 086c1058..374dda58 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js | |||
@@ -18,173 +18,173 @@ var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | |||
18 | /////////////////////////////////////////////////////////////////////// | 18 | /////////////////////////////////////////////////////////////////////// |
19 | exports.Circle = Object.create(GeomObj, { | 19 | exports.Circle = Object.create(GeomObj, { |
20 | 20 | ||
21 | /////////////////////////////////////////////////////////////////////// | 21 | /////////////////////////////////////////////////////////////////////// |
22 | // Instance variables | 22 | // Instance variables |
23 | /////////////////////////////////////////////////////////////////////// | 23 | /////////////////////////////////////////////////////////////////////// |
24 | _width: { value : 2.0, writable: true }, | 24 | _width: { value : 2.0, writable: true }, |
25 | _height: { value : 2.0, writable: true }, | 25 | _height: { value : 2.0, writable: true }, |
26 | _xOffset: { value : 0, writable: true }, | 26 | _xOffset: { value : 0, writable: true }, |
27 | _yOffset: { value : 0, writable: true }, | 27 | _yOffset: { value : 0, writable: true }, |
28 | 28 | ||
29 | _radius: { value : 2.0, writable: true }, | 29 | _radius: { value : 2.0, writable: true }, |
30 | _strokeWidth: { value : 0.25, writable: true }, | 30 | _strokeWidth: { value : 0.25, writable: true }, |
31 | _innerRadius: { value : 0, writable: true }, | 31 | _innerRadius: { value : 0, writable: true }, |
32 | _ovalHeight: { value : 4.0, writable: true }, | 32 | _ovalHeight: { value : 4.0, writable: true }, |
33 | _strokeStyle: { value : "Solid", writable: true }, | 33 | _strokeStyle: { value : "Solid", writable: true }, |
34 | _aspectRatio: { value : 1.0, writable: true }, | 34 | _aspectRatio: { value : 1.0, writable: true }, |
35 | 35 | ||
36 | init: { | 36 | init: { |
37 | value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { | 37 | value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { |
38 | if(arguments.length > 0) { | 38 | if(arguments.length > 0) { |
39 | this._width = width; | 39 | this._width = width; |
40 | this._height = height; | 40 | this._height = height; |
41 | this._xOffset = xOffset; | 41 | this._xOffset = xOffset; |
42 | this._yOffset = yOffset; | 42 | this._yOffset = yOffset; |
43 | this._ovalHeight = 2.0 * this._radius; | 43 | this._ovalHeight = 2.0 * this._radius; |
44 | 44 | ||
45 | this._strokeWidth = strokeSize; | 45 | this._strokeWidth = strokeSize; |
46 | this._innerRadius = innerRadius; | 46 | this._innerRadius = innerRadius; |
47 | this._strokeColor = strokeColor; | 47 | this._strokeColor = strokeColor; |
48 | this._fillColor = fillColor; | 48 | this._fillColor = fillColor; |
49 | 49 | ||
50 | this._strokeStyle = strokeStyle; | 50 | this._strokeStyle = strokeStyle; |
51 | 51 | ||
52 | this._matrix = Matrix.I(4); | 52 | this._matrix = Matrix.I(4); |
53 | //this._matrix[12] = xOffset; | 53 | //this._matrix[12] = xOffset; |
54 | //this._matrix[13] = yOffset; | 54 | //this._matrix[13] = yOffset; |
55 | } | 55 | } |
56 | 56 | ||
57 | this.m_world = world; | 57 | this.m_world = world; |
58 | 58 | ||
59 | if(strokeMaterial) { | 59 | if(strokeMaterial) { |
60 | this._strokeMaterial = strokeMaterial.dup(); | 60 | this._strokeMaterial = strokeMaterial.dup(); |
61 | } else { | 61 | } else { |
62 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 62 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
63 | } | 63 | } |
64 | if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); | 64 | if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); |
65 | 65 | ||
66 | if(fillMaterial) { | 66 | if(fillMaterial) { |
67 | this._fillMaterial = fillMaterial.dup(); | 67 | this._fillMaterial = fillMaterial.dup(); |
68 | } else { | 68 | } else { |
69 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 69 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
70 | } | 70 | } |
71 | if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); | 71 | if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); |
72 | } | 72 | } |
73 | }, | 73 | }, |
74 | 74 | ||
75 | /////////////////////////////////////////////////////////////////////// | 75 | /////////////////////////////////////////////////////////////////////// |
76 | // Property Accessors | 76 | // Property Accessors |
77 | /////////////////////////////////////////////////////////////////////// | 77 | /////////////////////////////////////////////////////////////////////// |
78 | // TODO - Use getters/setters in the future | 78 | // TODO - Use getters/setters in the future |
79 | getStrokeWidth: { | 79 | getStrokeWidth: { |
80 | value: function() { | 80 | value: function() { |
81 | return this._strokeWidth; | 81 | return this._strokeWidth; |
82 | } | 82 | } |
83 | }, | 83 | }, |
84 | 84 | ||
85 | setStrokeWidth: { | 85 | setStrokeWidth: { |
86 | value: function(w) { | 86 | value: function(w) { |
87 | this._strokeWidth = w; | 87 | this._strokeWidth = w; |
88 | } | 88 | } |
89 | }, | 89 | }, |
90 | 90 | ||
91 | getStrokeMaterial: { | 91 | getStrokeMaterial: { |
92 | value: function() { | 92 | value: function() { |
93 | return this._strokeMaterial; | 93 | return this._strokeMaterial; |
94 | } | 94 | } |
95 | }, | 95 | }, |
96 | 96 | ||
97 | setStrokeMaterial: { | 97 | setStrokeMaterial: { |
98 | value: function(m) { | 98 | value: function(m) { |
99 | this._strokeMaterial = m; | 99 | this._strokeMaterial = m; |
100 | } | 100 | } |
101 | }, | 101 | }, |
102 | 102 | ||
103 | getFillMaterial: { | 103 | getFillMaterial: { |
104 | value: function() { | 104 | value: function() { |
105 | return this._fillMaterial; | 105 | return this._fillMaterial; |
106 | } | 106 | } |
107 | }, | 107 | }, |
108 | 108 | ||
109 | setFillMaterial: { | 109 | setFillMaterial: { |
110 | value: function(m) { | 110 | value: function(m) { |
111 | this._fillMaterial = m; | 111 | this._fillMaterial = m; |
112 | } | 112 | } |
113 | }, | 113 | }, |
114 | 114 | ||
115 | getRadius: { | 115 | getRadius: { |
116 | value: function() { | 116 | value: function() { |
117 | return this._radius; | 117 | return this._radius; |
118 | } | 118 | } |
119 | }, | 119 | }, |
120 | 120 | ||
121 | setRadius: { | 121 | setRadius: { |
122 | value: function(r) { | 122 | value: function(r) { |
123 | this._radius = r; | 123 | this._radius = r; |
124 | } | 124 | } |
125 | }, | 125 | }, |
126 | 126 | ||
127 | getInnerRadius: { | 127 | getInnerRadius: { |
128 | value: function() { | 128 | value: function() { |
129 | return this._innerRadius; | 129 | return this._innerRadius; |
130 | } | 130 | } |
131 | }, | 131 | }, |
132 | 132 | ||
133 | setInnerRadius: { | 133 | setInnerRadius: { |
134 | value: function(r) { | 134 | value: function(r) { |
135 | this._innerRadius = r; | 135 | this._innerRadius = r; |
136 | } | 136 | } |
137 | }, | 137 | }, |
138 | 138 | ||
139 | getStrokeStyle: { | 139 | getStrokeStyle: { |
140 | value: function() { | 140 | value: function() { |
141 | return this._strokeStyle; | 141 | return this._strokeStyle; |
142 | } | 142 | } |
143 | }, | 143 | }, |
144 | 144 | ||
145 | setStrokeStyle: { | 145 | setStrokeStyle: { |
146 | value: function(s) { | 146 | value: function(s) { |
147 | this._strokeStyle = s; | 147 | this._strokeStyle = s; |
148 | } | 148 | } |
149 | }, | 149 | }, |
150 | 150 | ||
151 | getWidth: { | 151 | getWidth: { |
152 | value: function() { | 152 | value: function() { |
153 | return this._width; | 153 | return this._width; |
154 | } | 154 | } |
155 | }, | 155 | }, |
156 | 156 | ||
157 | setWidth: { | 157 | setWidth: { |
158 | value: function(w) { | 158 | value: function(w) { |
159 | this._width = w; | 159 | this._width = w; |
160 | } | 160 | } |
161 | }, | 161 | }, |
162 | 162 | ||
163 | getHeight: { | 163 | getHeight: { |
164 | value: function() { | 164 | value: function() { |
165 | return this._height; | 165 | return this._height; |
166 | } | 166 | } |
167 | }, | 167 | }, |
168 | 168 | ||
169 | setHeight: { | 169 | setHeight: { |
170 | value: function(h) { |