diff options
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-x | js/helper-classes/3D/ParseUtils.js | 84 | ||||
-rwxr-xr-x | js/helper-classes/3D/Rectangle.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/3D/StageLine.js | 8 | ||||
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/3D/element-planes.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/3D/glUtils.js | 319 | ||||
-rwxr-xr-x | js/helper-classes/3D/math-utils.js | 54 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-2d-record.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 46 | ||||
-rwxr-xr-x | js/helper-classes/3D/vec-utils.js | 16 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 12 |
11 files changed, 57 insertions, 490 deletions
diff --git a/js/helper-classes/3D/ParseUtils.js b/js/helper-classes/3D/ParseUtils.js deleted file mode 100755 index 556253e9..00000000 --- a/js/helper-classes/3D/ParseUtils.js +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | /////////////////////////////////////////////////////////////////////// | ||
8 | // Class Utils | ||
9 | // Vector Utility functions | ||
10 | /////////////////////////////////////////////////////////////////////// | ||
11 | function ParseUtils( theStr ) | ||
12 | { | ||
13 | /////////////////////////////////////////////////////////////////////// | ||
14 | // Instance variables | ||
15 | /////////////////////////////////////////////////////////////////////// | ||
16 | this._strBuffer = theStr; | ||
17 | |||
18 | /////////////////////////////////////////////////////////////////////// | ||
19 | // Property accessors | ||
20 | /////////////////////////////////////////////////////////////////////// | ||
21 | this.getBuffer = function() { return this._strBuffer; } | ||
22 | this.setBuffer = function(b) { this._strBuffer = b; } | ||
23 | |||
24 | /////////////////////////////////////////////////////////////////////// | ||
25 | // Methods | ||
26 | /////////////////////////////////////////////////////////////////////// | ||
27 | this.nextValue = function( prop, endKeyArg, advanceBufferArg ) | ||
28 | { | ||
29 | if (!this._strBuffer) return; | ||
30 | |||
31 | // make the 2 & 3rd argument optional. default is to advance the string | ||
32 | var endKey = "\n", advanceBuffer = true; | ||
33 | if (endKeyArg) | ||
34 | endKey = endKeyArg; | ||
35 | if (advanceBufferArg) | ||
36 | advanceBuffer = advanceBufferArg; | ||
37 | |||
38 | var iStart = this._strBuffer.indexOf( prop ); | ||
39 | if (iStart < 0) return; | ||
40 | |||
41 | var iEnd = this._strBuffer.indexOf( endKey, iStart ); | ||
42 | if (iEnd < 0) throw new Error( "property " + prop + " improperly terminated: " + this._strBuffer); | ||
43 | |||
44 | iStart += prop.length; | ||
45 | var nChars = iEnd - iStart; | ||
46 | var rtnStr = this._strBuffer.substr( iStart, nChars ); | ||
47 | |||
48 | if (advanceBuffer) | ||
49 | this._strBuffer = this._strBuffer.substr( iEnd + endKey.length ); | ||
50 | |||
51 | return rtnStr; | ||
52 | } | ||
53 | |||
54 | this.nextToken = function() | ||
55 | { | ||
56 | if (!this._strBuffer) return; | ||
57 | |||
58 | // find the limits | ||
59 | var index = this._strBuffer.search( /\S/ ); // first non-whitespace character | ||
60 | if (index > 0) this._strBuffer = this._strBuffer.slice(index); | ||
61 | index = this._strBuffer.search( /\s/ ); // first whitespace character marking the end of the token | ||
62 | |||
63 | var token; | ||
64 | if (index > 0) | ||
65 | { | ||
66 | token = this._strBuffer.slice(0, index); | ||
67 | this._strBuffer = this._strBuffer.slice( index ); | ||
68 | } | ||
69 | |||
70 | return token; | ||
71 | } | ||
72 | |||
73 | this.advancePastToken = function( token ) | ||
74 | { | ||
75 | var index = this._strBuffer.indexOf( token ); | ||
76 | if (index < 0) | ||
77 | console.log( "could not find token: " + token + " in string: " + this._strBuffer ); | ||
78 | else | ||
79 | this._strBuffer = this._strBuffer.substr( index + token.length ); | ||
80 | } | ||
81 | |||
82 | } | ||
83 | |||
84 | |||
diff --git a/js/helper-classes/3D/Rectangle.js b/js/helper-classes/3D/Rectangle.js index e797eedf..b8906f18 100755 --- a/js/helper-classes/3D/Rectangle.js +++ b/js/helper-classes/3D/Rectangle.js | |||
@@ -35,7 +35,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, { | |||
35 | getTop: { value: function() { return this.m_top; } }, | 35 | getTop: { value: function() { return this.m_top; } }, |
36 | setTop: { value: function(t) { this.m_top = t; } }, | 36 | setTop: { value: function(t) { this.m_top = t; } }, |
37 | 37 | ||
38 | getCenter: { value: function() { return Vector.create( [this.m_left + 0.5*this.m_width, this.m_top + 0.5*this.m_height] ); } }, | 38 | getCenter: { value: function() { return [this.m_left + 0.5*this.m_width, this.m_top + 0.5*this.m_height]; } }, |
39 | 39 | ||
40 | getWidth: { value: function() { return this.m_width; } }, | 40 | getWidth: { value: function() { return this.m_width; } }, |
41 | setWidth: { value: function(w) { this.m_width = w; } }, | 41 | setWidth: { value: function(w) { this.m_width = w; } }, |
diff --git a/js/helper-classes/3D/StageLine.js b/js/helper-classes/3D/StageLine.js index e0e7a8e3..b86673d1 100755 --- a/js/helper-classes/3D/StageLine.js +++ b/js/helper-classes/3D/StageLine.js | |||
@@ -149,8 +149,8 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { | |||
149 | var vec = vecUtils.vecSubtract(3, bPt1, bPt0); | 149 | var vec = vecUtils.vecSubtract(3, bPt1, bPt0); |
150 | if (plane.isBackFacing()) | 150 | if (plane.isBackFacing()) |
151 | MathUtils.negate( vec ); | 151 | MathUtils.negate( vec ); |
152 | planeEq = Vector.create( [-vec[1], vec[0], 0] ); | 152 | planeEq = [-vec[1], vec[0], 0]; |
153 | var normal = Vector.create( [planeEq[0], planeEq[1], planeEq[2]] ); | 153 | var normal = [planeEq[0], planeEq[1], planeEq[2]]; |
154 | // var d = -planeEq.dot(bPt0); | 154 | // var d = -planeEq.dot(bPt0); |
155 | var d = -vecUtils.vecDot(3, planeEq, bPt0); | 155 | var d = -vecUtils.vecDot(3, planeEq, bPt0); |
156 | planeEq[3] = d; | 156 | planeEq[3] = d; |
@@ -414,8 +414,8 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { | |||
414 | if (pt0[1] < pt1[1]) { yMin = pt0[1]; yMax = pt1[1]; } else { yMin = pt1[1]; yMax = pt0[1]; } | 414 | if (pt0[1] < pt1[1]) { yMin = pt0[1]; yMax = pt1[1]; } else { yMin = pt1[1]; yMax = pt0[1]; } |
415 | if (pt0[2] < pt1[2]) { zMin = pt0[2]; zMax = pt1[2]; } else { zMin = pt1[2]; zMax = pt0[2]; } | 415 | if (pt0[2] < pt1[2]) { zMin = pt0[2]; zMax = pt1[2]; } else { zMin = pt1[2]; zMax = pt0[2]; } |
416 | 416 | ||
417 | this._minPt = Vector.create( [xMin, yMin, zMin] ); | 417 | this._minPt = [xMin, yMin, zMin]; |
418 | this._maxPt = Vector.create( [xMax, yMax, zMax] ); | 418 | this._maxPt = [xMax, yMax, zMax]; |
419 | } | 419 | } |
420 | }//, | 420 | }//, |
421 | 421 | ||
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 85870097..02d946ae 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -123,7 +123,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
123 | this._planesArray = []; | 123 | this._planesArray = []; |
124 | this.setDrawingSurfaceElement(this.application.ninja.stage.canvas); | 124 | this.setDrawingSurfaceElement(this.application.ninja.stage.canvas); |
125 | this.setSourceSpaceElement( this.application.ninja.stage.stageDeps.currentStage ); | 125 | this.setSourceSpaceElement( this.application.ninja.stage.stageDeps.currentStage ); |
126 | this.setWorkingPlane( Vector.create( [0,0,1,0] ) ); | 126 | this.setWorkingPlane( [0,0,1,0] ); |
127 | 127 | ||
128 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them | 128 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them |
129 | if(this.application.ninja.currentDocument._liveNodeList.length > 0){ | 129 | if(this.application.ninja.currentDocument._liveNodeList.length > 0){ |
diff --git a/js/helper-classes/3D/element-planes.js b/js/helper-classes/3D/element-planes.js index 7ccf311e..38a7bf47 100755 --- a/js/helper-classes/3D/element-planes.js +++ b/js/helper-classes/3D/element-planes.js | |||
@@ -88,7 +88,7 @@ var ElementPlanes = exports.ElementPlanes = Object.create(Object.prototype, { | |||
88 | // create the plane equation | 88 | // create the plane equation |
89 | //var d = -( nrm.dot( this._boundaryPts[0]) ); | 89 | //var d = -( nrm.dot( this._boundaryPts[0]) ); |
90 | var d = -vecUtils.vecDot(3, nrm, this._boundaryPts[0]); | 90 | var d = -vecUtils.vecDot(3, nrm, this._boundaryPts[0]); |
91 | var planeEq = Vector.create( [nrm[0], nrm[1], nrm[2], d] ); | 91 | var planeEq = [nrm[0], nrm[1], nrm[2], d] ; |
92 | this.setPlaneEq( planeEq ); | 92 | this.setPlaneEq( planeEq ); |
93 | 93 | ||
94 | // get the 2D rectangle | 94 | // get the 2D rectangle |
diff --git a/js/helper-classes/3D/glUtils.js b/js/helper-classes/3D/glUtils.js deleted file mode 100755 index f6d075f8..00000000 --- a/js/helper-classes/3D/glUtils.js +++ /dev/null | |||
@@ -1,319 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | // Constructor function | ||
8 | function Vector() {} | ||
9 | Vector.create = function(elements) | ||
10 | { | ||
11 | var rtn; | ||
12 | if (elements) | ||
13 | rtn = elements.slice( 0 ); | ||
14 | else | ||
15 | rtn = []; | ||
16 | |||
17 | return rtn; | ||
18 | }; | ||
19 | |||
20 | Vector.dup = function(srcPt) | ||
21 | { | ||
22 | return srcPt.slice(0); | ||
23 | } | ||
24 | |||
25 | |||
26 | |||
27 | function Matrix() {} | ||
28 | |||
29 | Matrix.create = function( rowArray ) | ||
30 | { | ||
31 | var mat = Matrix.I(4); | ||
32 | var index = 0; | ||
33 | for(var j=0; j<4; j++) | ||
34 | { | ||
35 | for (var i=0; i<4; i++) | ||
36 | { | ||
37 | mat[index] = rowArray[i][j]; | ||
38 | index++; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | return mat; | ||
43 | } | ||
44 | Matrix.I = function(dimen) | ||
45 | { | ||
46 | var mat = []; | ||
47 | for (var i=0; i<dimen*dimen; i++) mat.push(0); | ||
48 | |||
49 | var index = 0; | ||
50 | for (var i=0; i<dimen; i++) | ||
51 | { | ||
52 | mat[index] = 1.0; | ||
53 | index += dimen + 1; | ||
54 | } | ||
55 | |||
56 | return mat; | ||
57 | } | ||
58 | |||
59 | Matrix.Translation = function (vec) | ||
60 | { | ||
61 |