aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE
diff options
context:
space:
mode:
authorPushkar Joshi2012-02-08 15:39:47 -0800
committerPushkar Joshi2012-02-08 15:39:47 -0800
commit802e92eb70b00849dadacf2c6590d27edbe65d99 (patch)
tree5ecc1e6eef0bb69820af500595fa22f6a68debaf /js/helper-classes/RDGE
parent9b6b228524f14bf65ba60aaf3d0993c8ec5bff2d (diff)
downloadninja-802e92eb70b00849dadacf2c6590d27edbe65d99.tar.gz
bug fixes for better anchor point rotation and removing snapping on hover and mouse down
Diffstat (limited to 'js/helper-classes/RDGE')
-rw-r--r--js/helper-classes/RDGE/GLAnchorPoint.js11
-rw-r--r--js/helper-classes/RDGE/GLBrushStroke.js6
-rw-r--r--js/helper-classes/RDGE/GLSubpath.js4
3 files changed, 19 insertions, 2 deletions
diff --git a/js/helper-classes/RDGE/GLAnchorPoint.js b/js/helper-classes/RDGE/GLAnchorPoint.js
index 6b4af072..716f59d4 100644
--- a/js/helper-classes/RDGE/GLAnchorPoint.js
+++ b/js/helper-classes/RDGE/GLAnchorPoint.js
@@ -55,6 +55,11 @@ GLAnchorPoint.prototype.setNextFromPrev = function () {
55 55
56//translate the next point from the translation that was applied to the prev. point 56//translate the next point from the translation that was applied to the prev. point
57GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) { 57GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) {
58 //do nothing if the total translation is zero
59 var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz);
60 if (totalTransSq < 0.0000001)
61 return;
62
58 // *** compute the rotation of the prev vector *** 63 // *** compute the rotation of the prev vector ***
59 var oldP = Vector.create([this._prevX + tx - this._x, this._prevY + ty - this._y, this._prevZ + tz - this._z]); 64 var oldP = Vector.create([this._prevX + tx - this._x, this._prevY + ty - this._y, this._prevZ + tz - this._z]);
60 var newP = Vector.create([this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z]); 65 var newP = Vector.create([this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z]);
@@ -71,6 +76,7 @@ GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) {
71 76
72 //TEMP for some situations the axis angle computation returns NaNs 77 //TEMP for some situations the axis angle computation returns NaNs
73 if (isNaN(newN[0]) || isNaN(newN[1]) || isNaN(newN[2])) { 78 if (isNaN(newN[0]) || isNaN(newN[1]) || isNaN(newN[2])) {
79 console.log("NaN in translateNextFromPrev");
74 return; 80 return;
75 } 81 }
76 //end TEMP 82 //end TEMP
@@ -80,6 +86,11 @@ GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) {
80} 86}
81//translate the next point from the translation that was applied to the prev. point 87//translate the next point from the translation that was applied to the prev. point
82GLAnchorPoint.prototype.translatePrevFromNext = function (tx, ty, tz) { 88GLAnchorPoint.prototype.translatePrevFromNext = function (tx, ty, tz) {
89 //do nothing if the total translation is zero
90 var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz);
91 if (totalTransSq < 0.0000001)
92 return;
93
83 // *** compute the rotation of the next vector *** 94 // *** compute the rotation of the next vector ***
84 var oldN = Vector.create([this._nextX + tx - this._x, this._nextY + ty - this._y, this._nextZ + tz - this._z]); 95 var oldN = Vector.create([this._nextX + tx - this._x, this._nextY + ty - this._y, this._nextZ + tz - this._z]);
85 var newN = Vector.create([this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z]); 96 var newN = Vector.create([this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z]);
diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js
index 552545f0..fdf1595c 100644
--- a/js/helper-classes/RDGE/GLBrushStroke.js
+++ b/js/helper-classes/RDGE/GLBrushStroke.js
@@ -4,7 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7// Todo: This shoudl be converted to a module 7// Todo: This entire class should be converted to a module
8var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; 8var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
9 9
10/////////////////////////////////////////////////////////////////////// 10///////////////////////////////////////////////////////////////////////
@@ -140,6 +140,10 @@ function GLBrushStroke() {
140 this._dirty = false; 140 this._dirty = false;
141 } 141 }
142 142
143 this.buildBuffers = function () {
144 return; //no need to do anything for now
145 }//buildBuffers()
146
143 //render 147 //render
144 // specify how to render the subpath in Canvas2D 148 // specify how to render the subpath in Canvas2D
145 this.render = function () { 149 this.render = function () {
diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js
index 383194d4..a14fdda0 100644
--- a/js/helper-classes/RDGE/GLSubpath.js
+++ b/js/helper-classes/RDGE/GLSubpath.js
@@ -4,7 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7// Todo: This shoudl be converted to a module 7// Todo: This entire class should be converted to a module
8var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; 8var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
9 9
10 10
@@ -163,6 +163,7 @@ function GLSubpath() {
163 } 163 }
164 */ 164 */
165 165
166
166 var numPoints = this._samples.length/3; 167 var numPoints = this._samples.length/3;
167 ctx.moveTo(this._samples[0]-bboxMin[0],this._samples[1]-bboxMin[1]); 168 ctx.moveTo(this._samples[0]-bboxMin[0],this._samples[1]-bboxMin[1]);
168 for (var i=0;i<numPoints;i++){ 169 for (var i=0;i<numPoints;i++){
@@ -172,6 +173,7 @@ function GLSubpath() {
172 ctx.lineTo(this._samples[0]-bboxMin[0],this._samples[1]-bboxMin[1]); 173 ctx.lineTo(this._samples[0]-bboxMin[0],this._samples[1]-bboxMin[1]);
173 ctx.fill(); 174 ctx.fill();
174 } 175 }
176
175 ctx.stroke(); 177 ctx.stroke();
176 ctx.restore(); 178 ctx.restore();
177 } //render() 179 } //render()