aboutsummaryrefslogtreecommitdiff
path: root/js/tools/RotateObject3DTool.js
diff options
context:
space:
mode:
authorhwc4872012-04-11 16:01:33 -0700
committerhwc4872012-04-11 16:01:33 -0700
commitf522ce09d98bbb2812ed25bb942597d854d71a1c (patch)
treea186dce4bdd589ba6dd102b758f1670a3e1e61ba /js/tools/RotateObject3DTool.js
parent2d21b01d6dd64af643f5f38818b57fcace05ea0b (diff)
downloadninja-f522ce09d98bbb2812ed25bb942597d854d71a1c.tar.gz
Rotate3D tool changes
Diffstat (limited to 'js/tools/RotateObject3DTool.js')
-rwxr-xr-xjs/tools/RotateObject3DTool.js141
1 files changed, 140 insertions, 1 deletions
diff --git a/js/tools/RotateObject3DTool.js b/js/tools/RotateObject3DTool.js
index 72af6eff..7b4ec083 100755
--- a/js/tools/RotateObject3DTool.js
+++ b/js/tools/RotateObject3DTool.js
@@ -4,7 +4,9 @@ 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
7var Montage = require("montage/core/core").Montage; 7var Montage = require("montage/core/core").Montage,
8 viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils,
9 snapManager = require("js/helper-classes/3D/snap-manager").SnapManager;
8 10
9var Rotate3DToolBase = require("js/tools/Rotate3DToolBase").Rotate3DToolBase; 11var Rotate3DToolBase = require("js/tools/Rotate3DToolBase").Rotate3DToolBase;
10var toolHandleModule = require("js/stage/tool-handle"); 12var toolHandleModule = require("js/stage/tool-handle");
@@ -54,6 +56,143 @@ exports.RotateObject3DTool = Montage.create(Rotate3DToolBase, {
54 } 56 }
55 }, 57 },
56 58
59 initializeSnapping : {
60 value : function(event)
61 {
62 console.log( "initializeSnapping" );
63
64 this._mouseDownHitRec = null;
65 this._mouseUpHitRec = null;
66
67 snapManager.clearAvoidList();
68 snapManager.clearDragPlane();
69
70 // the translate tool does snap align to the bounds of the object only.
71 // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method
72 snapManager.enableSnapAlign( false );
73
74 // snap to element and snap to grid are conditionally enabled based
75 // on the snap results of the mouse down. enable everything for the first snap
76 this._snapToElements = snapManager.elementSnapEnabledAppLevel();
77 this._snapToGrid = snapManager.gridSnapEnabledAppLevel();
78
79 this._dragPlane = null;
80 this._clickedOnStage = false;
81 var do3DSnap = true;
82
83 if(this._handleMode === null)
84 {
85 snapManager.enableElementSnap ( true );
86 snapManager.enableGridSnap ( true );
87 }
88// else
89// {
90// this._delta = null;
91 // special case for z-translation
92// if(this._handleMode === 0)
93// {
94// this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target);
95// snapManager.setupDragPlaneFromPlane(this._dragPlane);
96// do3DSnap = false;
97
98// snapManager.enableElementSnap ( false );
99// snapManager.enableGridSnap ( false );
100// }
101// }
102
103 if (this._targets)
104 {
105 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas,
106 new WebKitPoint(event.pageX, event.pageY));
107
108 // do the snap before setting up the avoid list to allow
109 // a snap on the mouse down
110 var hitRec = snapManager.snap(point.x, point.y, do3DSnap);
111
112// if(this._handleMode === 2)
113// {
114// // translate z doesn't snap to element so hitRec's element will always be different
115// // from what the browser says we clicked on. So, skip this check.
116// }
117// else
118// {
119// // Check that hitRec's element matches element that browser says we clicked on
120// // TODO - This is still not working when using a handle that is on top of an
121// // element that is not currently selected
122// var elt = this.application.ninja.stage.GetSelectableElement(event);
123// if(elt && (elt !== hitRec.getElement()))
124// {
125// hitRec = snapManager.findHitRecordForElement(elt);
126// }
127// if(elt === this.application.ninja.currentSelectedContainer)
128// {
129// this._clickedOnStage = true;
130// }
131// }
132
133 // we don't want to snap to selected objects during the drag
134// var len = this._targets.length;
135// for(var i=0; i<len; i++)
136// {
137// snapManager.addToAvoidList( this._targets[i].elt );
138// }
139 if (hitRec)
140 {
141 // disable snap attributes
142 if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT)
143 {
144 this._snapToElements = false;
145 this._snapToGrid = false;
146 }
147 else if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT_CENTER)
148 {
149 snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() );
150 }
151
152 if(this._handleMode === 0)
153 this.clickedObject = this._target;
154
155 // parameterize the snap point on the target
156 this._snapParam = this.parameterizeSnap( hitRec );
157
158 if(!this._dragPlane)
159 {
160 if (this._targets.length === 1)
161 {
162 this._dragPlane = viewUtils.getUnprojectedElementPlane(this._clickedObject);
163 snapManager.setupDragPlaneFromPlane(this._dragPlane);
164 }
165 else
166 {
167 this._dragPlane = snapManager.setupDragPlanes( hitRec, true );
168 }
169
170 }
171
172 // no quadrant snapping for the rotate tool
173 this._shouldUseQuadPt = false;
174
175 var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane );
176 this._mouseDownHitRec = wpHitRec;
177 this._mouseUpHitRec = null;
178
179 var pt = hitRec.getScreenPoint();
180 this.downPoint.x = pt[0];
181 this.downPoint.y = pt[1];
182 this.downPoint.z = pt[2];
183
184 // TODO - need to figure out snapManager dependency by drawUtils.
185 // For now, bypassing by calling snapManager.drawLastHit();
186// drawUtils.refreshDisplay();
187// snapManager.drawLastHit();
188 }
189 }
190 else
191 {
192 this.target = null;
193 }
194 }
195 },
57 _handleToolOptionsChange: { 196 _handleToolOptionsChange: {
58 value: function(event) { 197 value: function(event) {
59 this._inLocalMode = event.detail.mode; 198 this._inLocalMode = event.detail.mode;