diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/document-controller.js | 2 | ||||
-rwxr-xr-x | js/document/document-html.js | 5 | ||||
-rwxr-xr-x | js/document/html-document.js | 4 | ||||
-rwxr-xr-x | js/document/models/html.js | 5 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 146 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 13 | ||||
-rwxr-xr-x | js/lib/geom/circle.js | 124 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 190 | ||||
-rw-r--r-- | js/lib/geom/shape-primitive.js | 27 | ||||
-rwxr-xr-x | js/lib/rdge/materials/linear-gradient-material.js | 36 | ||||
-rwxr-xr-x | js/lib/rdge/materials/material.js | 4 | ||||
-rwxr-xr-x | js/lib/rdge/materials/radial-gradient-material.js | 70 | ||||
-rwxr-xr-x | js/ninja.reel/ninja.js | 2 | ||||
-rwxr-xr-x | js/panels/properties.reel/properties.js | 32 | ||||
-rwxr-xr-x | js/panels/properties.reel/sections/custom.reel/custom.js | 2 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 27 |
16 files changed, 389 insertions, 300 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 2eba556e..9ca5ea99 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -501,7 +501,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
501 | if(currentDocument) { | 501 | if(currentDocument) { |
502 | if(currentDocument.currentView === "design") { | 502 | if(currentDocument.currentView === "design") { |
503 | currentDocument.serializeDocument(); | 503 | currentDocument.serializeDocument(); |
504 | this.application.ninja.selectionController._selectionContainer = null; | 504 | this.application.ninja._currentSelectedContainer = this.application.ninja.selectionController._selectionContainer = null; |
505 | currentDocument.model.views.design.propertiesPanel.clear(); | 505 | currentDocument.model.views.design.propertiesPanel.clear(); |
506 | } | 506 | } |
507 | 507 | ||
diff --git a/js/document/document-html.js b/js/document/document-html.js index d6b4ba95..f92a425c 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -147,9 +147,10 @@ exports.HtmlDocument = Montage.create(Component, { | |||
147 | this.model.userContentTop = this.application.ninja.stage._userContentTop; | 147 | this.model.userContentTop = this.application.ninja.stage._userContentTop; |
148 | 148 | ||
149 | 149 | ||
150 | // Serialize the selection | 150 | // Serialize the selection, the container and grid |
151 | //TODO: Move this property to the design view class | 151 | //TODO: Move this property to the design view class |
152 | this.model.selection = this.application.ninja.selectedElements.slice(0); | 152 | this.model.selection = this.application.ninja.selectedElements.slice(0); |
153 | this.model.selectionContainer = this.application.ninja.currentSelectedContainer; | ||
153 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; | 154 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; |
154 | 155 | ||
155 | // Serialize the undo | 156 | // Serialize the undo |
@@ -177,7 +178,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
177 | 178 | ||
178 | //TODO: Move this property to the design view class | 179 | //TODO: Move this property to the design view class |
179 | this.application.ninja.selectedElements = this.model.selection.slice(0); | 180 | this.application.ninja.selectedElements = this.model.selection.slice(0); |
180 | 181 | // this.application.ninja.currentSelectedContainer = this.model.selectionContainer; | |
181 | this.application.ninja.appModel.show3dGrid = this.draw3DGrid; | 182 | this.application.ninja.appModel.show3dGrid = this.draw3DGrid; |
182 | 183 | ||
183 | // Serialize the undo | 184 | // Serialize the undo |
diff --git a/js/document/html-document.js b/js/document/html-document.js index bcf2b5c2..447d90e3 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -209,8 +209,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
209 | { | 209 | { |
210 | /* | 210 | /* |
211 | // Use this code to test the runtime version of WebGL | 211 | // Use this code to test the runtime version of WebGL |
212 | var cdm = new NinjaCvsRt.CanvasDataManager(); | 212 | var cvsDataMngr = Object.create(NinjaCvsRt.CanvasDataManager, {}); |
213 | cdm.loadGLData(elt, value, null ); | 213 | cvsDataMngr.loadGLData(elt, value); |
214 | */ | 214 | */ |
215 | 215 | ||
216 | // /* | 216 | // /* |
diff --git a/js/document/models/html.js b/js/document/models/html.js index a97b4b5a..9cc8ce92 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js | |||
@@ -22,6 +22,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { | |||
22 | selection: { | 22 | selection: { |
23 | value: [] | 23 | value: [] |
24 | }, | 24 | }, |
25 | //////////////////////////////////////////////////////////////////// | ||
26 | // | ||
27 | selectionContainer: { | ||
28 | value: [] | ||
29 | }, | ||
25 | //////////////////////////////////////////////////////////////////// | 30 | //////////////////////////////////////////////////////////////////// |
26 | // | 31 | // |
27 | draw3DGrid: { | 32 | draw3DGrid: { |
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index e22ac3ad..0f456e1e 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -223,64 +223,22 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
223 | else | 223 | else |
224 | parentPt = [xScreen, yScreen, 0.0]; | 224 | parentPt = [xScreen, yScreen, 0.0]; |
225 | 225 | ||
226 | var eyePt = []; | 226 | if (!snap3D && this._hasDragPlane) |
227 | var vec = viewUtils.parentToChildVec(parentPt, stage, eyePt); | 227 | this.activateDragPlane(); |
228 | if (vec) | 228 | |
229 | { | 229 | var hitRec = this.snapToStage( parentPt, quadPt ); |
230 | // activate the drag working plane | 230 | |
231 | if (!snap3D && this.hasDragPlane()) | 231 | // try snapping to the 3D grid, or to the stage boundaries if the grid is not displayed |
232 | this.activateDragPlane(); | 232 | if (this.gridSnapEnabled()) |
233 | 233 | this.snapToGrid( hitRec ); | |
234 | // project to the working plane | 234 | |
235 | var currentWorkingPlane = workingPlane.slice(0); | 235 | // save the hit record |
236 | var wp = currentWorkingPlane.slice(0); | 236 | hitRecArray.push( hitRec ); |
237 | var mat = viewUtils.getMatrixFromElement(stage); | 237 | |
238 | wp = MathUtils.transformPlane(wp, mat); | 238 | // restore the original working plane |
239 | var projPt = MathUtils.vecIntersectPlane(eyePt, vec, wp); | 239 | if (!snap3D && this.hasDragPlane()) |
240 | if (projPt) | 240 | this.deactivateDragPlane(); |
241 | { | 241 | |
242 | // the local point gets stored in the coordinate space of the plane | ||
243 | var wpMat = drawUtils.getPlaneToWorldMatrix(currentWorkingPlane, MathUtils.getPointOnPlane(currentWorkingPlane)); | ||
244 | projPt[3] = 1.0; | ||
245 | //var planeToViewMat = mat.multiply(wpMat); | ||
246 | var planeToViewMat = glmat4.multiply(mat, wpMat, []); | ||
247 | //var viewToPlaneMat = planeToViewMat.inverse(); | ||
248 | var viewToPlaneMat = glmat4.inverse( planeToViewMat, [] ); | ||
249 | var planePt = projPt.slice(0); | ||
250 | planePt[3] = 1.0; | ||
251 | //planePt = viewToPlaneMat.multiply(planePt); | ||
252 | planePt = glmat4.multiplyVec3( viewToPlaneMat, planePt ); | ||
253 | |||
254 | // get the screen position of the projected point | ||
255 | viewUtils.setViewportObj(stage); | ||
256 | var offset = viewUtils.getElementOffset(stage); | ||
257 | offset[2] = 0; | ||
258 | var scrPt = viewUtils.viewToScreen(projPt); | ||
259 | //scrPt = scrPt.add(offset); | ||
260 | scrPt = vecUtils.vecAdd(3, scrPt, offset); | ||
261 | |||
262 | // create the hit record | ||
263 | var hitRec = Object.create(HitRecord);//new HitRecord(); | ||
264 | hitRec.setLocalPoint(planePt); | ||
265 | hitRec.setPlaneMatrix( wpMat ); | ||
266 | hitRec.setScreenPoint(scrPt); | ||
267 | hitRec.setPlane(currentWorkingPlane); | ||
268 | hitRec.setType( hitRec.SNAP_TYPE_STAGE ); | ||
269 | hitRec.setElt( stage ); | ||
270 | if (quadPt) hitRec.setUseQuadPoint( true ); | ||
271 | |||
272 | // try snapping to the 3D grid, or to the stage boundaries if the grid is not displayed | ||
273 | if (this.gridSnapEnabled()) | ||
274 | this.snapToGrid( hitRec ); | ||
275 | |||
276 | // save the hit record | ||
277 | hitRecArray.push( hitRec ); | ||
278 | |||
279 | // restore the original working plane | ||
280 | if (!snap3D && this.hasDragPlane()) | ||
281 | this.deactivateDragPlane(); | ||
282 | } | ||
283 | } | ||
284 | } //if (hitRecArray.length == 0) | 242 | } //if (hitRecArray.length == 0) |
285 | 243 | ||
286 | var rtnHit; | 244 | var rtnHit; |
@@ -305,6 +263,62 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
305 | } | 263 | } |
306 | }, | 264 | }, |
307 | 265 | ||
266 | snapToStage: | ||
267 | { | ||
268 | value: function( scrPt, quadPt ) | ||
269 | { | ||
270 | var stage = this.getStage(); | ||
271 | var l2g = viewUtils.getLocalToGlobalMatrix( stage ); | ||
272 | var g2l = glmat4.inverse( l2g, [] ); | ||
273 | |||
274 | var pt0 = scrPt.slice(), pt1 = scrPt.slice(); | ||
275 | pt0[2] = 0.0; pt1[2] = 10; | ||
276 | |||
277 | var localPt0 = MathUtils.transformAndDivideHomogeneousPoint( pt0, g2l ), | ||
278 | localPt1 = MathUtils.transformAndDivideHomogeneousPoint( pt1, g2l ); | ||
279 | |||
280 | var stageWorldPt0 = viewUtils.localToStageWorld( localPt0, stage ), | ||
281 | stageWorldPt1 = viewUtils.localToStageWorld( localPt1, stage ); | ||
282 | var vec = vecUtils.vecSubtract( 3, stageWorldPt1, stageWorldPt0 ); | ||
283 | |||
284 | var ptOnWorkingPlane = MathUtils.vecIntersectPlane(stageWorldPt0, vec, workingPlane); | ||
285 | |||
286 | var wpMat = drawUtils.getPlaneToWorldMatrix(workingPlane, MathUtils.getPointOnPlane(workingPlane)), | ||
287 | wpMatInv = glmat4.inverse( wpMat, [] ); | ||
288 | var localPt = MathUtils.transformPoint( ptOnWorkingPlane, wpMatInv ); | ||
289 | |||
290 | // create the hit record | ||
291 | var hitRec = Object.create(HitRecord); | ||
292 | hitRec.setLocalPoint( localPt ); | ||
293 | hitRec.setPlaneMatrix( wpMat ); | ||
294 | hitRec.setScreenPoint(scrPt); | ||
295 | hitRec.setPlane(workingPlane); | ||
296 | hitRec.setType( hitRec.SNAP_TYPE_STAGE ); | ||