aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-02-09 15:02:51 -0800
committerJose Antonio Marquez2012-02-09 15:02:51 -0800
commit67a5b6a1fb352bdc69ff05297268c27e7e2ba795 (patch)
tree8483701ec4d16143a2517b82a8148a7c5a456b0c /js
parent74efc1238f51e9c0ffdeffe2a349f66011ef9f17 (diff)
parent666ae3e9119410cbf7fa974274d95336aaff091c (diff)
downloadninja-67a5b6a1fb352bdc69ff05297268c27e7e2ba795.tar.gz
Merge branch 'refs/heads/NinjaInternal' into FileIO
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/elements/shapes-controller.js25
-rwxr-xr-xjs/helper-classes/3D/math-utils.js97
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js17
-rwxr-xr-xjs/helper-classes/RDGE/GLLine.js29
-rwxr-xr-xjs/helper-classes/RDGE/GLMaterial.js2
-rwxr-xr-xjs/helper-classes/RDGE/GLRectangle.js141
-rwxr-xr-xjs/helper-classes/RDGE/Materials/BumpMetalMaterial.js10
-rwxr-xr-xjs/helper-classes/RDGE/Materials/FlatMaterial.js31
-rwxr-xr-xjs/helper-classes/RDGE/Materials/UberMaterial.js6
-rwxr-xr-xjs/helper-classes/RDGE/MaterialsLibrary.js2
-rwxr-xr-xjs/panels/properties/sections/three-d-view.reel/three-d-view.html12
-rwxr-xr-xjs/tools/Rotate3DToolBase.js2
-rwxr-xr-xjs/tools/RotateStage3DTool.js2
-rwxr-xr-xjs/tools/SelectionTool.js40
-rwxr-xr-xjs/tools/modifier-tool-base.js35
15 files changed, 299 insertions, 152 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index e764de4e..b9c033aa 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -63,11 +63,11 @@ exports.ShapesController = Montage.create(CanvasController, {
63 canvas.height = el.height; 63 canvas.height = el.height;
64 this.application.ninja.elementMediator.replaceElement(el, canvas); 64 this.application.ninja.elementMediator.replaceElement(el, canvas);
65 NJevent("elementDeleted", el); 65 NJevent("elementDeleted", el);
66 this.application.ninja.selectionController.selectElement(canvas);
67 el = canvas; 66 el = canvas;
68 this.toggleWebGlMode(el, value); 67 this.toggleWebGlMode(el, value);
69 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 68 el.elementModel.shapeModel.GLWorld.render();
70 break; 69 this.application.ninja.selectionController.selectElement(el);
70 return;
71 case "strokeMaterial": 71 case "strokeMaterial":
72 var sm = Object.create(MaterialsLibrary.getMaterial(value)); 72 var sm = Object.create(MaterialsLibrary.getMaterial(value));
73 if(sm) 73 if(sm)
@@ -338,13 +338,26 @@ exports.ShapesController = Montage.create(CanvasController, {
338 { 338 {
339 return; 339 return;
340 } 340 }
341 var world, 341 var sm,
342 fm,
343 world,
342 worldData = el.elementModel.shapeModel.GLWorld.export(); 344 worldData = el.elementModel.shapeModel.GLWorld.export();
343 if(worldData) 345 if(worldData)
344 { 346 {
345 world = new GLWorld(el, true); 347 world = new GLWorld(el, true);
346 el.elementModel.shapeModel.GLWorld = world; 348 el.elementModel.shapeModel.GLWorld = world;
349 el.elementModel.shapeModel.GLGeomObj.setWorld(world);
347 el.elementModel.shapeModel.useWebGl = true; 350 el.elementModel.shapeModel.useWebGl = true;
351 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
352 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
353 if(sm && fm)
354 {
355 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
356 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
357 el.elementModel.shapeModel.strokeMaterial = sm;
358 el.elementModel.shapeModel.fillMaterial = fm;
359 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
360 }
348 world.import(worldData); 361 world.import(worldData);
349 } 362 }
350 363
@@ -365,6 +378,10 @@ exports.ShapesController = Montage.create(CanvasController, {
365 world = new GLWorld(el, false); 378 world = new GLWorld(el, false);
366 el.elementModel.shapeModel.GLWorld = world; 379 el.elementModel.shapeModel.GLWorld = world;
367 el.elementModel.shapeModel.useWebGl = false; 380 el.elementModel.shapeModel.useWebGl = false;
381 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null);
382 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
383 el.elementModel.shapeModel.strokeMaterial = null;
384 el.elementModel.shapeModel.fillMaterial = null;
368 world.import(worldData); 385 world.import(worldData);
369 } 386 }
370 387
diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js
index 3d24f76e..37044763 100755
--- a/js/helper-classes/3D/math-utils.js
+++ b/js/helper-classes/3D/math-utils.js
@@ -8,7 +8,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
8// Class Utils 8// Class Utils
9// Math Utility functions 9// Math Utility functions
10/////////////////////////////////////////////////////////////////////// 10///////////////////////////////////////////////////////////////////////
11var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; 11var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils,
12 ViewUtils = require("js/helper-classes/3D/view-utils").ViewUtils,
13 Rectangle = require("js/helper-classes/3D/rectangle").Rectangle;
12 14
13var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { 15var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
14 /////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////
@@ -536,6 +538,99 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
536 } 538 }
537 }, 539 },
538 540
541 rectsOverlap:
542 {
543 value: function( pt, width, height, elt )
544 {
545 // only consider rectangles with non-zero area
546 if ((width == 0) || (height == 0)) return false;
547
548 // get the mins/maxs of the onput rectangle
549 var xMin, xMax, yMin, yMax;
550 if (width > 0) { xMin = pt[0]; xMax = pt[0] + width; }
551 else { xMax = pt[0]; xMin = pt[0] + width; }
552 if (height > 0) { yMin = pt[1]; yMax = pt[1] + height; }
553 else { yMax = pt[1]; yMin = pt[1] + height; }
554
555 // get the bounds of the element in global screen space
556 var bounds = ViewUtils.getElementViewBounds3D( elt );
557 var bounds3D = [];
558 for (var i=0; i<4; i++)
559 bounds3D[i] = ViewUtils.localToGlobal( bounds[i], elt );
560
561 // get the min/maxs for the element
562 var xMinElt = bounds3D[0][0], xMaxElt = bounds3D[0][0],
563 yMinElt = bounds3D[0][1], yMaxElt = bounds3D[0][1];
564 for (var i=1; i<4; i++)
565 {
566 if (bounds3D[i][0] < xMinElt) xMinElt = bounds3D[i][0];
567 else if (bounds3D[i][0] > xMaxElt) xMaxElt = bounds3D[i][0];
568 if (bounds3D[i][1] < yMinElt) yMinElt = bounds3D[i][1];
569 else if (bounds3D[i][1] > yMaxElt) yMaxElt = bounds3D[i][1];
570 }
571
572 // test 1. Overall bounding box test
573 if ((xMaxElt < xMin) || (xMinElt > xMax) || (yMaxElt < yMin) || (yMinElt > yMax))
574 return false;
575
576 // test 2. See if any of the corners of the element are contained in the rectangle
577 var rect = Object.create(Rectangle, {});
578 rect.set( pt[0], pt[1], width, height );
579 for (var i=0; i<4; i++)
580 {
581 if (rect.contains( bounds3D[i][0], bounds3D[i][1] )) return true;
582 }
583
584 // test 3. Bounding box tests on individual edges of the element
585 for (var i=0; i<4; i++)
586 {
587 var pt0 = bounds3D[i],
588 pt1 = bounds3D[(i+1)%4];
589
590 // get the extremes of the edge
591 if (pt0[0] < pt1[0]) { xMinElt = pt0[0]; xMaxElt = pt1[0]; }
592 else { xMaxElt = pt0[0]; xMinElt = pt1[0]; }
593 if (pt0[1] < pt1[1]) { yMinElt = pt0[1]; yMaxElt = pt1[1]; }
594 else { yMaxElt = pt0[1]; yMinElt = pt1[1]; }
595
596 if ((xMaxElt < xMin) || (xMinElt > xMax) || (yMaxElt < yMin) || (yMinElt > yMax))
597 continue;
598 else
599 {
600 // intersect the element edge with the 4 sides of the rectangle
601 // vertical edges
602 var xRect = xMin;
603 for (var j=0; j<2; j++)
604 {
605 if ((xMinElt < xRect) && (xMaxElt > xRect))
606 {
607 var t = (xRect - pt0[0])/(pt1[0] - pt0[0]);
608 var y = pt0[1] + t*(pt1[1] - pt0[1]);
609 if ((y >= yMin) && (y <= yMax)) return true;
610 }
611 xRect = xMax;
612 }
613
614 // horizontal edges
615 var yRect = yMin;
616 for (var j=0; j<2; j++)
617 {
618 if ((yMinElt < yRect) && (yMaxElt > yRect))
619 {
620 var t = (yRect - pt0[1])/(pt1[1] - pt0[1]);
621 var x = pt0[0] + t*(pt1[0] - pt0[0]);
622 if ((x >= xMin) && (x <= xMax)) return true;
623 }
624 yRect = yMax;
625 }
626 }
627 }
628
629 // if we get here there is no overlap
630 return false;
631 }
632 },
633
539 /////////////////////////////////////////////////////////////////////// 634 ///////////////////////////////////////////////////////////////////////
540 // Bezier Methods 635 // Bezier Methods
541 /////////////////////////////////////////////////////////////////////// 636 ///////////////////////////////////////////////////////////////////////
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 3af7d8cf..0a950658 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -970,13 +970,12 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
970 value: function( screenPt, hitRecs ) { 970 value: function( screenPt, hitRecs ) {
971 // start at the stage. 971 // start at the stage.
972 var stage = this.getStage();