aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/circle.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/circle.js')
-rwxr-xr-xjs/lib/geom/circle.js1388
1 files changed, 740 insertions, 648 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 218dcfa6..425b869a 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -7,705 +7,801 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
7var GeomObj = require("js/lib/geom/geom-obj").GeomObj; 7var GeomObj = require("js/lib/geom/geom-obj").GeomObj;
8var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive; 8var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive;
9var MaterialsModel = require("js/models/materials-model").MaterialsModel; 9var MaterialsModel = require("js/models/materials-model").MaterialsModel;
10var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils;
11var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
12
10/////////////////////////////////////////////////////////////////////// 13///////////////////////////////////////////////////////////////////////
11// Class GLCircle 14// Class GLCircle
12// GL representation of a circle. 15// GL representation of a circle.
13// Derived from class GLGeomObj 16// Derived from class GLGeomObj
14// The position and dimensions of the stroke, fill, and inner Radius should be in pixels 17// The position and dimensions of the stroke, fill, and inner Radius should be in pixels
15/////////////////////////////////////////////////////////////////////// 18///////////////////////////////////////////////////////////////////////
16var Circle = function GLCircle() { 19exports.Circle = Object.create(GeomObj, {
17 20
18 this.init = function( world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { 21 ///////////////////////////////////////////////////////////////////////
19 /////////////////////////////////////////////////////////////////////// 22 // Instance variables
20 // Instance variables 23 ///////////////////////////////////////////////////////////////////////
21 /////////////////////////////////////////////////////////////////////// 24 _width: { value : 2.0, writable: true },
22 this._width = 2.0; 25 _height: { value : 2.0, writable: true },
23 this._height = 2.0; 26 _xOffset: { value : 0, writable: true },
24 this._xOffset = 0; 27 _yOffset: { value : 0, writable: true },
25 this._yOffset = 0; 28
26 29 _radius: { value : 2.0, writable: true },
27 this._radius = 2.0; 30 _strokeWidth: { value : 0.25, writable: true },
28 this._strokeWidth = 0.25; 31 _innerRadius: { value : 0, writable: true },
29 this._innerRadius = 0; 32 _ovalHeight: { value : 4.0, writable: true },
30 33 _strokeStyle: { value : "Solid", writable: true },
31 this._ovalHeight = this._ovalHeight = 2.0 * this._radius; 34 _aspectRatio: { value : 1.0, writable: true },
32 35
33 this._strokeStyle = "Solid"; 36 init: {
34 37 value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) {
35 this._aspectRatio = 1.0; 38 if(arguments.length > 0) {
36 39 this._width = width;
37 if (arguments.length > 0) { 40 this._height = height;
38 this._width = width; 41 this._xOffset = xOffset;
39 this._height = height; 42 this._yOffset = yOffset;
40 this._xOffset = xOffset; 43 this._ovalHeight = 2.0 * this._radius;
41 this._yOffset = yOffset; 44
42 45 this._strokeWidth = strokeSize;
43 this._strokeWidth = strokeSize; 46 this._innerRadius = innerRadius;
44 this._innerRadius = innerRadius; 47 this._strokeColor = strokeColor;
45 this._strokeColor = strokeColor; 48 this._fillColor = fillColor;
46 this._fillColor = fillColor; 49
47 50 this._strokeStyle = strokeStyle;
48 this._strokeStyle = strokeStyle; 51
49 } 52 this._matrix = Matrix.I(4);
50 53 //this._matrix[12] = xOffset;
51 this.m_world = world; 54 //this._matrix[13] = yOffset;
52 55 }
53 if(strokeMaterial){ 56
54 this._strokeMaterial = strokeMaterial; 57 this.m_world = world;
55 } else {
56 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
57 }
58 58
59 if(fillMaterial) { 59 if(strokeMaterial) {
60 this._fillMaterial = fillMaterial; 60 this._strokeMaterial = strokeMaterial;
61 } else { 61 } else {
62 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); 62 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
63 }
64
65 if(fillMaterial) {
66 this._fillMaterial = fillMaterial;
67 } else {
68 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
69 }
63 } 70 }
64 }; 71 },
65 72
66 /////////////////////////////////////////////////////////////////////// 73 ///////////////////////////////////////////////////////////////////////
67 // Property Accessors 74 // Property Accessors
68 /////////////////////////////////////////////////////////////////////// 75 ///////////////////////////////////////////////////////////////////////
69 this.getStrokeWidth = function() { 76 // TODO - Use getters/setters in the future
70 return this._strokeWidth; 77 getStrokeWidth: {
71 }; 78 value: function() {
72 79 return this._strokeWidth;
73 this.setStrokeWidth = function(w) { 80 }
74 this._strokeWidth = w; 81 },
75 };
76
77 this.getStrokeMaterial = function() {
78 return this._strokeMaterial;
79 };
80 82
81 this.setStrokeMaterial = function(m) { 83 setStrokeWidth: {
82 this._strokeMaterial = m; 84 value: function(w) {
83 }; 85 this._strokeWidth = w;
86 }
87 },
84 88
85 this.getFillMaterial = function() { 89 getStrokeMaterial: {
86 return this._fillMaterial; 90 value: function() {
87 }; 91 return this._strokeMaterial;
92 }
93 },
88 94
89 this.setFillMaterial = function(m) { 95 setStrokeMaterial: {
90 this._fillMaterial = m; 96 value: function(m) {
91 }; 97 this._strokeMaterial = m;
98 }
99 },
92 100
93 this.getRadius = function() { 101 getFillMaterial: {
94 return this._radius; 102 value: function() {
95 }; 103 return this._fillMaterial;
104 }
105 },
96 106
97 this.setRadius = function(r) { 107 setFillMaterial: {
98 this._radius = r; 108 value: function(m) {
99 }; 109 this._fillMaterial = m;
110 }
111 },
100 112
101 this.getWorld = function() { 113 getRadius: {
102 return this._world; 114 value: function() {
103 }; 115 return this._radius;
116 }
117 },
104 118
105 this.setWorld = function(w) { 119 setRadius: {
106 this._world = w; 120 value: function(r) {
107 }; 121 this._radius = r;
122 }
123 },
108 124
109 this.getInnerRadius = function() { 125 getInnerRadius: {
110 return this._innerRadius; 126 value: function() {
111 }; 127 return this._innerRadius;
128 }
129 },
112 130
113 this.setInnerRadius = function(r) { 131 setInnerRadius: {
114 this._innerRadius = r; 132 value: function(r) {
115 }; 133 this._innerRadius = r;
134 }
135 },
116 136
117 this.getStrokeStyle = function() { 137 getStrokeStyle: {
118 return this._strokeStyle; 138 value: function() {
119 }; 139 return this._strokeStyle;
120 this.setStrokeStyle = function(s) { 140 }
121 this._strokeStyle = s; 141 },
122 };
123 142
124 this.getWidth = function() { 143 setStrokeStyle: {
125 return this._width; 144 value: function(s) {
126 }; 145 this._strokeStyle = s;
146 }
147 },
127 148
128 this.setWidth = function(w) { 149 getWidth: {
129 this._width = w; 150 value: function() {
130 }; 151 return this._width;
152 }
153 },
131 154
132 this.getHeight = function() { 155 setWidth: {
133 return this._height; 156 value: function(w) {
134 }; 157 this._width = w;
158 }
159 },
135 160
136 this.setHeight = function(h) { 161 getHeight: {
137 this._height = h; 162 value: function() {
138 }; 163 return this._height;
164 }
165 },
139 166
140 this.geomType = function() { 167 setHeight: {
141 return this.GEOM_TYPE_CIRCLE; 168 value: function(h) {
142 }; 169 this._height = h;
170 }
171 },
143 172
144 /////////////////////////////////////////////////////////////////////// 173 geomType: {
145 // Methods 174 value: function() {
146 /////////////////////////////////////////////////////////////////////// 175 return this.GEOM_TYPE_CIRCLE;
176 }
177 },
147 178
148 /////////////////////////////////////////////////////////////////////// 179 ///////////////////////////////////////////////////////////////////////