aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/hit-record.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/3D/hit-record.js')
-rwxr-xr-xjs/helper-classes/3D/hit-record.js345
1 files changed, 173 insertions, 172 deletions
diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js
index 46462c20..a82e29ca 100755
--- a/js/helper-classes/3D/hit-record.js
+++ b/js/helper-classes/3D/hit-record.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -41,90 +42,90 @@ var snapManagerModule = require("js/helper-classes/3D/snap-manager");
41var HitRecord = exports.HitRecord = Object.create(Object.prototype, 42var HitRecord = exports.HitRecord = Object.create(Object.prototype,
42{ 43{
43 44
44 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
45 // Constant definitions 46 // Constant definitions
46 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
47 SNAP_TYPE_STAGE : { value: 1, writable: true }, 48 SNAP_TYPE_STAGE : { value: 1, writable: true },
48 SNAP_TYPE_GRID_VERTEX : { value: 2, writable: true }, 49 SNAP_TYPE_GRID_VERTEX : { value: 2, writable: true },
49 SNAP_TYPE_GRID_HORIZONTAL : { value: 13, writable: true }, 50 SNAP_TYPE_GRID_HORIZONTAL : { value: 13, writable: true },
50 SNAP_TYPE_GRID_VERTICAL: { value: 14, writable: true }, 51 SNAP_TYPE_GRID_VERTICAL: { value: 14, writable: true },
51 SNAP_TYPE_ALIGN_MERGED: { value: 15, writable: true }, 52 SNAP_TYPE_ALIGN_MERGED: { value: 15, writable: true },
52 SNAP_TYPE_HORIZONTAL_FROM_START: { value: 3, writable: true }, 53 SNAP_TYPE_HORIZONTAL_FROM_START: { value: 3, writable: true },
53 SNAP_TYPE_VERTICAL_FROM_START: { value: 4, writable: true }, 54 SNAP_TYPE_VERTICAL_FROM_START: { value: 4, writable: true },
54 SNAP_TYPE_ELEMENT: { value: 5, writable: true }, 55 SNAP_TYPE_ELEMENT: { value: 5, writable: true },
55 SNAP_TYPE_ELEMENT_EDGE: { value: 6, writable: true }, 56 SNAP_TYPE_ELEMENT_EDGE: { value: 6, writable: true },
56 SNAP_TYPE_ELEMENT_VERTEX: { value: 7, writable: true }, 57 SNAP_TYPE_ELEMENT_VERTEX: { value: 7, writable: true },
57 SNAP_TYPE_ALIGN_HORIZONTAL: { value: 8, writable: true }, 58 SNAP_TYPE_ALIGN_HORIZONTAL: { value: 8, writable: true },
58 SNAP_TYPE_ALIGN_VERTICAL: { value: 9, writable: true }, 59 SNAP_TYPE_ALIGN_VERTICAL: { value: 9, writable: true },
59 SNAP_TYPE_ALIGN_BOTH: { value: 10, writable: true }, 60 SNAP_TYPE_ALIGN_BOTH: { value: 10, writable: true },
60 SNAP_TYPE_ELEMENT_CENTER: { value: 11, writable: true }, 61 SNAP_TYPE_ELEMENT_CENTER: { value: 11, writable: true },
61 SNAP_TYPE_CONTAINED_ELEMENT: { value: 12, writable: true }, 62 SNAP_TYPE_CONTAINED_ELEMENT: { value: 12, writable: true },
62 SNAP_TYPE_UNDEFINED: { value: null, writable: -1 }, 63 SNAP_TYPE_UNDEFINED: { value: null, writable: -1 },
63 64
64 /////////////////////////////////////////////////////////////////////// 65 ///////////////////////////////////////////////////////////////////////
65 // Instance variables 66 // Instance variables
66 /////////////////////////////////////////////////////////////////////// 67 ///////////////////////////////////////////////////////////////////////
67 _type: { value: this.SNAP_TYPE_UNDEFINED, writable: true }, 68 _type: { value: this.SNAP_TYPE_UNDEFINED, writable: true },
68 _elt: { value: null, writable: true }, // this can be null. example: snapping to the working plane 69 _elt: { value: null, writable: true }, // this can be null. example: snapping to the working plane
69 _screenPt: { value: null, writable: true }, // snap point in global screen space 70 _screenPt: { value: null, writable: true }, // snap point in global screen space
70 _localPoint: { value: null, writable: true }, // snap point in the local space of the element 71 _localPoint: { value: null, writable: true }, // snap point in the local space of the element
71 _plane: { value: null, writable: true }, // plane equation at the snap point in local object space 72 _plane: { value: null, writable: true }, // plane equation at the snap point in local object space
72 _planeMat: { value: Matrix.I(4) , writable: true }, // transform to take the point from plane space to the transformed view space of the element 73 _planeMat: { value: Matrix.I(4) , writable: true }, // transform to take the point from plane space to the transformed view space of the element
73 _assocScrPt: { value: null, writable: true }, // associated screen point 74 _assocScrPt: { value: null, writable: true }, // associated screen point
74 _assocScrPt2: { value: null, writable: true }, // a second associated point for drawing multiple snap align hits 75 _assocScrPt2: { value: null, writable: true }, // a second associated point for drawing multiple snap align hits
75 _planarHit: { value: false, writable: true }, 76 _planarHit: { value: false, writable: true },
76 _snapBoundaryIndex : { value: -1, writable: true }, // this used for snap align to object boundaries 77 _snapBoundaryIndex : { value: -1, writable: true }, // this used for snap align to object boundaries
77 _isQuadPt :{ value: false, writable: true }, // used for snapping to an object's quadrant point 78 _isQuadPt :{ value: false, writable: true }, // used for snapping to an object's quadrant point
78 79
79 /////////////////////////////////////////////////////////////////////// 80 ///////////////////////////////////////////////////////////////////////
80 // Property accessors 81 // Property accessors
81 /////////////////////////////////////////////////////////////////////// 82 ///////////////////////////////////////////////////////////////////////
82 getElt : { value: function() { return this._elt; }}, 83 getElt : { value: function() { return this._elt; }},
83 setElt : { value: function(e) { this._elt = e; }}, 84 setElt : { value: function(e) { this._elt = e; }},
84 getElement : { value: function() { return this._elt; }}, 85 getElement : { value: function() { return this._elt; }},
85 setElement : { value: function(e) { this._elt = e; }}, 86 setElement : { value: function(e) { this._elt = e; }},
86 87
87 getZIndex : { value: function() { return this._zIndex; }}, 88 getZIndex : { value: function() { return this._zIndex; }},
88 setZIndex : { value: function(i) { this._zIndex = i; }}, 89 setZIndex : { value: function(i) { this._zIndex = i; }},
89 90
90 setScreenPoint : { value: function(s) { this._screenPt = s.slice(0); }}, 91 setScreenPoint : { value: function(s) { this._screenPt = s.slice(0); }},
91 getScreenPoint : { value: function() { return this._screenPt.slice(0); }}, 92 getScreenPoint : { value: function() { return this._screenPt.slice(0); }},
92 93
93 setLocalPoint : { value: function(s) { this._localPt = s.slice(0); }}, 94 setLocalPoint : { value: function(s) { this._localPt = s.slice(0); }},
94 getLocalPoint : { value: function() { return this._localPt.slice(0); }}, 95 getLocalPoint : { value: function() { return this._localPt.slice(0); }},
95 96
96 setAssociatedScreenPoint : { value: function(s) { this._assocScrPt = s.slice(0); }}, 97 setAssociatedScreenPoint : { value: function(s) { this._assocScrPt = s.slice(0); }},
97 getAssociatedScreenPoint : { value: function() { return this._assocScrPt.slice(0); }}, 98 getAssociatedScreenPoint : { value: function() { return this._assocScrPt.slice(0); }},
98 hasAssociatedScreenPoint : { value: function() { return this._assocScrPt != null; }}, 99 hasAssociatedScreenPoint : { value: function() { return this._assocScrPt != null; }},
99 100
100 setAssociatedScreenPoint2 : { value: function(s) { this._assocScrPt2 = s.slice(0); }}, 101 setAssociatedScreenPoint2 : { value: function(s) { this._assocScrPt2 = s.slice(0); }},
101 getAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2.slice(0); }}, 102 getAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2.slice(0); }},
102 hasAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2 != null; }}, 103 hasAssociatedScreenPoint2 : { value: function() { return this._assocScrPt2 != null; }},
103 104
104 setPlane : { value: function(p) { this._plane = p.slice(0); }}, 105 setPlane : { value: function(p) { this._plane = p.slice(0); }},
105 getPlane : { value: function() { return this._plane.slice(0); }}, 106 getPlane : { value: function() { return this._plane.slice(0); }},
106 107
107 setPlaneMatrix : { value: function(pm) { this._planeMat = pm.slice(0); }}, 108 setPlaneMatrix : { value: function(pm) { this._planeMat = pm.slice(0); }},
108 getPlaneMatrix : { value: function() { return this._planeMat.slice(0); }}, 109 getPlaneMatrix : { value: function() { return this._planeMat.slice(0); }},
109 110
110 setPlanarHit : { value: function(p) { this._planarHit = p; }}, 111 setPlanarHit : { value: function(p) { this._planarHit = p; }},
111 isPlanarHit : { value: function() { return this._planarHit; }}, 112 isPlanarHit : { value: function() { return this._planarHit; }},
112 113
113 getSnapBoundaryIndex : { value: function() { return this._snapBoundaryIndex; }}, 114 getSnapBoundaryIndex : { value: function() { return this._snapBoundaryIndex; }},
114 setSnapBoundaryIndex : { value: function(i) { this._snapBoundaryIndex = i; }}, 115 setSnapBoundaryIndex : { value: function(i) { this._snapBoundaryIndex = i; }},
115 116
116 getType : { value: function() { return this._type; }}, 117 getType : { value: function() { return this._type; }},
117 setType : { value: function(t) {this._type = t; if (!this.checkType()) { throw new Error("invalid snap type"); return; } }}, 118 setType : { value: function(t) {this._type = t; if (!this.checkType()) { throw new Error("invalid snap type"); return; } }},
118 119
119 getUseQuadPoint : { value: function() { return this._isQuadPt; }}, 120 getUseQuadPoint : { value: function() { return this._isQuadPt; }},
120 setUseQuadPoint : { value: function(q) {this._isQuadPt = q; }}, 121 setUseQuadPoint : { value: function(q) {this._isQuadPt = q; }},
121 122
122 /////////////////////////////////////////////////////////////////////// 123 ///////////////////////////////////////////////////////////////////////
123 // Methods 124 // Methods
124 /////////////////////////////////////////////////////////////////////// 125 ///////////////////////////////////////////////////////////////////////
125 126
126 checkType :{ 127 checkType :{
127 value: function() { 128 value: function() {
128 var ok = false; 129 var ok = false;
129 switch (this._type) 130 switch (this._type)
130 { 131 {
@@ -161,7 +162,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
161 } 162 }
162 }, 163 },
163 164
164 isSomeGridTypeSnap : { 165 isSomeGridTypeSnap : {
165 value: function() { 166 value: function() {
166 return ((this._type == this.SNAP_TYPE_GRID_VERTEX) || 167 return ((this._type == this.SNAP_TYPE_GRID_VERTEX) ||
167 (this._type == this.SNAP_TYPE_GRID_HORIZONTAL) || 168 (this._type == this.SNAP_TYPE_GRID_HORIZONTAL) ||
@@ -170,7 +171,7 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
170 } 171 }
171 }, 172 },