aboutsummaryrefslogtreecommitdiff
path: root/js/tools/TranslateObject3DTool.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-04-10 11:24:35 -0700
committerJose Antonio Marquez2012-04-10 11:24:35 -0700
commite663e336ee7e832b5059a82748061506b414cb04 (patch)
treea09d932319365067f437780e90aeab4ef19f74b4 /js/tools/TranslateObject3DTool.js
parentc3022de5ba2e24737184dba7454233b165da0a20 (diff)
parentbd43ce383b050d03b0f92cc923c517febc66ca28 (diff)
downloadninja-e663e336ee7e832b5059a82748061506b414cb04.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/tools/TranslateObject3DTool.js')
-rwxr-xr-xjs/tools/TranslateObject3DTool.js33
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
7var Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, 7var 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
12exports.TranslateObject3DTool = Object.create(Translate3DToolBase, { 14exports.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;