aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/geom-obj.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/geom-obj.js')
-rwxr-xr-xjs/lib/geom/geom-obj.js852
1 files changed, 459 insertions, 393 deletions
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js
index 7cb9b80f..4cb21a25 100755
--- a/js/lib/geom/geom-obj.js
+++ b/js/lib/geom/geom-obj.js
@@ -10,184 +10,239 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel;
10// Class GLGeomObj 10// Class GLGeomObj
11// Super class for all geometry classes 11// Super class for all geometry classes
12/////////////////////////////////////////////////////////////////////// 12///////////////////////////////////////////////////////////////////////
13var GeomObj = function GLGeomObj() { 13exports.GeomObj = Object.create(Object.prototype, {
14 /////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////
15 // Constants 15 // Constants
16 /////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////
17 this.GEOM_TYPE_RECTANGLE = 1; 17 // TODO - Is there a way to make these static constants?
18 this.GEOM_TYPE_CIRCLE = 2; 18 GEOM_TYPE_RECTANGLE: { value : 1, writable: false },
19 this.GEOM_TYPE_LINE = 3; 19 GEOM_TYPE_CIRCLE: { value : 2, writable: false },
20 this.GEOM_TYPE_PATH = 4; 20 GEOM_TYPE_LINE: { value : 3, writable: false },
21 this.GEOM_TYPE_CUBIC_BEZIER = 5; 21 GEOM_TYPE_PATH: { value : 4, writable: false },
22 this.GEOM_TYPE_BRUSH_STROKE = 6; 22 GEOM_TYPE_CUBIC_BEZIER: { value : 5, writable: false },
23 this.GEOM_TYPE_UNDEFINED = -1; 23 GEOM_TYPE_BRUSH_STROKE: { value : 6, writable: false },
24 24 GEOM_TYPE_UNDEFINED: { value : -1, writable: false },
25 // Needed for calculating dashed/dotted strokes
26 this.DASH_LENGTH = 0.15;
27 this.DOT_LENGTH = 0.05;
28 this.GAP_LENGTH = 0.05;
29 25
30 /////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////
31 // Instance variables 27 // Instance variables
32 /////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////
33 this._matrix = Matrix.I(4); 29 _matrix: { value : Matrix.I(4), writable: true },
34 30
35 this._next = undefined; 31 _next: { value : undefined, writable: true },
36 this._prev = undefined; 32 _prev: { value : undefined, writable: true },
37 this._child = undefined; 33 _child: { value : undefined, writable: true },
38 this._parent = undefined; 34 _parent: { value : undefined, writable: true },
39 35
40 this.m_world = null; 36 m_world: { value : null, writable: true },
41 37
42 // stroke and fill colors 38 // stroke and fill colors
43 this._strokeColor = [0, 0, 0, 0]; 39 _strokeColor: { value : [0, 0, 0, 0], writable: true },
44 this._fillColor = [0, 0, 0, 0]; 40 _fillColor: { value : [0, 0, 0, 0], writable: true },
45 41
46 // stroke and fill materials 42 // stroke and fill materials
47 this._fillMaterial = null; 43 _fillMaterial: { value : null, writable: true },
48 this._strokeMaterial = null; 44 _strokeMaterial: { value : null, writable: true },
49 45
50 // Shapes (such as lines) that don't support fill should set this to false 46 // Shapes (such as lines) that don't support fill should set this to false
51 this.canFill = true; 47 canFill: { value : true, writable: true },
52 48
53 // array of primitives - used in RDGE 49 // array of primitives - used in RDGE
54 this._primArray = []; 50 _primArray: { value : [], writable: true },
55 this._materialNodeArray = []; 51 _materialNodeArray: { value : [], writable: true },
56 this._materialArray = []; 52 _materialArray: { value : [], writable: true },
57 this._materialTypeArray = []; 53 _materialTypeArray: { value : [], writable: true },
58 54
59 // the transform node used by RDGE 55 // the transform node used by RDGE
60 this._trNode = null; 56 _trNode: { value : null, writable: true },
61 57
62 /////////////////////////////////////////////////////////////////////// 58 ///////////////////////////////////////////////////////////////////////
63 // Property accessors 59 // Property accessors
64 /////////////////////////////////////////////////////////////////////// 60 ///////////////////////////////////////////////////////////////////////
65 this.setWorld = function (world) { 61 getWorld: {
66 this.m_world = world; 62 value: function() {
67 }; 63 return this.m_world;
64 }
65 },
68 66
69 this.getWorld = function () { 67 setWorld: {
70 return this.m_world; 68 value: function(world) {
71 }; 69 this.m_world = world;
70 }
71 },
72 72
73 this.getMatrix = function () { 73 getMatrix: {
74 return this._matrix.slice(0); 74 value: function() {
75 }; 75 return this._matrix.slice(0);
76 }
77 },
76 78
77 this.setMatrix = function (m) { 79 setMatrix: {
78 this._matrix = m.slice(0); 80 value: function(m) {
79 }; 81 this._matrix = m.slice(0);
82 }
83 },
80 84
81 this.setNext = function (next) { 85 getNext: {
82 this._next = next; 86 value: function() {
83 }; 87 return this._next;
88 }
89 },
84 90
85 this.getNext = function () { 91 setNext: {
86 return this._next; 92 value: function(next) {
87 }; 93 this._next = next;
94 }
95 },
88 96
89 this.setPrev = function (prev) { 97 getPrev: {
90 this._prev = prev; 98 value: function() {
91 }; 99 return this._prev;
100 }
101 },
92 102
93 this.getPrev = function () { 103 setPrev: {
94 return this._prev; 104 value: function(prev) {
95 }; 105 this._prev = prev;
106 }
107 },
96 108
97 this.setChild = function (child) { 109 getChild: {
98 this._child = child; 110 value: function() {
99 }; 111 return this._child;
112 }
113 },
100 114
101 this.getChild = function () { 115 setChild: {
102 return this._child; 116 value: function(child) {
103 }; 117 this._child = child;
118 }
119 },
104 120
105 this.setParent = function (parent) { 121 getParent: {
106 this._parent = parent; 122 value: function() {
107 }; 123 return this._parent;
124 }
125 },
108 126
109 this.getParent = function () { 127 setParent: {
110 return this._parent; 128 value: function(parent) {
111 }; 129 this._parent = parent;
130 }
131 },
112 132
113 this.geomType = function () { 133 geomType: {
114 return this.GEOM_TYPE_UNDEFINED; 134 value: function() {
115 }; 135 return this.GEOM_TYPE_UNDEFINED;
136 }
137 },
116 138
117 this.getPrimitiveArray = function () { 139 getPrimitiveArray: {
118 return this._primArray; 140 value: function() {
119 }; 141 return this._primArray;
142 }
143 },
120 144
121 this.getMaterialNodeArray = function () { 145 getMaterialNodeArray: {
122 return this._materialNodeArray; 146 value: function() {
123 }; 147 return this._materialNodeArray;
148 }
149 },
124 150
125 this.getMaterialArray = function () { 151 getMaterialArray: {
126 return this._materialArray; 152 value: function() {
127 }; 153 return this._materialArray;
154 }
155 },
128 156
129 this.getTransformNode = function () { 157 getTransformNode: {
130 return this._trNode; 158 value: function() {
131 }; 159 return this._trNode;
160 }
161 },
132 162
133 this.setTransformNode = function (t) { 163 setTransformNode: {
134 this._trNode = t; 164 value: function(t) {
135 }; 165 this._trNode = t;
166 }
167 },
136 168
137 this.setFillColor = function (c) { 169 setFillColor: {
138 this.setMaterialColor(c, "fill"); 170 value: function(c) {
139 }; 171 this.setMaterialColor(c, "fill");
172 }
173 },
140 174
141 this.setStrokeColor = function (c) { 175 setStrokeColor: {
142 this.setMaterialColor(c, "stroke"); 176 value: function(c) {