diff options
Diffstat (limited to 'js/tools/TranslateObject3DTool.js')
-rwxr-xr-x | js/tools/TranslateObject3DTool.js | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 60633e74..8edf1fee 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js | |||
@@ -4,18 +4,28 @@ 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 | var Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, | ||
8 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, | 9 | drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, |
10 | vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, | ||
9 | viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, | 11 | viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, |
10 | snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; | 12 | snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; |
11 | 13 | ||
12 | exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { | 14 | exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { |
13 | _toolID: { value: "translateObject3DTool" }, | 15 | _toolID: { value: "translateObject3DTool" }, |
14 | _canOperateOnStage: { value: true }, | 16 | _canOperateOnStage: { value: true }, |
15 | 17 | ||
18 | _initializeToolHandles: { | ||
19 | value: function() { | ||
20 | this._inLocalMode = (this.options.selectedMode === "rotateLocally"); | ||
21 | } | ||
22 | }, | ||
23 | |||
16 | initializeSnapping : { | 24 | initializeSnapping : { |
17 | value : function(event) | 25 | value : function(event) |
18 | { | 26 | { |
27 | // console.log( "initializeSnapping" ); | ||
28 | |||
19 | this._mouseDownHitRec = null; | 29 | this._mouseDownHitRec = null; |
20 | this._mouseUpHitRec = null; | 30 | this._mouseUpHitRec = null; |
21 | 31 | ||
@@ -37,8 +47,6 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { | |||
37 | 47 | ||
38 | if(this._handleMode === null) | 48 | if(this._handleMode === null) |
39 | { | 49 | { |
40 | // this.doSelection(event); | ||
41 | |||
42 | snapManager.enableElementSnap ( true ); | 50 | snapManager.enableElementSnap ( true ); |
43 | snapManager.enableGridSnap ( true ); | 51 | snapManager.enableGridSnap ( true ); |
44 | } | 52 | } |
@@ -107,16 +115,10 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { | |||
107 | } | 115 | } |
108 | 116 | ||
109 | if(this._handleMode === 2) | 117 | if(this._handleMode === 2) |
110 | { | ||
111 | // TODO - not sure how to parameterize point in z-translate mode | ||
112 | this.clickedObject = this._target; | 118 | this.clickedObject = this._target; |
113 | this._snapParam = [0, 0, 0]; | 119 | |
114 | } | 120 | // parameterize the snap point on the target |
115 | else | 121 | this._snapParam = this.parameterizeSnap( hitRec ); |
116 | { | ||
117 | // parameterize the snap point on the target | ||
118 | this._snapParam = this.parameterizeSnap( hitRec ); | ||
119 | } | ||
120 | 122 | ||
121 | if(!this._dragPlane) | 123 | if(!this._dragPlane) |
122 | { | 124 | { |
@@ -132,6 +134,11 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { | |||
132 | 134 | ||
133 | } | 135 | } |
134 | 136 | ||
137 | // only do quadrant snapping if the 4 corners of the element are in the drag plane | ||
138 | |||
139 | var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); | ||
140 | this._shouldUseQuadPt = (sign == 0); | ||
141 | |||
135 | var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); | 142 | var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); |
136 | this._mouseDownHitRec = wpHitRec; | 143 | this._mouseDownHitRec = wpHitRec; |
137 | this._mouseUpHitRec = null; | 144 | this._mouseUpHitRec = null; |