aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/hit-record.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/3D/hit-record.js')
-rwxr-xr-xjs/helper-classes/3D/hit-record.js322
1 files changed, 161 insertions, 161 deletions
diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js
index 46462c20..7e39bb50 100755
--- a/js/helper-classes/3D/hit-record.js
+++ b/js/helper-classes/3D/hit-record.js
@@ -41,90 +41,90 @@ var snapManagerModule = require("js/helper-classes/3D/snap-manager");
41var HitRecord = exports.HitRecord = Object.create(Object.prototype, 41var HitRecord = exports.HitRecord = Object.create(Object.prototype,
42{ 42{
43 43
44 /////////////////////////////////////////////////////////////////////// 44 ///////////////////////////////////////////////////////////////////////
45 // Constant definitions 45 // Constant definitions
46 /////////////////////////////////////////////////////////////////////// 46 ///////////////////////////////////////////////////////////////////////
47 SNAP_TYPE_STAGE : { value: 1, writable: true }, 47 SNAP_TYPE_STAGE : { value: 1, writable: true },
48 SNAP_TYPE_GRID_VERTEX : { value: 2, writable: true }, 48 SNAP_TYPE_GRID_VERTEX : { value: 2, writable: true },
49 SNAP_TYPE_GRID_HORIZONTAL : { value: 13, writable: true }, 49 SNAP_TYPE_GRID_HORIZONTAL : { value: 13, writable: true },
50 SNAP_TYPE_GRID_VERTICAL: { value: 14, writable: true }, 50 SNAP_TYPE_GRID_VERTICAL: { value: 14, writable: true },
51 SNAP_TYPE_ALIGN_MERGED: { value: 15, writable: true }, 51 SNAP_TYPE_ALIGN_MERGED: { value: 15, writable: true },
52 SNAP_TYPE_HORIZONTAL_FROM_START: { value: 3, writable: true }, 52 SNAP_TYPE_HORIZONTAL_FROM_START: { value: 3, writable: true },
53 SNAP_TYPE_VERTICAL_FROM_START: { value: 4, writable: true }, 53 SNAP_TYPE_VERTICAL_FROM_START: { value: 4, writable: true },
54 SNAP_TYPE_ELEMENT: { value: 5, writable: true }, 54 SNAP_TYPE_ELEMENT: { value: 5, writable: true },
55 SNAP_TYPE_ELEMENT_EDGE: { value: 6, writable: true }, 55 SNAP_TYPE_ELEMENT_EDGE: { value: 6, writable: true },
56 SNAP_TYPE_ELEMENT_VERTEX: { value: 7, writable: true }, 56 SNAP_TYPE_ELEMENT_VERTEX: { value: 7, writable: true },
57 SNAP_TYPE_ALIGN_HORIZONTAL: { value: 8, writable: true }, 57 SNAP_TYPE_ALIGN_HORIZONTAL: { value: 8, writable: true },
58 SNAP_TYPE_ALIGN_VERTICAL: { value: 9, writable: true }, 58 SNAP_TYPE_ALIGN_VERTICAL: { value: 9, writable: true },
59 SNAP_TYPE_ALIGN_BOTH: { value: 10, writable: true }, 59 SNAP_TYPE_ALIGN_BOTH: { value: 10, writable: true },
60 SNAP_TYPE_ELEMENT_CENTER: { value: 11, writable: true }, 60 SNAP_TYPE_ELEMENT_CENTER: { value: 11, writable: true },
61 SNAP_TYPE_CONTAINED_ELEMENT: { value: 12, writable: true }, 61 SNAP_TYPE_CONTAINED_ELEMENT: { value: 12, writable: true },
62 SNAP_TYPE_UNDEFINED: { value: null, writable: -1 }, 62 SNAP_TYPE_UNDEFINED: { value: null, writable: -1 },
63 63
64 /////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////
65 // Instance variables 65 // Instance variables
66 /////////////////////////////////////////////////////////////////////// 66 ///////////////////////////////////////////////////////////////////////
67 _type: { value: this.SNAP_TYPE_UNDEFINED, writable: true }, 67 _type: { value: this.SNAP_TYPE_UNDEFINED, writable: true },
68 _elt: { value: null, writable: true }, // this can be null. example: snapping to the working plane 68 _elt: { value: null, writable: true }, // this can be null. example: snapping to the working plane
69 _screenPt: { value: null, writable: true }, // snap point in global screen space 69 _screenPt: { value: null, writable: true }, // snap point in global screen space
70 _localPoint: { value: null, writable: true }, // snap point in the local space of the element 70 _localPoint: { value: null, writable: true }, // snap point in the local space of the element
71 _plane: { value: null, writable: true }, // plane equation at the snap point in local object space 71 _plane: { value: null, writable: true }, // plane equation at the snap point in local object space
72 _planeMat: { value: Matrix.I(4) , writable: true }, // transform to take the point from plane space to the transformed view space of the element 72 _planeMat: { value: Matrix.I(4) , writable: true }, // transform to take the point from plane space to the transformed view space of the element
73 _assocScrPt: { value: null, writable: true }, // associated screen point 73 _assocScrPt: { value: null, writable: true }, // associated screen point
74 _assocScrPt2: { value: null, writable: true }, // a second associated point for drawing multiple snap align hits 74 _assocScrPt2: { value: null, writable: true }, // a second associated point for drawing multiple snap align hits
75 _planarHit: { value: false, writable: true }, 75 _planarHit: { value: false, writable: true },
76 _snapBoundaryIndex : { value: -1, writable: true }, // this used for snap align to object boundaries 76 _snapBoundaryIndex : { value: -1, writable: true }, // this used for snap align to object boundaries
77 _isQuadPt :{ value: false, writable: true }, // used for snapping to an object's quadrant point 77 _isQuadPt :{ value: false, writable: true }, // used for snapping to an object's quadrant point
78 78
79 /////////////////////////////////////////////////////////////////////// 79 ///////////////////////////////////////////////////////////////////////
80 // Property accessors 80 // Property accessors
81 /////////////////////////////////////////////////////////////////////// 81 ///////////////////////////////////////////////////////////////////////
82 getElt : { value: function() { return this._elt; }}, 82 getElt : { value: function() { return this._elt; }},
83 setElt : { value: function(e) { this._elt = e; }}, 83 setElt : { value: function(e) { this._elt = e; }},
84 getElement : { value: function() { return this._elt; }}, 84 getElement : { value: function() { return this._elt; }},
85 setElement : { value: function(e) { this._elt = e; }}, 85 setElement : { value: function(e) { this._elt = e; }},
86 86
87 getZIndex : { value: function() { return this._zIndex; }}, 87 getZIndex : { value: function() { return this._zIndex; }},
88 setZIndex : { value: function(i) { this._zIndex = i; }}, 88 setZIndex : { value: function(i) { this._zIndex = i; }},
89 89
90 setScreenPoint : { value: function(s) { this._screenPt = s.slice(0); }}, 90 setScreenPoint : { value: function(s) { this._screenPt = s.slice(0); }},
91 getScreenPoint : { value: function() { return this._screenPt.slice(0); }}, 91 getScreenPoint : { value: function() { return this._screenPt.slice(0); }},
92 92
93 setLocalPoint : { value: function(s) { this._localPt = s.slice(0); }}, 93 setLocalPoint : { value: function(s) { this._localPt = s.slice(0); }},
94 getLocalPoint : { value: function() { return this._localPt.slice(0); }}, 94 getLocalPoint : { value: function() { return this._localPt.slice(0); }},
95 95
96 setAssociatedScreenPoint : { value: function(s) { this._assocScrPt = s.slice(0); }}, 96 setAssociatedScreenPoint : { value: function(s) { this._assocScrPt = s.slice(0); }},
97 getAssociatedScreenPoint : { value: function() { return this._assocScrPt.slice(0); }}, 97 getAssociatedScreenPoint : { value: function() { return this._assocScrPt.slice(0); }},
98 hasAssociatedScreenPoint : { value: function() { return this._assocScrPt != null; }}, 98 hasAssociatedScreenPoint : { value: function() { return this._assocScrPt != null; }},
99 99
100 setAssociatedScreenPoint2 : { value: function(s) { this._assocScrPt2 = s.slice(0); }}, 100 setAssociatedScreenPoint2 : { value: function(s) { this._assocScrPt2 = s.slice(0); }},
101 getAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2.slice(0); }}, 101 getAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2.slice(0); }},
102 hasAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2 != null; }}, 102 hasAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2 != null; }},
103 103
104 setPlane : { value: function(p) { this._plane = p.slice(0); }}, 104 setPlane : { value: function(p) { this._plane = p.slice(0); }},
105 getPlane : { value: function() { return this._plane.slice(0); }}, 105 getPlane : { value: function() { return this._plane.slice(0); }},
106 106
107 setPlaneMatrix : { value: function(pm) { this._planeMat = pm.slice(0); }}, 107 setPlaneMatrix : { value: function(pm) { this._planeMat = pm.slice(0); }},
108 getPlaneMatrix : { value: function() { return this._planeMat.slice(0); }}, 108 getPlaneMatrix : { value: function() { return this._planeMat.slice(0); }},
109 109
110 setPlanarHit : { value: function(p) { this._planarHit = p; }}, 110 setPlanarHit : { value: function(p) { this._planarHit = p; }},
111 isPlanarHit : { value: function() { return this._planarHit; }}, 111 isPlanarHit : { value: function() { return this._planarHit; }},
112 112
113 getSnapBoundaryIndex : { value: function() { return this._snapBoundaryIndex; }}, 113 getSnapBoundaryIndex : { value: function() { return this._snapBoundaryIndex; }},
114 setSnapBoundaryIndex : { value: function(i) { this._snapBoundaryIndex = i; }}, 114 setSnapBoundaryIndex : { value: function(i) { this._snapBoundaryIndex = i; }},
115 115
116 getType : { value: function() { return this._type; }}, 116 getType : { value: function() { return this._type; }},
117 setType : { value: function(t) {this._type = t; if (!this.checkType()) { throw new Error("invalid snap type"); return; } }}, 117 setType : { value: function(t) {this._type = t; if (!this.checkType()) { throw new Error("invalid snap type"); return; } }},
118 118
119 getUseQuadPoint : { value: function() { return this._isQuadPt; }}, 119 getUseQuadPoint : { value: function() { return this._isQuadPt; }},
120 setUseQuadPoint : { value: function(q) {this._isQuadPt = q; }}, 120 setUseQuadPoint : { value: function(q) {this._isQuadPt = q; }},
121 121
122 /////////////////////////////////////////////////////////////////////// 122 ///////////////////////////////////////////////////////////////////////
123 // Methods 123 // Methods
124 /////////////////////////////////////////////////////////////////////// 124 ///////////////////////////////////////////////////////////////////////
125 125
126 checkType :{ 126 checkType :{
127 value: function() { 127 value: function() {
128 var ok = false; 128 var ok = false;
129 switch (this._type) 129 switch (this._type)
130 { 130 {
@@ -161,7 +161,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
161 } 161 }
162 }, 162 },
163 163
164 isSomeGridTypeSnap : { 164 isSomeGridTypeSnap : {
165 value: function() { 165 value: function() {
166 return ((this._type == this.SNAP_TYPE_GRID_VERTEX) || 166 return ((this._type == this.SNAP_TYPE_GRID_VERTEX) ||
167 (this._type == this.SNAP_TYPE_GRID_HORIZONTAL) || 167 (this._type == this.SNAP_TYPE_GRID_HORIZONTAL) ||
@@ -170,7 +170,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
170 } 170 }
171 }, 171 },
172 172
173 convertToWorkingPlane : { 173 convertToWorkingPlane : {
174 value: function( wp ) { 174 value: function( wp ) {
175 var swp = this.calculateStageWorldPoint(); 175 var swp = this.calculateStageWorldPoint();
176 var wpMat = drawUtils.getPlaneToWorldMatrix(wp, MathUtils.getPointOnPlane(wp)); 176 var wpMat = drawUtils.getPlaneToWorldMatrix(wp, MathUtils.getPointOnPlane(wp));
@@ -191,7 +191,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
191 } 191 }
192 }, 192 },
193 193
194 calculateStageWorldPoint : { 194 calculateStageWorldPoint : {
195 value: function() { 195 value: function() {
196 var wPt; 196 var wPt;
197 var elt = this.getElt(); 197 var elt = this.getElt();
@@ -207,7 +207,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
207 }, 207 },
208 208
209 209
210 calculateScreenPoint : { 210 calculateScreenPoint : {
211 value: function() { 211 value: function() {
212 var scrPt; 212 var scrPt;
213 213
@@ -231,7 +231,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
231 } 231 }
232 }, 232 },
233 233
234 calculateElementWorldPoint : { 234 calculateElementWorldPoint : {
235 value: function() { 235 value: function() {
236 var localPt = this.getLocalPoint(); 236 var localPt = this.getLocalPoint();
237 var worldPt = MathUtils.transformPoint( localPt, this.getPlaneMatrix() ); 237 var worldPt = MathUtils.transformPoint( localPt, this.getPlaneMatrix() );
@@ -240,7 +240,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
240 } 240 }
241