From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- js/helper-classes/3D/hit-record.js | 322 ++++++++++++++++++------------------- 1 file changed, 161 insertions(+), 161 deletions(-) (limited to 'js/helper-classes/3D/hit-record.js') diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js index 46462c20..4c1a71b0 100755 --- a/js/helper-classes/3D/hit-record.js +++ b/js/helper-classes/3D/hit-record.js @@ -41,90 +41,90 @@ var snapManagerModule = require("js/helper-classes/3D/snap-manager"); var HitRecord = exports.HitRecord = Object.create(Object.prototype, { - /////////////////////////////////////////////////////////////////////// - // Constant definitions - /////////////////////////////////////////////////////////////////////// - SNAP_TYPE_STAGE : { value: 1, writable: true }, - SNAP_TYPE_GRID_VERTEX : { value: 2, writable: true }, - SNAP_TYPE_GRID_HORIZONTAL : { value: 13, writable: true }, - SNAP_TYPE_GRID_VERTICAL: { value: 14, writable: true }, - SNAP_TYPE_ALIGN_MERGED: { value: 15, writable: true }, - SNAP_TYPE_HORIZONTAL_FROM_START: { value: 3, writable: true }, - SNAP_TYPE_VERTICAL_FROM_START: { value: 4, writable: true }, - SNAP_TYPE_ELEMENT: { value: 5, writable: true }, - SNAP_TYPE_ELEMENT_EDGE: { value: 6, writable: true }, - SNAP_TYPE_ELEMENT_VERTEX: { value: 7, writable: true }, - SNAP_TYPE_ALIGN_HORIZONTAL: { value: 8, writable: true }, - SNAP_TYPE_ALIGN_VERTICAL: { value: 9, writable: true }, - SNAP_TYPE_ALIGN_BOTH: { value: 10, writable: true }, - SNAP_TYPE_ELEMENT_CENTER: { value: 11, writable: true }, - SNAP_TYPE_CONTAINED_ELEMENT: { value: 12, writable: true }, - SNAP_TYPE_UNDEFINED: { value: null, writable: -1 }, - - /////////////////////////////////////////////////////////////////////// - // Instance variables - /////////////////////////////////////////////////////////////////////// - _type: { value: this.SNAP_TYPE_UNDEFINED, writable: true }, - _elt: { value: null, writable: true }, // this can be null. example: snapping to the working plane - _screenPt: { value: null, writable: true }, // snap point in global screen space - _localPoint: { value: null, writable: true }, // snap point in the local space of the element - _plane: { value: null, writable: true }, // plane equation at the snap point in local object space - _planeMat: { value: Matrix.I(4) , writable: true }, // transform to take the point from plane space to the transformed view space of the element - _assocScrPt: { value: null, writable: true }, // associated screen point - _assocScrPt2: { value: null, writable: true }, // a second associated point for drawing multiple snap align hits - _planarHit: { value: false, writable: true }, - _snapBoundaryIndex : { value: -1, writable: true }, // this used for snap align to object boundaries - _isQuadPt :{ value: false, writable: true }, // used for snapping to an object's quadrant point - - /////////////////////////////////////////////////////////////////////// - // Property accessors - /////////////////////////////////////////////////////////////////////// - getElt : { value: function() { return this._elt; }}, - setElt : { value: function(e) { this._elt = e; }}, - getElement : { value: function() { return this._elt; }}, - setElement : { value: function(e) { this._elt = e; }}, - - getZIndex : { value: function() { return this._zIndex; }}, - setZIndex : { value: function(i) { this._zIndex = i; }}, - - setScreenPoint : { value: function(s) { this._screenPt = s.slice(0); }}, - getScreenPoint : { value: function() { return this._screenPt.slice(0); }}, - - setLocalPoint : { value: function(s) { this._localPt = s.slice(0); }}, - getLocalPoint : { value: function() { return this._localPt.slice(0); }}, - - setAssociatedScreenPoint : { value: function(s) { this._assocScrPt = s.slice(0); }}, - getAssociatedScreenPoint : { value: function() { return this._assocScrPt.slice(0); }}, - hasAssociatedScreenPoint : { value: function() { return this._assocScrPt != null; }}, - - setAssociatedScreenPoint2 : { value: function(s) { this._assocScrPt2 = s.slice(0); }}, - getAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2.slice(0); }}, - hasAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2 != null; }}, - - setPlane : { value: function(p) { this._plane = p.slice(0); }}, - getPlane : { value: function() { return this._plane.slice(0); }}, - - setPlaneMatrix : { value: function(pm) { this._planeMat = pm.slice(0); }}, - getPlaneMatrix : { value: function() { return this._planeMat.slice(0); }}, - - setPlanarHit : { value: function(p) { this._planarHit = p; }}, - isPlanarHit : { value: function() { return this._planarHit; }}, - - getSnapBoundaryIndex : { value: function() { return this._snapBoundaryIndex; }}, - setSnapBoundaryIndex : { value: function(i) { this._snapBoundaryIndex = i; }}, - - getType : { value: function() { return this._type; }}, - setType : { value: function(t) {this._type = t; if (!this.checkType()) { throw new Error("invalid snap type"); return; } }}, - - getUseQuadPoint : { value: function() { return this._isQuadPt; }}, - setUseQuadPoint : { value: function(q) {this._isQuadPt = q; }}, - - /////////////////////////////////////////////////////////////////////// - // Methods - /////////////////////////////////////////////////////////////////////// - - checkType :{ - value: function() { + /////////////////////////////////////////////////////////////////////// + // Constant definitions + /////////////////////////////////////////////////////////////////////// + SNAP_TYPE_STAGE : { value: 1, writable: true }, + SNAP_TYPE_GRID_VERTEX : { value: 2, writable: true }, + SNAP_TYPE_GRID_HORIZONTAL : { value: 13, writable: true }, + SNAP_TYPE_GRID_VERTICAL: { value: 14, writable: true }, + SNAP_TYPE_ALIGN_MERGED: { value: 15, writable: true }, + SNAP_TYPE_HORIZONTAL_FROM_START: { value: 3, writable: true }, + SNAP_TYPE_VERTICAL_FROM_START: { value: 4, writable: true }, + SNAP_TYPE_ELEMENT: { value: 5, writable: true }, + SNAP_TYPE_ELEMENT_EDGE: { value: 6, writable: true }, + SNAP_TYPE_ELEMENT_VERTEX: { value: 7, writable: true }, + SNAP_TYPE_ALIGN_HORIZONTAL: { value: 8, writable: true }, + SNAP_TYPE_ALIGN_VERTICAL: { value: 9, writable: true }, + SNAP_TYPE_ALIGN_BOTH: { value: 10, writable: true }, + SNAP_TYPE_ELEMENT_CENTER: { value: 11, writable: true }, + SNAP_TYPE_CONTAINED_ELEMENT: { value: 12, writable: true }, + SNAP_TYPE_UNDEFINED: { value: null, writable: -1 }, + + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + _type: { value: this.SNAP_TYPE_UNDEFINED, writable: true }, + _elt: { value: null, writable: true }, // this can be null. example: snapping to the working plane + _screenPt: { value: null, writable: true }, // snap point in global screen space + _localPoint: { value: null, writable: true }, // snap point in the local space of the element + _plane: { value: null, writable: true }, // plane equation at the snap point in local object space + _planeMat: { value: Matrix.I(4) , writable: true }, // transform to take the point from plane space to the transformed view space of the element + _assocScrPt: { value: null, writable: true }, // associated screen point + _assocScrPt2: { value: null, writable: true }, // a second associated point for drawing multiple snap align hits + _planarHit: { value: false, writable: true }, + _snapBoundaryIndex : { value: -1, writable: true }, // this used for snap align to object boundaries + _isQuadPt :{ value: false, writable: true }, // used for snapping to an object's quadrant point + + /////////////////////////////////////////////////////////////////////// + // Property accessors + /////////////////////////////////////////////////////////////////////// + getElt : { value: function() { return this._elt; }}, + setElt : { value: function(e) { this._elt = e; }}, + getElement : { value: function() { return this._elt; }}, + setElement : { value: function(e) { this._elt = e; }}, + + getZIndex : { value: function() { return this._zIndex; }}, + setZIndex : { value: function(i) { this._zIndex = i; }}, + + setScreenPoint : { value: function(s) { this._screenPt = s.slice(0); }}, + getScreenPoint : { value: function() { return this._screenPt.slice(0); }}, + + setLocalPoint : { value: function(s) { this._localPt = s.slice(0); }}, + getLocalPoint : { value: function() { return this._localPt.slice(0); }}, + + setAssociatedScreenPoint : { value: function(s) { this._assocScrPt = s.slice(0); }}, + getAssociatedScreenPoint : { value: function() { return this._assocScrPt.slice(0); }}, + hasAssociatedScreenPoint : { value: function() { return this._assocScrPt != null; }}, + + setAssociatedScreenPoint2 : { value: function(s) { this._assocScrPt2 = s.slice(0); }}, + getAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2.slice(0); }}, + hasAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2 != null; }}, + + setPlane : { value: function(p) { this._plane = p.slice(0); }}, + getPlane : { value: function() { return this._plane.slice(0); }}, + + setPlaneMatrix : { value: function(pm) { this._planeMat = pm.slice(0); }}, + getPlaneMatrix : { value: function() { return this._planeMat.slice(0); }}, + + setPlanarHit : { value: function(p) { this._planarHit = p; }}, + isPlanarHit : { value: function() { return this._planarHit; }}, + + getSnapBoundaryIndex : { value: function() { return this._snapBoundaryIndex; }}, + setSnapBoundaryIndex : { value: function(i) { this._snapBoundaryIndex = i; }}, + + getType : { value: function() { return this._type; }}, + setType : { value: function(t) {this._type = t; if (!this.checkType()) { throw new Error("invalid snap type"); return; } }}, + + getUseQuadPoint : { value: function() { return this._isQuadPt; }}, + setUseQuadPoint : { value: function(q) {this._isQuadPt = q; }}, + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + + checkType :{ + value: function() { var ok = false; switch (this._type) { @@ -161,7 +161,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, } }, - isSomeGridTypeSnap : { + isSomeGridTypeSnap : { value: function() { return ((this._type == this.SNAP_TYPE_GRID_VERTEX) || (this._type == this.SNAP_TYPE_GRID_HORIZONTAL) || @@ -170,7 +170,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, } }, - convertToWorkingPlane : { + convertToWorkingPlane : { value: function( wp ) { var swp = this.calculateStageWorldPoint(); var wpMat = drawUtils.getPlaneToWorldMatrix(wp, MathUtils.getPointOnPlane(wp)); @@ -191,7 +191,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, } }, - calculateStageWorldPoint : { + calculateStageWorldPoint : { value: function() { var wPt; var elt = this.getElt(); @@ -207,7 +207,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, }, - calculateScreenPoint : { + calculateScreenPoint : { value: function() { var scrPt; @@ -231,7 +231,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, } }, - calculateElementWorldPoint : { + calculateElementWorldPoint : { value: function() { var localPt = this.getLocalPoint(); var worldPt = MathUtils.transformPoint( localPt, this.getPlaneMatrix() ); @@ -240,7 +240,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, } }, - calculateElementScreenPoint : { + calculateElementScreenPoint : { value: function() { var worldPt = this.calculateElementWorldPoint(); viewUtils.pushViewportObj( this._elt ); @@ -251,7 +251,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, } }, - calculateElementScreenToPlane : { + calculateElementScreenToPlane : { value: function( scrPt, plane ) { var elt = this.getElt(); viewUtils.pushViewportObj( elt ); @@ -285,29 +285,29 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, viewUtils.popViewportObj(); return scrPt; - } + } }, - getTypeString :{ - value: function() { + getTypeString :{ + value: function() { var str; switch (this.getType()) { - case this.SNAP_TYPE_STAGE: str = "SNAP_TYPE_STAGE"; break; - case this.SNAP_TYPE_GRID_VERTEX: str = "SNAP_TYPE_GRID_VERTEX"; break; - case this.SNAP_TYPE_GRID_HORIZONTAL: str = "SNAP_TYPE_GRID_HORIZONTAL"; break; - case this.SNAP_TYPE_GRID_VERTICAL: str = "SNAP_TYPE_GRID_VERTICAL"; break; - case this.SNAP_TYPE_HORIZONTAL_FROM_START: str = "SNAP_TYPE_HORIZONTAL_FROM_START"; break; - case this.SNAP_TYPE_VERTICAL_FROM_START: str = "SNAP_TYPE_VERTICAL_FROM_START"; break; - case this.SNAP_TYPE_ELEMENT: str = "SNAP_TYPE_ELEMENT"; break; - case this.SNAP_TYPE_ELEMENT_EDGE: str = "SNAP_TYPE_ELEMENT_EDGE"; break; - case this.SNAP_TYPE_ELEMENT_VERTEX: str = "SNAP_TYPE_ELEMENT_VERTEX"; break; - case this.SNAP_TYPE_ELEMENT_CENTER: str = "SNAP_TYPE_ELEMENT_CENTER"; break; - case this.SNAP_TYPE_CONTAINED_ELEMENT: str = "SNAP_TYPE_CONTAINED_ELEMENT"; break; - case this.SNAP_TYPE_ALIGN_HORIZONTAL: str = "SNAP_TYPE_ALIGN_HORIZONTAL"; break; - case this.SNAP_TYPE_ALIGN_VERTICAL: str = "SNAP_TYPE_ALIGN_VERTICAL"; break; - case this.SNAP_TYPE_ALIGN_BOTH: str = "SNAP_TYPE_ALIGN_BOTH"; break; - case this.SNAP_TYPE_ALIGN_MERGED: str = "this.SNAP_TYPE_ALIGN_MERGED"; break; + case this.SNAP_TYPE_STAGE: str = "SNAP_TYPE_STAGE"; break; + case this.SNAP_TYPE_GRID_VERTEX: str = "SNAP_TYPE_GRID_VERTEX"; break; + case this.SNAP_TYPE_GRID_HORIZONTAL: str = "SNAP_TYPE_GRID_HORIZONTAL"; break; + case this.SNAP_TYPE_GRID_VERTICAL: str = "SNAP_TYPE_GRID_VERTICAL"; break; + case this.SNAP_TYPE_HORIZONTAL_FROM_START: str = "SNAP_TYPE_HORIZONTAL_FROM_START"; break; + case this.SNAP_TYPE_VERTICAL_FROM_START: str = "SNAP_TYPE_VERTICAL_FROM_START"; break; + case this.SNAP_TYPE_ELEMENT: str = "SNAP_TYPE_ELEMENT"; break; + case this.SNAP_TYPE_ELEMENT_EDGE: str = "SNAP_TYPE_ELEMENT_EDGE"; break; + case this.SNAP_TYPE_ELEMENT_VERTEX: str = "SNAP_TYPE_ELEMENT_VERTEX"; break; + case this.SNAP_TYPE_ELEMENT_CENTER: str = "SNAP_TYPE_ELEMENT_CENTER"; break; + case this.SNAP_TYPE_CONTAINED_ELEMENT: str = "SNAP_TYPE_CONTAINED_ELEMENT"; break; + case this.SNAP_TYPE_ALIGN_HORIZONTAL: str = "SNAP_TYPE_ALIGN_HORIZONTAL"; break; + case this.SNAP_TYPE_ALIGN_VERTICAL: str = "SNAP_TYPE_ALIGN_VERTICAL"; break; + case this.SNAP_TYPE_ALIGN_BOTH: str = "SNAP_TYPE_ALIGN_BOTH"; break; + case this.SNAP_TYPE_ALIGN_MERGED: str = "this.SNAP_TYPE_ALIGN_MERGED"; break; default: str = "SNAP_TYPE_UNDEFINED"; @@ -318,57 +318,57 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, } }, - test: - { - value: function() - { - var elt = this.getElement(); - var stage = viewUtils.getStage(); - if (elt === stage) return; - - var localPt = this.calculateElementPreTransformScreenPoint(); - var stageWorldPt = this.calculateStageWorldPoint(); - var globalPt = this.getScreenPoint(); - var err = false; - - var test1 = viewUtils.localToGlobal( localPt, elt ); - var dist = vecUtils.vecDist(3, test1, globalPt); - if (MathUtils.fpSign(dist) != 0) - { - err = true; - console.log( "**** transform error 1 ***** " + dist + ", localPt: " + localPt ); - } - - var stageWorldToGlobal = viewUtils.getStageWorldToGlobalMatrix(); - var test2 = MathUtils.transformAndDivideHomogeneousPoint( stageWorldPt, stageWorldToGlobal ); - dist = vecUtils.vecDist(3, test2, globalPt); - if (MathUtils.fpSign(dist) != 0) - { - err = true; - console.log( "**** transform error 2 ***** " + dist + ", localPt: " + localPt ); - } - - var localToGlobal = viewUtils.getLocalToGlobalMatrix( elt ); - var globalToLocal = glmat4.inverse( localToGlobal, [] ); - var test3 = MathUtils.transformAndDivideHomogeneousPoint( globalPt, globalToLocal ); - dist = vecUtils.vecDist(3, test3, localPt); - if (MathUtils.fpSign(dist) != 0) - { - err = true; - console.log( "**** transform error 3 ***** " + dist + ", localPt: " + localPt ); - } - - var objToStageWorld = viewUtils.getObjToStageWorldMatrix( elt, true ); - var test4 = MathUtils.transformAndDivideHomogeneousPoint( localPt, objToStageWorld ); - dist = vecUtils.vecDist(3, test4, stageWorldPt); - if (MathUtils.fpSign(dist) != 0) - { - err = true; - console.log( "**** transform error 4 ***** " + dist + ", localPt: " + localPt ); - } - - //if (!err) console.log( "no hitRecord error" ); - } - } + test: + { + value: function() + { + var elt = this.getElement(); + var stage = viewUtils.getStage(); + if (elt === stage) return; + + var localPt = this.calculateElementPreTransformScreenPoint(); + var stageWorldPt = this.calculateStageWorldPoint(); + var globalPt = this.getScreenPoint(); + var err = false; + + var test1 = viewUtils.localToGlobal( localPt, elt ); + var dist = vecUtils.vecDist(3, test1, globalPt); + if (MathUtils.fpSign(dist) != 0) + { + err = true; + console.log( "**** transform error 1 ***** " + dist + ", localPt: " + localPt ); + } + + var stageWorldToGlobal = viewUtils.getStageWorldToGlobalMatrix(); + var test2 = MathUtils.transformAndDivideHomogeneousPoint( stageWorldPt, stageWorldToGlobal ); + dist = vecUtils.vecDist(3, test2, globalPt); + if (MathUtils.fpSign(dist) != 0) + { + err = true; + console.log( "**** transform error 2 ***** " + dist + ", localPt: " + localPt ); + } + + var localToGlobal = viewUtils.getLocalToGlobalMatrix( elt ); + var globalToLocal = glmat4.inverse( localToGlobal, [] ); + var test3 = MathUtils.transformAndDivideHomogeneousPoint( globalPt, globalToLocal ); + dist = vecUtils.vecDist(3, test3, localPt); + if (MathUtils.fpSign(dist) != 0) + { + err = true; + console.log( "**** transform error 3 ***** " + dist + ", localPt: " + localPt ); + } + + var objToStageWorld = viewUtils.getObjToStageWorldMatrix( elt, true ); + var test4 = MathUtils.transformAndDivideHomogeneousPoint( localPt, objToStageWorld ); + dist = vecUtils.vecDist(3, test4, stageWorldPt); + if (MathUtils.fpSign(dist) != 0) + { + err = true; + console.log( "**** transform error 4 ***** " + dist + ", localPt: " + localPt ); + } + + //if (!err) console.log( "no hitRecord error" ); + } + } }); -- cgit v1.2.3 From 04343eda8c2f870b0da55cfdc8003c99fe1cc4de Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:53:10 -0700 Subject: Remove trailing spaces --- js/helper-classes/3D/hit-record.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/helper-classes/3D/hit-record.js') diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js index 4c1a71b0..7e39bb50 100755 --- a/js/helper-classes/3D/hit-record.js +++ b/js/helper-classes/3D/hit-record.js @@ -60,7 +60,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, SNAP_TYPE_ELEMENT_CENTER: { value: 11, writable: true }, SNAP_TYPE_CONTAINED_ELEMENT: { value: 12, writable: true }, SNAP_TYPE_UNDEFINED: { value: null, writable: -1 }, - + /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3