diff options
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-x | js/helper-classes/3D/LinePlaneIntersectRec.js | 16 | ||||
-rwxr-xr-x | js/helper-classes/3D/Rectangle.js | 10 | ||||
-rwxr-xr-x | js/helper-classes/3D/StageLine.js | 370 | ||||
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 2082 | ||||
-rwxr-xr-x | js/helper-classes/3D/hit-record.js | 322 | ||||
-rwxr-xr-x | js/helper-classes/3D/math-utils.js | 256 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-2d-record.js | 84 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 4046 | ||||
-rwxr-xr-x | js/helper-classes/3D/vec-utils.js | 146 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 328 |
10 files changed, 3830 insertions, 3830 deletions
diff --git a/js/helper-classes/3D/LinePlaneIntersectRec.js b/js/helper-classes/3D/LinePlaneIntersectRec.js index 71ee81f4..ec2d6d57 100755 --- a/js/helper-classes/3D/LinePlaneIntersectRec.js +++ b/js/helper-classes/3D/LinePlaneIntersectRec.js | |||
@@ -60,17 +60,17 @@ var LinePlaneIntersectRec = exports.LinePlaneIntersectRec = Object.create(Object | |||
60 | getElementPlanes: { value: function() { return this._elementPlanes; } }, | 60 | getElementPlanes: { value: function() { return this._elementPlanes; } }, |
61 | setElementPlanes: { value: function(p) { this._elementPlanes = p; } }, | 61 | setElementPlanes: { value: function(p) { this._elementPlanes = p; } }, |
62 | 62 | ||
63 | getT: { value: function() { return this._t; } }, | 63 | getT: { value: function() { return this._t; } }, |
64 | setT: { value: function(t) { this._t = t; } }, | 64 | setT: { value: function(t) { this._t = t; } }, |
65 | 65 | ||
66 | setDeltaVis: { value: function(d) { this._deltaVis = d; } }, | 66 | setDeltaVis: { value: function(d) { this._deltaVis = d; } }, |
67 | getDeltaVis: { value: function() { return this._deltaVis; } }, | 67 | getDeltaVis: { value: function() { return this._deltaVis; } }, |
68 | 68 | ||
69 | setNext: { value: function(n) { this._next = n; } }, | 69 | setNext: { value: function(n) { this._next = n; } }, |
70 | getNext: { value: function() { return this._next; } }, | 70 | getNext: { value: function() { return this._next; } }, |
71 | 71 | ||
72 | getPrev: { value: function() { return this._prev; } }, | 72 | getPrev: { value: function() { return this._prev; } }, |
73 | setPrev: { value: function(p) { this._prev = p; } } | 73 | setPrev: { value: function(p) { this._prev = p; } } |
74 | 74 | ||
75 | /////////////////////////////////////////////////////////////////////// | 75 | /////////////////////////////////////////////////////////////////////// |
76 | // Methods | 76 | // Methods |
diff --git a/js/helper-classes/3D/Rectangle.js b/js/helper-classes/3D/Rectangle.js index 1922bd91..15f812ab 100755 --- a/js/helper-classes/3D/Rectangle.js +++ b/js/helper-classes/3D/Rectangle.js | |||
@@ -67,7 +67,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, { | |||
67 | getHeight: { value: function() { return this.m_height; } }, | 67 | getHeight: { value: function() { return this.m_height; } }, |
68 | setHeight: { value: function(h) { this.m_height = h; } }, | 68 | setHeight: { value: function(h) { this.m_height = h; } }, |
69 | 69 | ||
70 | geomType: { value: function() { return this.GEOM_TYPE_RECTANGLE; } }, | 70 | geomType: { value: function() { return this.GEOM_TYPE_RECTANGLE; } }, |
71 | 71 | ||
72 | /////////////////////////////////////////////////////////////////////// | 72 | /////////////////////////////////////////////////////////////////////// |
73 | // Methods | 73 | // Methods |
@@ -84,7 +84,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, { | |||
84 | } | 84 | } |
85 | }, | 85 | }, |
86 | 86 | ||
87 | dup: { | 87 | dup: { |
88 | value: function() | 88 | value: function() |
89 | { | 89 | { |
90 | var rtnRec = Object.create(Rectangle, {}); | 90 | var rtnRec = Object.create(Rectangle, {}); |
@@ -122,7 +122,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, { | |||
122 | } | 122 | } |
123 | }, | 123 | }, |
124 | 124 | ||
125 | setToBounds: { | 125 | setToBounds: { |
126 | value: function( bounds ) | 126 | value: function( bounds ) |
127 | { | 127 | { |
128 | var pt = bounds[0]; | 128 | var pt = bounds[0]; |
@@ -166,7 +166,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, { | |||
166 | } | 166 | } |
167 | }, | 167 | }, |
168 | 168 | ||
169 | getQuadrant: { | 169 | getQuadrant: { |
170 | value: function( iQuad ) | 170 | value: function( iQuad ) |
171 | { | 171 | { |
172 | // quadrant ordering starts at upper left and continues around counter-clockwise | 172 | // quadrant ordering starts at upper left and continues around counter-clockwise |
@@ -220,7 +220,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, { | |||
220 | this.setTop( yMin ); this.setHeight( yMax - yMin ); | 220 | this.setTop( yMin ); this.setHeight( yMax - yMin ); |
221 | } | 221 | } |
222 | }, | 222 | }, |
223 | 223 | ||
224 | 224 | ||
225 | translate: { | 225 | translate: { |
226 | value: function( dx, dy ) | 226 | value: function( dx, dy ) |
diff --git a/js/helper-classes/3D/StageLine.js b/js/helper-classes/3D/StageLine.js index aaa9f95d..b869fb17 100755 --- a/js/helper-classes/3D/StageLine.js +++ b/js/helper-classes/3D/StageLine.js | |||
@@ -120,7 +120,7 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { | |||
120 | // add the intersection | 120 | // add the intersection |
121 | var dot = MathUtils.dot3( pt0, planeEq ) + planeEq[3]; | 121 | var dot = MathUtils.dot3( pt0, planeEq ) + planeEq[3]; |
122 | var deltaVis = (dot > 0) ? 1 : -1; | 122 | var deltaVis = (dot > 0) ? 1 : -1; |
123 | // if (plane.isBackFacing()) | 123 | // if (plane.isBackFacing()) |
124 | // deltaVis = (dot < 0) ? 1 : -1; | 124 | // deltaVis = (dot < 0) ? 1 : -1; |
125 | 125 | ||
126 | this.addIntersection( plane, t, deltaVis ); | 126 | this.addIntersection( plane, t, deltaVis ); |
@@ -175,14 +175,14 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { | |||
175 | MathUtils.negate( vec ); | 175 | MathUtils.negate( vec ); |
176 | planeEq = [-vec[1], vec[0], 0]; | 176 | planeEq = [-vec[1], vec[0], 0]; |
177 | var normal = [planeEq[0], planeEq[1], planeEq[2]]; | 177 | var normal = [planeEq[0], planeEq[1], planeEq[2]]; |
178 | // var d = -planeEq.dot(bPt0); | 178 | // var d = -planeEq.dot(bPt0); |
179 | var d = -vecUtils.vecDot(3, planeEq, bPt0); | 179 | var d = -vecUtils.vecDot(3, planeEq, bPt0); |
180 | planeEq[3] = d; | 180 | planeEq[3] = d; |
181 | 181 | ||
182 | t = MathUtils.vecIntersectPlaneForParam( pt0, lineDir, planeEq ); | 182 | t = MathUtils.vecIntersectPlaneForParam( pt0, lineDir, planeEq ); |
183 | if (t) | 183 | if (t) |
184 | { | 184 | { |
185 | if ((MathUtils.fpSign(t) > 0) && (MathUtils.fpCmp(t,1.0) <= 0)) // the strict vs not-strict inequality comparisons are IMPORTANT! | 185 | if ((MathUtils.fpSign(t) > 0) && (MathUtils.fpCmp(t,1.0) <= 0)) // the strict vs not-strict inequality comparisons are IMPORTANT! |
186 | { | 186 | { |
187 | // get the intersection point | 187 | // get the intersection point |
188 | var pt = MathUtils.interpolateLine3D( pt0, pt1, t ); | 188 | var pt = MathUtils.interpolateLine3D( pt0, pt1, t ); |
@@ -207,47 +207,47 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { | |||
207 | } | 207 | } |
208 | }, | 208 | }, |
209 | 209 | ||
210 | doCoplanarIntersection: { | 210 | doCoplanarIntersection: { |
211 | value: function( plane ) | 211 | value: function( plane ) |
212 | { | 212 | { |
213 | // get the boundary points for the plane | 213 | // get the boundary points for the plane |
214 | var boundaryPts = plane.getBoundaryPoints(); | 214 | var boundaryPts = plane.getBoundaryPoints(); |
215 | var planeEq = plane.getPlaneEq(); | 215 | var planeEq = plane.getPlaneEq(); |
216 | 216 | ||
217 | if (plane.isBackFacing()) | 217 | if (plane.isBackFacing()) |
218 | { | 218 | { |
219 | var tmp; | 219 | var tmp; |
220 | tmp = boundaryPts[0]; boundaryPts[0] = boundaryPts[3]; boundaryPts[3] = tmp; | 220 | tmp = boundaryPts[0]; boundaryPts[0] = boundaryPts[3]; boundaryPts[3] = tmp; |
221 | tmp = boundaryPts[1]; boundaryPts[1] = boundaryPts[2]; boundaryPts[2] = tmp; | 221 | tmp = boundaryPts[1]; boundaryPts[1] = boundaryPts[2]; boundaryPts[2] = tmp; |
222 | } | 222 | } |
223 | 223 | ||
224 | var pt0 = this.getPoint0(), | 224 | var pt0 = this.getPoint0(), |
225 | pt1 = this.getPoint1(); | 225 | pt1 = this.getPoint1(); |
226 | 226 | ||
227 | // keep a couple flags to prevent counting crossings twice in edge cases | 227 | // keep a couple flags to prevent counting crossings twice in edge cases |
228 | var gotEnter = false, | 228 | var gotEnter = false, |
229 | gotExit = false; | 229 | gotExit = false; |
230 | 230 | ||
231 | var bp1 = boundaryPts[3]; | 231 | var bp1 = boundaryPts[3]; |
232 | for (var i=0; i<4; i++) | 232 | for (var i=0; i<4; i++) |
233 | { | 233 | { |
234 | var bp0 = bp1; | 234 | var bp0 = bp1; |
235 | bp1 = boundaryPts[i]; | 235 | bp1 = boundaryPts[i]; |
236 | var vec = vecUtils.vecSubtract(3, bp1, bp0); | 236 | var vec = vecUtils.vecSubtract(3, bp1, bp0); |
237 | var nrm = vecUtils.vecCross(3, vec, planeEq); | 237 | var nrm = vecUtils.vecCross(3, vec, planeEq); |
238 | nrm[3] = -vecUtils.vecDot(3, bp0, nrm); | 238 | nrm[3] = -vecUtils.vecDot(3, bp0, nrm); |
239 | 239 | ||
240 | var d0 = vecUtils.vecDot(3, nrm, pt0) + nrm[3], | 240 | var d0 = vecUtils.vecDot(3, nrm, pt0) + nrm[3], |
241 | d1 = vecUtils.vecDot(3, nrm, pt1) + nrm[3]; | 241 | d1 = vecUtils.vecDot(3, nrm, pt1) + nrm[3]; |
242 | 242 | ||
243 | var s0 = MathUtils.fpSign(d0), | 243 | var s0 = MathUtils.fpSign(d0), |
244 | s1 = MathUtils.fpSign(d1); | 244 | s1 = MathUtils.fpSign(d1); |
245 | 245 | ||
246 | if (s0 != s1) | 246 | if (s0 != s1) |
247 | { | 247 | { |
248 | var t = Math.abs(d0)/( Math.abs(d0) + Math.abs(d1) ); | 248 | var t = Math.abs(d0)/( Math.abs(d0) + Math.abs(d1) ); |
249 | if (MathUtils.fpSign(t) === 0) | 249 | if (MathUtils.fpSign(t) === 0) |
250 | { | 250 | { |
251 | // the first point of the line is on the (infinite) extension of a side of the boundary. | 251 | // the first point of the line is on the (infinite) extension of a side of the boundary. |
252 | // Make sure the point (pt0) is within the range of the polygon edge | 252 | // Make sure the point (pt0) is within the range of the polygon edge |
253 | var vt0 = vecUtils.vecSubtract(3, pt0, bp0), | 253 | var vt0 = vecUtils.vecSubtract(3, pt0, bp0), |
@@ -257,144 +257,144 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { | |||
257 | var st0 = MathUtils.fpSign(dt0), st1 = MathUtils.fpSign(dt1); | 257 | var st0 = MathUtils.fpSign(dt0), st1 = MathUtils.fpSign(dt1); |
258 | if ((st0 >= 0) && (st1 >= 0)) | 258 | if ((st0 >= 0) && (st1 >= 0)) |
259 | { | 259 | { |
260 | if (s1 > 0) // entering the material from the beginning of the line that is to be drawn |