aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
authorJonathan Duran2012-03-06 11:38:39 -0800
committerJonathan Duran2012-03-06 11:38:39 -0800
commit342fb451bd251358068a0dcb10e9dc218b79a176 (patch)
treeaa0195d581c3934fb6dc09981506b3c070002806 /js/lib/geom
parent2815adfd7c19b3dff89dc3e1bda9af8d30dca8d6 (diff)
downloadninja-342fb451bd251358068a0dcb10e9dc218b79a176.tar.gz
Squashed commit of the following:
commit 1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Tue Mar 6 11:24:25 2012 -0800 Fixing WebGL not available bug commit 84332ab81c1b445195f1d9be8bbeae0725c8e758 Author: Valerio Virgillito <valerio@motorola.com> Date: Tue Mar 6 10:58:25 2012 -0800 Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito <valerio@motorola.com> commit 13f52cf0c74f53a919fa864f86669e8155f82961 Merge: dced508 abc04f3 Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:46:11 2012 -0800 Merge pull request #93 from imix23ways/Timeline Timeline: Critical bug fixes commit dced508bb19a7bcd467ff1b86b5df5bbec4be794 Merge: 0aeb400 cc772ef Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:45:35 2012 -0800 Merge pull request #92 from mqg734/WebGLFixes Selection Tool Fixes for elements flying off into space when they overlap commit 0aeb400070762cf01d83cf9f9ee25a5595098b7f Merge: ff0a956 aabb48a Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 14:05:21 2012 -0800 Merge pull request #94 from ericguzman/PresetsPanel Presets Panel - Fix single-click activation, and transition cut-off bug. commit cc772ef3333ed419d269a2bda7aea5b0150a7bd9 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:34:58 2012 -0800 Fixing flying off into space bug for translate tool too. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit abc04f3d50311ed1c21067344bc7e448686f8c5c Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:26:25 2012 -0800 Timeline Fix timing function Signed-off-by: Jonathan Duran <jduran@motorola.com> commit aabb48a1c8d34bc968f4c6b0ffee4e31c1d5d286 Author: Eric Guzman <ericg@motorola.com> Date: Fri Mar 2 11:22:44 2012 -0800 Presets Panel - Fix single-click activation, and transition cut-off bug. Use double-click as the activation event for transition presets. Also fixed the bug when applying a style preset before the transition preset, which disabled transitions after the first one. commit f3207f39ea9d8c1c34246217a23d3a689671903d Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:21:29 2012 -0800 Don't draw transform handles if the stage is the target element. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 5425be91e7125c22955b4459a62412ff574e49a8 Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:11:48 2012 -0800 Timeline: Fix for animation iteration count Add default webkit css properties to allow animations with integer iteration counts. Signed-off-by: Jonathan Duran <jduran@motorola.com> commit 1760bac1da9218315ad1bacdcf3a157495a049e8 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 10:48:41 2012 -0800 Fix for jumping issue when moving items that have any 3d on them. We can't translate 3d moves into 2d space due to perspective, so we must update the matrix3d values instead of the top-left values if items have 3d. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 2c04935f0ccb1cb7c98371fc10b43155f2d956c4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 22:20:06 2012 -0800 Fix for elements flying off into space when moving elements that overlap. This was happening because our hit record's element and the browser's element from point did not match. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 50058746779f714ed9b0287f49e56c9f0d35593e Merge: 500426d ff0a956 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 21:49:44 2012 -0800 Merge branch 'refs/heads/ninja-internal' into WebGLFixes commit 500426dea0ca95a6b45be8ea8d132cfdb4d2c940 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:11:39 2012 -0800 Fixed logic error when resizing with the top-left transform handles. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 7980d9bde2b43aa5a494ddf6f1db5c4959a57b91 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:04:15 2012 -0800 Re-fixing IKNinja-940 - Can't select objects when in side/top view. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit f04cc0146d8f7573628678613a99c270116768e4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Feb 29 16:45:40 2012 -0800 Last-used material (instead of FlatMaterial) is applied to shape when turning on use WebGL checkbox in the PI. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/anchor-point.js242
-rwxr-xr-xjs/lib/geom/brush-stroke.js482
-rwxr-xr-xjs/lib/geom/circle.js751
-rwxr-xr-xjs/lib/geom/geom-obj.js280
-rwxr-xr-xjs/lib/geom/line.js488
-rwxr-xr-xjs/lib/geom/rectangle.js1165
-rw-r--r--js/lib/geom/shape-primitive.js54
-rwxr-xr-xjs/lib/geom/sub-path.js1288
8 files changed, 4750 insertions, 0 deletions
diff --git a/js/lib/geom/anchor-point.js b/js/lib/geom/anchor-point.js
new file mode 100755
index 00000000..0e9f65ea
--- /dev/null
+++ b/js/lib/geom/anchor-point.js
@@ -0,0 +1,242 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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 GLAnchorPoint
9// GL representation of a point clicked
10// and dragged during pen tool
11//
12//
13/////////////////////////////////////////////
14var GLAnchorPoint = function GLAnchorPoint() {
15 /////////////////////////////////////////
16 // Instance variables
17 /////////////////////////////////////////
18 this._x = 0.0;
19 this._y = 0.0;
20 this._z = 0.0;
21
22 this._prevX = 0.0;
23 this._prevY = 0.0;
24 this._prevZ = 0.0;
25
26 this._nextX = 0.0;
27 this._nextY = 0.0;
28 this._nextZ = 0.0;
29};
30 // *********** setters ************
31GLAnchorPoint.prototype.setPos = function (x, y, z) {
32 this._x = x;
33 this._y = y;
34 this._z = z;
35};
36
37GLAnchorPoint.prototype.setPrevPos = function (x, y, z) {
38 this._prevX = x;
39 this._prevY = y;
40 this._prevZ = z;
41};
42
43GLAnchorPoint.prototype.setNextPos = function (x, y, z) {
44 this._nextX = x;
45 this._nextY = y;
46 this._nextZ = z;
47};
48
49GLAnchorPoint.prototype.setPrevFromNext = function () {
50 //set the previous control point by reflecting the next control point
51 var dispX = this._nextX - this._x;
52 var dispY = this._nextY - this._y;
53 var dispZ = this._nextZ - this._z;
54
55 this._prevX = this._x - dispX;
56 this._prevY = this._y - dispY;
57 this._prevZ = this._z - dispZ;
58};
59
60GLAnchorPoint.prototype.setNextFromPrev = function () {
61 //set the previous control point by reflecting the next control point
62 var dispX = this._prevX - this._x;
63 var dispY = this._prevY - this._y;
64 var dispZ = this._prevZ - this._z;
65
66 this._nextX = this._x - dispX;
67 this._nextY = this._y - dispY;
68 this._nextZ = this._z - dispZ;
69};
70
71//translate the next point from the translation that was applied to the prev. point
72GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) {
73 //do nothing if the total translation is zero
74 var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz);
75 if (totalTransSq < 0.0000001) {
76 return;
77 }
78
79 // *** compute the rotation of the prev vector ***
80 var oldP = [this._prevX + tx - this._x, this._prevY + ty - this._y, this._prevZ + tz - this._z];
81 var newP = [this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z];
82 //compute angle between the two vectors
83 var axis = [0, 0, 0];
84 var angle = MathUtils.getAxisAngleBetween3DVectors(oldP, newP, axis);
85 if (angle === 0) {
86 return;
87 }
88
89 // *** compute the vector from anchor to next
90 var oldN = [this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z];
91 var rotMat = Matrix.Rotation(-angle, axis);
92 var newN = MathUtils.transformVector(oldN, rotMat);
93
94 //TEMP for some situations the axis angle computation returns NaNs
95 if (isNaN(newN[0]) || isNaN(newN[1]) || isNaN(newN[2])) {
96 console.log("NaN in translateNextFromPrev");
97 return;
98 }
99 //end TEMP
100 this._nextX = this._x + newN[0];
101 this._nextY = this._y + newN[1];
102 this._nextZ = this._z + newN[2];
103};
104
105//translate the next point from the translation that was applied to the prev. point
106GLAnchorPoint.prototype.translatePrevFromNext = function (tx, ty, tz) {
107 //do nothing if the total translation is zero
108 var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz);
109 if (totalTransSq < 0.0000001) {
110 return;
111 }
112
113 // *** compute the rotation of the next vector ***
114 var oldN = [this._nextX + tx - this._x, this._nextY + ty - this._y, this._nextZ + tz - this._z];
115 var newN = [this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z];
116 //compute angle between the two vectors
117 var axis = [0, 0, 0];
118 var angle = MathUtils.getAxisAngleBetween3DVectors(oldN, newN, axis);
119 if (angle === 0) {
120 return;
121 }
122
123 // *** compute the vector from anchor to prev
124 var oldP = [this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z];
125 var rotMat = Matrix.Rotation(-angle, axis);
126 var newP = MathUtils.transformVector(oldP, rotMat);
127
128 //TEMP for some situations the axis angle computation returns NaNs
129 if (isNaN(newP[0]) || isNaN(newP[1]) || isNaN(newP[2])) {
130 return;
131 }
132 //end TEMP
133 this._prevX = this._x + newP[0];
134 this._prevY = this._y + newP[1];
135 this._prevZ = this._z + newP[2];
136};
137
138// ******* modifiers *******
139GLAnchorPoint.prototype.translatePrev = function (x, y, z) {
140 this._prevX += x;
141 this._prevY += y;
142 this._prevZ += z;
143};
144
145GLAnchorPoint.prototype.translateNext = function (x, y, z) {
146 this._nextX += x;
147 this._nextY += y;
148 this._nextZ += z;
149};
150
151GLAnchorPoint.prototype.translate = function (x, y, z) {
152 this._x += x;
153 this._y += y;
154 this._z += z;
155};
156
157GLAnchorPoint.prototype.translateAll = function (x, y, z) {
158 this.translate(x, y, z);
159 this.translatePrev(x, y, z);
160 this.translateNext(x, y, z);
161};
162
163GLAnchorPoint.prototype.scaleAll = function(sx,sy,sz){
164 this._x *= sx;
165 this._prevX *= sx;
166 this._nextX *= sx;
167 this._y *= sy;
168 this._prevY *= sy;
169 this._nextY *= sy;
170 this._z *= sz;
171 this._prevZ *= sz;
172 this._nextZ *= sz;
173};
174
175// ********* getters **********
176GLAnchorPoint.prototype.getPosX = function () {
177 return this._x;
178};
179
180GLAnchorPoint.prototype.getPosY = function () {
181 return this._y;
182};
183
184GLAnchorPoint.prototype.getPosZ = function () {
185 return this._z;
186};
187
188GLAnchorPoint.prototype.getPrevX = function () {
189 return this._prevX;
190};
191
192GLAnchorPoint.prototype.getPrevY = function () {
193 return this._prevY;
194};
195
196GLAnchorPoint.prototype.getPrevZ = function () {
197 return this._prevZ;
198};
199
200GLAnchorPoint.prototype.getNextX = function () {
201 return this._nextX;
202};
203
204GLAnchorPoint.prototype.getNextY = function () {
205 return this._nextY;
206};
207
208GLAnchorPoint.prototype.getNextZ = function () {
209 return this._nextZ;
210};
211
212GLAnchorPoint.prototype.getPos = function() {
213 return [this._x, this._y, this._z];