aboutsummaryrefslogtreecommitdiff
path: root/js/tools/Rotate3DToolBase.js
diff options
context:
space:
mode:
authorKruti Shah2012-07-17 12:40:00 -0700
committerKruti Shah2012-07-17 12:40:00 -0700
commitbf2d7bdb22c28089dc1067bc9094ebc590daac87 (patch)
tree2156d9920ea1b7db49ed6460545fea7cda121bae /js/tools/Rotate3DToolBase.js
parent7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff)
parentb4b3e45d6684e77d361b4f8ca5be4889428320c5 (diff)
downloadninja-bf2d7bdb22c28089dc1067bc9094ebc590daac87.tar.gz
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
Diffstat (limited to 'js/tools/Rotate3DToolBase.js')
-rwxr-xr-xjs/tools/Rotate3DToolBase.js347
1 files changed, 174 insertions, 173 deletions
diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js
index 60dcdc6a..e36e23c4 100755
--- a/js/tools/Rotate3DToolBase.js
+++ b/js/tools/Rotate3DToolBase.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -41,7 +42,7 @@ var Montage = require("montage/core/core").Montage,
41 ElementsMediator = require("js/mediators/element-mediator").ElementMediator; 42 ElementsMediator = require("js/mediators/element-mediator").ElementMediator;
42 43
43exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { 44exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
44 _canSnap: { value: false }, 45 _canSnap: { value: false },
45 46
46 _inLocalMode: { value: true, enumerable: true }, 47 _inLocalMode: { value: true, enumerable: true },
47 48
@@ -59,20 +60,20 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
59 selectedElements = [this.application.ninja.currentDocument.model.documentRoot]; 60 selectedElements = [this.application.ninja.currentDocument.model.documentRoot];
60 } 61 }
61 62
62 this._mouseDownHitRec = null; 63 this._mouseDownHitRec = null;
63 this._mouseUpHitRec = null; 64 this._mouseUpHitRec = null;
64 65
65 snapManager.clearAvoidList(); 66 snapManager.clearAvoidList();
66 snapManager.clearDragPlane(); 67 snapManager.clearDragPlane();
67 68
68 // the translate tool does snap align to the bounds of the object only. 69 // the translate tool does snap align to the bounds of the object only.
69 // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method 70 // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method
70 snapManager.enableSnapAlign( false ); 71 snapManager.enableSnapAlign( false );
71 72
72 // snap to element and snap to grid are conditionally enabled based 73 // snap to element and snap to grid are conditionally enabled based
73 // on the snap results of the mouse down. enable everything for the first snap 74 // on the snap results of the mouse down. enable everything for the first snap
74 this._snapToElements = snapManager.elementSnapEnabledAppLevel(); 75 this._snapToElements = snapManager.elementSnapEnabledAppLevel();
75 this._snapToGrid = snapManager.gridSnapEnabledAppLevel(); 76 this._snapToGrid = snapManager.gridSnapEnabledAppLevel();
76 77
77 this._dragPlane = null; 78 this._dragPlane = null;
78 this._clickedOnStage = false; 79 this._clickedOnStage = false;
@@ -80,8 +81,8 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
80 81
81 if(this._handleMode === null) 82 if(this._handleMode === null)
82 { 83 {
83 snapManager.enableElementSnap ( true ); 84 snapManager.enableElementSnap ( true );
84 snapManager.enableGridSnap ( true ); 85 snapManager.enableGridSnap ( true );
85 } 86 }
86// else 87// else
87// { 88// {
@@ -93,8 +94,8 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
93// snapManager.setupDragPlaneFromPlane(this._dragPlane); 94// snapManager.setupDragPlaneFromPlane(this._dragPlane);
94// do3DSnap = false; 95// do3DSnap = false;
95 96
96// snapManager.enableElementSnap ( false ); 97// snapManager.enableElementSnap ( false );
97// snapManager.enableGridSnap ( false ); 98// snapManager.enableGridSnap ( false );
98// } 99// }
99// } 100// }
100 101
@@ -103,9 +104,9 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
103 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, 104 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas,
104 new WebKitPoint(event.pageX, event.pageY)); 105 new WebKitPoint(event.pageX, event.pageY));
105 106
106 // do the snap before setting up the avoid list to allow 107 // do the snap before setting up the avoid list to allow
107 // a snap on the mouse down 108 // a snap on the mouse down
108 var hitRec = snapManager.snap(point.x, point.y, do3DSnap); 109 var hitRec = snapManager.snap(point.x, point.y, do3DSnap);
109 110
110// if(this._handleMode === 2) 111// if(this._handleMode === 2)
111// { 112// {
@@ -134,18 +135,18 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
134// { 135// {
135// snapManager.addToAvoidList( this._targets[i].elt ); 136// snapManager.addToAvoidList( this._targets[i].elt );
136// } 137// }
137 if (hitRec) 138 if (hitRec)
138 { 139 {
139 // disable snap attributes 140 // disable snap attributes
140 if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT) 141 if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT)
141 { 142 {
142 this._snapToElements = false; 143 this._snapToElements = false;
143 this._snapToGrid = false; 144 this._snapToGrid = false;
144 } 145 }
145 else if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT_CENTER) 146 else if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT_CENTER)
146 { 147 {
147 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); 148 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
148 } 149 }
149 150
150 if(this._handleMode === 0) 151 if(this._handleMode === 0)
151 this.clickedObject = this._target; 152 this.clickedObject = this._target;
@@ -170,20 +171,20 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
170 // no quadrant snapping for the rotate tool 171 // no quadrant snapping for the rotate tool
171 this._shouldUseQuadPt = false; 172 this._shouldUseQuadPt = false;
172 173
173 var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); 174 var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane );
174 this._mouseDownHitRec = wpHitRec; 175 this._mouseDownHitRec = wpHitRec;
175 this._mouseUpHitRec = null; 176 this._mouseUpHitRec = null;
176 177
177 var pt = hitRec.getScreenPoint(); 178 var pt = hitRec.getScreenPoint();
178 this.downPoint.x = pt[0]; 179 this.downPoint.x = pt[0];
179 this.downPoint.y = pt[1]; 180 this.downPoint.y = pt[1];
180 this.downPoint.z = pt[2]; 181 this.downPoint.z = pt[2];
181 182
182 // TODO - need to figure out snapManager dependency by drawUtils. 183 // TODO - need to figure out snapManager dependency by drawUtils.
183 // For now, bypassing by calling snapManager.drawLastHit(); 184 // For now, bypassing by calling snapManager.drawLastHit();
184// drawUtils.refreshDisplay(); 185// drawUtils.refreshDisplay();
185// snapManager.drawLastHit(); 186// snapManager.drawLastHit();
186 } 187 }
187 } 188 }
188 else 189 else
189 { 190 {
@@ -231,9 +232,9 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
231 } 232 }
232 } 233 }
233 234
234 this.DrawHandles(this._delta); 235 this.DrawHandles(this._delta);
235 236
236 if(this._canSnap) 237 if(this._canSnap)
237 { 238 {
238 snapManager.drawLastHit(); 239 snapManager.drawLastHit();
239 } 240 }
@@ -261,23 +262,23 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
261 this._origin[1] = pt1.y; 262 this._origin[1] = pt1.y;
262 this._origin[2] = pt1.z; 263 this._origin[2] = pt1.z;
263 264
264 var sw2gMat = viewUtils.getStageWorldToGlobalMatrix(); 265 var sw2gMat = viewUtils.getStageWorldToGlobalMatrix();
265 var g2swMat = glmat4.inverse( sw2gMat, [] ); 266 var g2swMat = glmat4.inverse( sw2gMat, [] );
266 var swOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2swMat ); 267 var swOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2swMat );
267 //console.log( "modifyElements, _origin: " + this._origin + ", in stageWorld: " + swOrigin ); 268 //console.log( "modifyElements, _origin: " + this._origin + ", in stageWorld: " + swOrigin );
268 269
269 var len = selectedElements.length; 270 var len = selectedElements.length;
270 if(len === 1) 271 if(len === 1)
271 { 272 {
272 var elt = selectedElements[0]; 273 var elt = selectedElements[0];
273 <