diff options
author | hwc487 | 2012-04-19 13:01:43 -0700 |
---|---|---|
committer | hwc487 | 2012-04-19 13:01:43 -0700 |
commit | e6a20fe64574763483dc602bd759278ccf5e5e68 (patch) | |
tree | 69defe7200206f0257fe90697136fadef59d521e /js/helper-classes/3D | |
parent | ae7eb87564632ce7c676bd728b8ff2710ff0bb83 (diff) | |
parent | 9284c19f076dec3b47ece7dc7bcd22d74e4246c3 (diff) | |
download | ninja-e6a20fe64574763483dc602bd759278ccf5e5e68.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Conflicts:
js/lib/drawing/world.js
js/lib/geom/geom-obj.js
js/lib/rdge/materials/cloud-material.js
js/lib/rdge/materials/deform-material.js
js/lib/rdge/materials/flat-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/relief-tunnel-material.js
js/lib/rdge/materials/square-tunnel-material.js
js/lib/rdge/materials/star-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/tunnel-material.js
js/lib/rdge/materials/twist-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/uber-material.js
js/lib/rdge/materials/water-material.js
js/lib/rdge/materials/z-invert-material.js
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 129 | ||||
-rwxr-xr-x | js/helper-classes/3D/hit-record.js | 10 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 44 | ||||
-rwxr-xr-x | js/helper-classes/3D/vec-utils.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 270 |
5 files changed, 279 insertions, 176 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index d6334e6c..ec8eea0f 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -109,10 +109,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
109 | this._gridOrigin = [0,0]; // 2D plane space point | 109 | this._gridOrigin = [0,0]; // 2D plane space point |
110 | 110 | ||
111 | this.eventManager.addEventListener("elementAdded", this, false); | 111 | this.eventManager.addEventListener("elementAdded", this, false); |
112 | this.eventManager.addEventListener("elementDeleted", this, false); | 112 | this.eventManager.addEventListener("elementsRemoved", this, false); |
113 | this.eventManager.addEventListener("deleteSelection", this, false); | ||
114 | this.eventManager.addEventListener("elementChange", this, false); | 113 | this.eventManager.addEventListener("elementChange", this, false); |
114 | this.eventManager.addEventListener("elementChanging", this, false); | ||
115 | this.eventManager.addEventListener("closeDocument", this, false); | 115 | this.eventManager.addEventListener("closeDocument", this, false); |
116 | this.eventManager.addEventListener("elementReplaced", this, false); | ||
116 | } | 117 | } |
117 | }, | 118 | }, |
118 | 119 | ||
@@ -147,38 +148,75 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
147 | 148 | ||
148 | handleElementAdded: { | 149 | handleElementAdded: { |
149 | value: function(event) { | 150 | value: function(event) { |
150 | this.addElement(event.detail); | 151 | var elements = event.detail; |
152 | |||
153 | if(Array.isArray(elements)) { | ||
154 | elements.forEach(function(element) { | ||
155 | this.addElement(element); | ||
156 | }, this); | ||
157 | } else { | ||
158 | this.addElement(elements); | ||
159 | } | ||
160 | |||
151 | this.drawWorkingPlane(); | 161 | this.drawWorkingPlane(); |
152 | } | 162 | } |
153 | }, | 163 | }, |
154 | 164 | ||
155 | handleElementDeleted: { | 165 | handleElementsRemoved: { |
156 | value: function(event) { | 166 | value: function(event) { |
157 | this.removeElement(event.detail); | 167 | var elements = event.detail; |
168 | |||
169 | if(Array.isArray(elements)) { | ||
170 | elements = Array.prototype.slice.call(elements, 0); | ||
171 | elements.forEach(function(element) { | ||
172 | this.removeElement(element); | ||
173 | }, this); | ||
174 | } else { | ||
175 | this.removeElement(elements); | ||
176 | } | ||
177 | |||
178 | this.drawWorkingPlane(); | ||
158 | } | 179 | } |
159 | }, | 180 | }, |
160 | 181 | ||
161 | handleDeleteSelection: { | 182 | handleElementReplaced: { |
162 | value: function(event) { | 183 | value: function(event) { |
163 | this.drawWorkingPlane(); | 184 | var oldElement = event.detail.data.oldChild; |
185 | var newElement = event.detail.data.newChild; | ||
186 | |||
187 | // check if we already know about this object | ||
188 | var n = this._eltArray.length, | ||
189 | plane; | ||
190 | for (var i=0; i<n; i++) { | ||
191 | if (oldElement === this._eltArray[i]) { | ||
192 | this._eltArray[i] = newElement; | ||
193 | plane = this._planesArray[i]; | ||
194 | break; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | if(!plane) { | ||
199 | this._eltArray.push( newElement ); | ||
200 | plane = Object.create(this.ElementPlanes, {}); | ||
201 | this._planesArray.push( plane ); | ||
202 | } | ||
203 | |||
204 | plane.setElement( newElement ); | ||
205 | plane.init(); | ||
206 | newElement.elementModel.props3D.elementPlane = plane; | ||
164 | } | 207 | } |
165 | }, | 208 | }, |
166 | 209 | ||
167 | _shouldUpdatePlanes: { | 210 | _shouldUpdatePlanes: { |
168 | value: function(props) { | 211 | value: function(props) { |
169 | if(!props) | 212 | if(!props) { |
170 | { | ||
171 | return false; | 213 | return false; |
172 | } | 214 | } else if (typeof props === "string") { |
173 | else if (typeof props === "string") | ||
174 | { | ||
175 | return (this._updatePlaneProps.indexOf(props) !== -1); | 215 | return (this._updatePlaneProps.indexOf(props) !== -1); |
176 | } | 216 | } |
177 | 217 | ||
178 | for (var p in props) | 218 | for (var p in props) { |
179 | { | 219 | if(this._updatePlaneProps.indexOf(p) !== -1) { |
180 | if(this._updatePlaneProps.indexOf(p) !== -1) | ||
181 | { | ||
182 | return true; | 220 | return true; |
183 | } | 221 | } |
184 | } | 222 | } |
@@ -190,24 +228,27 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
190 | // TODO - Check why handleElementChange is being fired before handleAddElement | 228 | // TODO - Check why handleElementChange is being fired before handleAddElement |
191 | handleElementChange: { | 229 | handleElementChange: { |
192 | value: function(event) { | 230 | value: function(event) { |
193 | if(!event.detail || !event.detail.data) | 231 | this._elementChangeHelper(event); |
194 | { | 232 | } |
233 | }, | ||
234 | |||
235 | handleElementChanging: { | ||
236 | value: function(event) { | ||
237 | this._elementChangeHelper(event); | ||
238 | } | ||
239 | }, | ||
240 | |||
241 | _elementChangeHelper: { | ||
242 | value: function(event) { | ||
243 | if(!event.detail || !event.detail.data) { | ||
195 | return; | 244 | return; |
196 | } | 245 | } |
197 | var els = event.detail.data.els; | 246 | var els = event.detail.data.els; |
198 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) | 247 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) { |
199 | { | 248 | var len = els.length; |
200 | var len = els.length, | 249 | for(var i=0; i < len; i++) { |
201 | i = 0, | 250 | if(els[i].elementModel.props3D.elementPlane) { |
202 | item, | 251 | els[i].elementModel.props3D.elementPlane.init(); |
203 | el; | ||
204 | |||
205 | for(i=0; i < len; i++) { | ||
206 | item = els[i]; | ||
207 | el = item._element || item; | ||
208 | if(el.elementModel.props3D.elementPlane) | ||
209 | { | ||
210 | el.elementModel.props3D.elementPlane.init(); | ||
211 | } | 252 | } |
212 | } | 253 | } |
213 | 254 | ||
@@ -222,17 +263,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
222 | // Methods | 263 | // Methods |
223 | /////////////////////////////////////////////////////////////////////// | 264 | /////////////////////////////////////////////////////////////////////// |
224 | 265 | ||
225 | addElement: | 266 | addElement: { |
226 | { | 267 | value: function( elt ) { |
227 | value: function( elt ) | ||
228 | { | ||
229 | // check if we already know about this object | 268 | // check if we already know about this object |
230 | var n = this._eltArray.length; | 269 | var n = this._eltArray.length; |
231 | for (var i=0; i<n; i++) | 270 | for (var i=0; i<n; i++) { |
232 | { | 271 | if (elt == this._eltArray[i]) { |
233 | if (elt == this._eltArray[i]) | ||
234 | { | ||
235 | // console.log( "element already added to stage display: " + elt.id ); | ||
236 | return; | 272 | return; |
237 | } | 273 | } |
238 | } | 274 | } |
@@ -248,17 +284,14 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
248 | } | 284 | } |
249 | }, | 285 | }, |
250 | 286 | ||
251 | removeElement : { | 287 | removeElement: { |
252 | value: function( elt ) { | 288 | value: function(element) { |
253 | // check if object exists | 289 | // check if object exists |
254 | var n = this._eltArray.length; | 290 | var _elements = this._eltArray.length; |
255 | for (var i=0; i<n; i++) | 291 | for (var i=0; i < _elements; i++) { |
256 | { | 292 | if (element === this._eltArray[i]) { |
257 | if (elt == this._eltArray[i]) | ||
258 | { | ||
259 | // First remove the planes for this element | 293 | // First remove the planes for this element |
260 | this._planesArray.splice(i, 1); | 294 | this._planesArray.splice(i, 1); |
261 | |||
262 | // Then remove the element | 295 | // Then remove the element |
263 | this._eltArray.splice(i, 1); | 296 | this._eltArray.splice(i, 1); |
264 | 297 | ||
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(); |