diff options
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-x | js/helper-classes/3D/hit-record.js | 10 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 20 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 209 |
3 files changed, 165 insertions, 74 deletions
diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js index 2c60adc6..265bf2a4 100755 --- a/js/helper-classes/3D/hit-record.js +++ b/js/helper-classes/3D/hit-record.js | |||
@@ -232,7 +232,15 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, | |||
232 | var elt = this.getElt(); | 232 | var elt = this.getElt(); |
233 | viewUtils.pushViewportObj( elt ); | 233 | viewUtils.pushViewportObj( elt ); |
234 | var viewPt = viewUtils.screenToView( scrPt[0], scrPt[1], scrPt[2] ); | 234 | var viewPt = viewUtils.screenToView( scrPt[0], scrPt[1], scrPt[2] ); |
235 | var eyePt = viewUtils.getEyePoint(); | 235 | var eyePt; |
236 | if(viewUtils.getPerspectiveDistFromElement(elt)) | ||
237 | { | ||
238 | eyePt = viewUtils.getEyePoint(); | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | eyePt = [viewPt[0], viewPt[1], 1400]; | ||
243 | } | ||
236 | var projPt = MathUtils.vecIntersectPlane( eyePt, MathUtils.vecSubtract(viewPt,eyePt), plane ); | 244 | var projPt = MathUtils.vecIntersectPlane( eyePt, MathUtils.vecSubtract(viewPt,eyePt), plane ); |
237 | 245 | ||
238 | return projPt; | 246 | return projPt; |
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index a401c363..02e81a62 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -229,7 +229,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
229 | parentPt = [quadPt[0], quadPt[1], 0.0]; | 229 | parentPt = [quadPt[0], quadPt[1], 0.0]; |
230 | else | 230 | else |
231 | parentPt = [xScreen, yScreen, 0.0]; | 231 | parentPt = [xScreen, yScreen, 0.0]; |
232 | var vec = viewUtils.parentToChildVec(parentPt, stage); | 232 | |
233 | var eyePt = []; | ||
234 | var vec = viewUtils.parentToChildVec(parentPt, stage, eyePt); | ||
233 | if (vec) | 235 | if (vec) |
234 | { | 236 | { |
235 | // activate the drag working plane | 237 | // activate the drag working plane |
@@ -241,7 +243,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
241 | var wp = currentWorkingPlane.slice(0); | 243 | var wp = currentWorkingPlane.slice(0); |
242 | var mat = viewUtils.getMatrixFromElement(stage); | 244 | var mat = viewUtils.getMatrixFromElement(stage); |
243 | wp = MathUtils.transformPlane(wp, mat); | 245 | wp = MathUtils.transformPlane(wp, mat); |
244 | var eyePt = viewUtils.getEyePoint(); | ||
245 | var projPt = MathUtils.vecIntersectPlane(eyePt, vec, wp); | 246 | var projPt = MathUtils.vecIntersectPlane(eyePt, vec, wp); |
246 | if (projPt) | 247 | if (projPt) |
247 | { | 248 | { |
@@ -709,8 +710,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
709 | var wp = currentWorkingPlane.slice(0); | 710 | var wp = currentWorkingPlane.slice(0); |
710 | var mat = viewUtils.getMatrixFromElement(stage); | 711 | var mat = viewUtils.getMatrixFromElement(stage); |
711 | wp = MathUtils.transformPlane(wp, mat); | 712 | wp = MathUtils.transformPlane(wp, mat); |
712 | var eyePt = viewUtils.getEyePoint(); | 713 | var eyePt = []; |
713 | var vec = viewUtils.parentToChildVec(gPt, stage); | 714 | var vec = viewUtils.parentToChildVec(gPt, stage, eyePt); |
714 | var projPt = MathUtils.vecIntersectPlane(eyePt, vec, wp); | 715 | var projPt = MathUtils.vecIntersectPlane(eyePt, vec, wp); |
715 | var wpMat = drawUtils.getPlaneToWorldMatrix(currentWorkingPlane, MathUtils.getPointOnPlane(currentWorkingPlane)); | 716 | var wpMat = drawUtils.getPlaneToWorldMatrix(currentWorkingPlane, MathUtils.getPointOnPlane(currentWorkingPlane)); |
716 | projPt[3] = 1.0; | 717 | projPt[3] = 1.0; |
@@ -1067,8 +1068,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
1067 | // Snapping is done in screen space, so convert the bounds from | 1068 | // Snapping is done in screen space, so convert the bounds from |
1068 | // local element space to global screen space | 1069 | // local element space to global screen space |
1069 | var bounds3D = new Array(); | 1070 | var bounds3D = new Array(); |
1071 | var eltMat = viewUtils.getLocalToGlobalMatrix( elt ); | ||
1070 | for (var i=0; i<4; i++) | 1072 | for (var i=0; i<4; i++) |
1071 | bounds3D[i] = viewUtils.localToGlobal( bounds[i], elt ); | 1073 | bounds3D[i] = viewUtils.localToGlobal2(bounds[i], eltMat); |
1072 | 1074 | ||
1073 | var hitRec = this.snapToScreenBounds( elt, globalScrPt, bounds, bounds3D ); | 1075 | var hitRec = this.snapToScreenBounds( elt, globalScrPt, bounds, bounds3D ); |
1074 | 1076 | ||
@@ -1352,7 +1354,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
1352 | var offset = viewUtils.getElementOffset( elt ); | 1354 | var offset = viewUtils.getElementOffset( elt ); |
1353 | MathUtils.makeDimension3( offset ); | 1355 | MathUtils.makeDimension3( offset ); |
1354 | var parentPt = vecUtils.vecAdd(3, scrPt, offset ); | 1356 | var parentPt = vecUtils.vecAdd(3, scrPt, offset ); |
1355 | var globalPt = viewUtils.localToGlobal( parentPt, elt.parentElement ); | 1357 | var globalPt = viewUtils.localToGlobal( parentPt, elt.offsetParent ); |
1356 | 1358 | ||
1357 | var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); | 1359 | var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); |
1358 | if (dist < this.ELEMENT_VERTEX_HIT_RAD) | 1360 | if (dist < this.ELEMENT_VERTEX_HIT_RAD) |
@@ -1390,7 +1392,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
1390 | var offset = viewUtils.getElementOffset( elt ); | 1392 | var offset = viewUtils.getElementOffset( elt ); |
1391 | MathUtils.makeDimension3( offset ); | 1393 | MathUtils.makeDimension3( offset ); |
1392 | var parentPt = vecUtils.vecAdd(3, scrPt, offset ); | 1394 | var parentPt = vecUtils.vecAdd(3, scrPt, offset ); |
1393 | var globalPt = viewUtils.localToGlobal( parentPt, elt.parentElement ); | 1395 | var globalPt = viewUtils.localToGlobal( parentPt, elt.offsetParent ); |
1394 | 1396 | ||
1395 | var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); | 1397 | var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); |
1396 | if (dist < this.ELEMENT_EDGE_HIT_RAD) | 1398 | if (dist < this.ELEMENT_EDGE_HIT_RAD) |
@@ -1443,7 +1445,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
1443 | var offset = viewUtils.getElementOffset( elt ); | 1445 | var offset = viewUtils.getElementOffset( elt ); |
1444 | MathUtils.makeDimension3( offset ); | 1446 | MathUtils.makeDimension3( offset ); |
1445 | var parentPt = vecUtils.vecAdd(3, scrPt, offset ); | 1447 | var parentPt = vecUtils.vecAdd(3, scrPt, offset ); |
1446 | var globalPt = viewUtils.localToGlobal( parentPt, elt.parentElement ); | 1448 | var globalPt = viewUtils.localToGlobal( parentPt, elt.offsetParent ); |
1447 | 1449 | ||
1448 | var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); | 1450 | var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); |
1449 | if (dist < this.ELEMENT_VERTEX_HIT_RAD) | 1451 | if (dist < this.ELEMENT_VERTEX_HIT_RAD) |
@@ -1481,7 +1483,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
1481 | var offset = viewUtils.getElementOffset( elt ); | 1483 | var offset = viewUtils.getElementOffset( elt ); |
1482 | MathUtils.makeDimension3( offset ); | 1484 | MathUtils.makeDimension3( offset ); |
1483 | var parentPt = vecUtils.vecAdd(3, scrPt, offset ); | 1485 | var parentPt = vecUtils.vecAdd(3, scrPt, offset ); |
1484 | var globalPt = viewUtils.localToGlobal( parentPt, elt.parentElement ); | 1486 | var globalPt = viewUtils.localToGlobal( parentPt, elt.offsetParent ); |
1485 | 1487 | ||
1486 | var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); | 1488 | var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); |
1487 | if (dist < this.ELEMENT_EDGE_HIT_RAD) | 1489 | if (dist < this.ELEMENT_EDGE_HIT_RAD) |
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 63c2cb52..1cd1c313 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -37,10 +37,8 @@ exports.ViewUtils = Montage.create(Component, { | |||
37 | setViewportObj: { | 37 | setViewportObj: { |
38 | value: function( vp ) { | 38 | value: function( vp ) { |
39 | this.m_viewportObj = vp; | 39 | this.m_viewportObj = vp; |
40 | this._perspectiveDist = 1400; | ||
41 | 40 | ||
42 | var dist = this.getPerspectiveDistFromElement( vp ); | 41 | this._perspectiveDist = this.getPerspectiveDistFromElement( vp ); |
43 | var mode = this.getPerspectiveModeFromElement( vp ); | ||
44 | } | 42 | } |
45 | }, | 43 | }, |
46 | getViewportObj: { value: function() { return this.m_viewportObj; } }, | 44 | getViewportObj: { value: function() { return this.m_viewportObj; } }, |
@@ -261,7 +259,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
261 | 259 | ||
262 | // transform the point up the tree | 260 | // transform the point up the tree |
263 | var child = elt; | 261 | var child = elt; |
264 | var parent = elt.parentElement; | 262 | var parent = elt.offsetParent; |
265 | while ( parent ) | 263 | while ( parent ) |
266 | { | 264 | { |
267 | // go to screen space of the current child | 265 | // go to screen space of the current child |
@@ -289,7 +287,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
289 | } | 287 | } |
290 | 288 | ||
291 | child = parent; | 289 | child = parent; |
292 | parent = parent.parentElement; | 290 | parent = parent.offsetParent; |
293 | } | 291 | } |
294 | 292 | ||
295 | return pt; | 293 | return pt; |
@@ -305,7 +303,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
305 | 303 | ||
306 | // transform the bounds up the tree | 304 | // transform the bounds up the tree |
307 | var child = elt; | 305 | var child = elt; |
308 | var parent = elt.parentElement; | 306 | var parent = elt.offsetParent; |
309 | while ( parent ) | 307 | while ( parent ) |
310 | { | 308 | { |
311 | pt = this.childToParent( pt, child ); | 309 | pt = this.childToParent( pt, child ); |
@@ -313,7 +311,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
313 | if (parent === this._rootElement) break; | 311 | if (parent === this._rootElement) break; |
314 | 312 | ||
315 | child = parent; | 313 | child = parent; |
316 | parent = parent.parentElement; | 314 | parent = parent.offsetParent; |
317 | } | 315 | } |
318 | 316 | ||
319 | ///////////////////////////////////////////////////////// | 317 | ///////////////////////////////////////////////////////// |
@@ -348,7 +346,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
348 | if (pt.length == 2) pt[2] = 0; | 346 | if (pt.length == 2) pt[2] = 0; |
349 | 347 | ||
350 | // transform the bounds up the tree | 348 | // transform the bounds up the tree |
351 | var parent = child.parentElement; | 349 | var parent = child.offsetParent; |
352 | if ( parent ) | 350 | if ( parent ) |
353 | { | 351 | { |
354 | this.setViewportObj( child ); | 352 | this.setViewportObj( child ); |
@@ -360,11 +358,21 @@ exports.ViewUtils = Montage.create(Component, { | |||
360 | 358 | ||
361 | if (this.elementHas3D( child )) | 359 | if (this.elementHas3D( child )) |
362 | { | 360 | { |
361 | // TODO - Commenting out flatten support until new perspective workflow is fully working | ||
363 | // if (flatten) pt[2] = 0; | 362 | // if (flatten) pt[2] = 0; |
363 | // var flatten = (parent !== this._rootElement) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); | ||
364 | // if(flatten) | ||
365 | // { | ||
366 | // pt[2] = 0; | ||
367 | // } | ||