aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/panels/properties.reel/sections/three-d-view.reel/three-d-view.js66
1 files changed, 59 insertions, 7 deletions
diff --git a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js
index 104d474d..478a6de5 100755
--- a/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js
+++ b/js/panels/properties.reel/sections/three-d-view.reel/three-d-view.js
@@ -5,7 +5,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage; 7var Montage = require("montage/core/core").Montage;
8var Component = require("montage/ui/component").Component; 8 Component = require("montage/ui/component").Component,
9 viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils,
10 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils;
9 11
10exports.ThreeD = Montage.create(Component, { 12exports.ThreeD = Montage.create(Component, {
11 13
@@ -107,6 +109,10 @@ exports.ThreeD = Montage.create(Component, {
107 value: null 109 value: null
108 }, 110 },
109 111
112 _transformCtr: {
113 value: null
114 },
115
110 handleAction: { 116 handleAction: {
111 value: function(event) { 117 value: function(event) {
112 if(event.currentTarget.identifier === "flatten") { 118 if(event.currentTarget.identifier === "flatten") {
@@ -143,10 +149,20 @@ exports.ThreeD = Montage.create(Component, {
143 value : function(prop, value, item, inGlobalMode, isChanging){ 149 value : function(prop, value, item, inGlobalMode, isChanging){
144 if(!this._curMat) { 150 if(!this._curMat) {
145 this._curMat = this.application.ninja.elementMediator.getMatrix(item); 151 this._curMat = this.application.ninja.elementMediator.getMatrix(item);
152// this._transformCtr = item.elementModel.props3D.m_transformCtr || [0,0,0];
153 // TODO - Always use the center for now until we support multiple selections
154 this._transformCtr = [0,0,0];
155 if(inGlobalMode) {
156 this._transformCtr = MathUtils.transformPoint(this._transformCtr, this._curMat);
157 }
146 } 158 }
147 159
148 var curMat = this._curMat; 160 var curMat = this._curMat,
149 var delta = value.value; 161 delta = value.value,
162 isRotating = false,
163 xFormMat = Matrix.I(4),
164 tMat = Matrix.I(4),
165 mat = [];
150 if(inGlobalMode) { 166 if(inGlobalMode) {
151 167
152 if(!this._curProp) { 168 if(!this._curProp) {
@@ -156,17 +172,19 @@ exports.ThreeD = Montage.create(Component, {
156 delta -= this._curProp; 172 delta -= this._curProp;
157 } 173 }
158 174
159 var xFormMat = Matrix.I(4);
160 switch (prop) 175 switch (prop)
161 { 176 {
162 case "xAngle": 177 case "xAngle":
163 xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta); 178 xFormMat = Matrix.RotationX(MathUtils.DEG_TO_RAD * delta);
179 isRotating = true;
164 break; 180 break;
165 case "yAngle": 181 case "yAngle":
166 xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta); 182 xFormMat = Matrix.RotationY(MathUtils.DEG_TO_RAD * delta);
183 isRotating = true;
167 break; 184 break;
168 case "zAngle": 185 case "zAngle":
169 xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta); 186 xFormMat = Matrix.RotationZ(MathUtils.DEG_TO_RAD * delta);
187 isRotating = true;
170 break; 188 break;
171 case "x3D": 189 case "x3D":
172 xFormMat[12] = delta; 190 xFormMat[12] = delta;
@@ -179,11 +197,45 @@ exports.ThreeD = Montage.create(Component, {
179 break; 197 break;
180 } 198 }
181 199
182 var mat = [];
183 if(inGlobalMode) { 200 if(inGlobalMode) {
184 glmat4.multiply(xFormMat, curMat, mat); 201
202 if(isRotating) {
203
204 // pre-translate by the transformation center
205 tMat[12] = this._transformCtr[0];
206 tMat[13] = this._transformCtr[1];
207 tMat[14] = this._transformCtr[2];
208
209 glmat4.multiply(tMat, xFormMat, mat);
210
211 // translate back
212 tMat[12] = -this._transformCtr[0];
213 tMat[13] = -this._transformCtr[1];
214 tMat[14] = -this._transformCtr[2];
215
216 glmat4.multiply(mat, tMat, mat);
217 glmat4.multiply(mat, curMat, mat);
218 } else {
219 glmat4.multiply(xFormMat, curMat, mat);
220 }
185 } else { 221 } else {
186 glmat4.multiply(curMat, xFormMat, mat); 222 if(isRotating) {
223 tMat[12] = this._transformCtr[0];
224 tMat[13] = this._transformCtr[1];
225 tMat[14] = this._transformCtr[2];
226
227 glmat4.multiply(curMat, tMat, mat);
228
229 // translate back
230 tMat[12] = -this._transformCtr[0];
231 tMat[13] = -this._transformCtr[1];
232 tMat[14] = -this._transformCtr[2];
233
234 glmat4.multiply(mat, xFormMat, mat);
235 glmat4.multiply(mat, tMat, mat);
236 } else {
237 glmat4.multiply(curMat, xFormMat, mat);
238 }
187 } 239 }
188 240
189 if(isChanging) { 241 if(isChanging) {