aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
authorEric Guzman2012-02-29 16:13:19 -0800
committerEric Guzman2012-02-29 16:13:19 -0800
commit53bdb1e7773069c4cca59e88d6da91cd0f58c94a (patch)
tree44a2147fcbb43ea483f78a1e2e082919f9c81970 /js/helper-classes
parentb2c60efb9c6f5dfa7b0fc5c2b9feebebc805ed97 (diff)
parentb09956e4a9a35c5588cc7cd1f01efb617cbe0884 (diff)
downloadninja-53bdb1e7773069c4cca59e88d6da91cd0f58c94a.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Conflicts: js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js20
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js10
-rwxr-xr-xjs/helper-classes/3D/view-utils.js11
-rwxr-xr-xjs/helper-classes/RDGE/GLAnchorPoint.js7
-rwxr-xr-xjs/helper-classes/RDGE/GLBrushStroke.js175
-rwxr-xr-xjs/helper-classes/RDGE/GLCircle.js142
-rwxr-xr-xjs/helper-classes/RDGE/GLGeomObj.js4
-rwxr-xr-xjs/helper-classes/RDGE/GLLine.js69
-rwxr-xr-xjs/helper-classes/RDGE/GLRectangle.js83
-rwxr-xr-xjs/helper-classes/RDGE/GLSubpath.js66
-rwxr-xr-xjs/helper-classes/RDGE/GLWorld.js29
-rwxr-xr-xjs/helper-classes/RDGE/rdge-compiled.js28
-rw-r--r--js/helper-classes/RDGE/runtime/CanvasDataManager.js98
-rw-r--r--js/helper-classes/RDGE/runtime/GLRuntime.js159
-rw-r--r--js/helper-classes/RDGE/src/tools/rdge-compiled.js28
15 files changed, 711 insertions, 218 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index c07391db..85870097 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -115,6 +115,26 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
115 } 115 }
116 }, 116 },
117 117
118 initializeFromDocument:{
119 value:function(){
120 var documentRootChildren = null, i;
121 //initialize with current document
122 this._eltArray = [];
123 this._planesArray = [];
124 this.setDrawingSurfaceElement(this.application.ninja.stage.canvas);
125 this.setSourceSpaceElement( this.application.ninja.stage.stageDeps.currentStage );
126 this.setWorkingPlane( Vector.create( [0,0,1,0] ) );
127
128 //Loop through all the top-level children of the current document and call drawUtils.addElement on them
129 if(this.application.ninja.currentDocument._liveNodeList.length > 0){
130 documentRootChildren = this.application.ninja.currentDocument._liveNodeList;
131 for(i=0;i<documentRootChildren.length;i++){
132 this.addElement(documentRootChildren[i]);
133 }
134 }
135 }
136 },
137
118 handleElementAdded: { 138 handleElementAdded: {
119 value: function(event) { 139 value: function(event) {
120 this.addElement(event.detail); 140 this.addElement(event.detail);
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index ada6960b..372be345 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -521,7 +521,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
521 521
522 if (!elt.elementModel) 522 if (!elt.elementModel)
523 { 523 {
524 NJUtils.makeElementModel2(elt); 524 NJUtils.makeModelFromElement(elt);
525 } 525 }
526 elt.elementModel.isIn2DSnapCache = true; 526 elt.elementModel.isIn2DSnapCache = true;
527 } 527 }
@@ -588,7 +588,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
588 588
589 if (!elt.elementModel) 589 if (!elt.elementModel)
590 { 590 {
591 NJUtils.makeElementModel2(elt); 591 NJUtils.makeModelFromElement(elt);
592 } 592 }
593 elt.elementModel.isIn2DSnapCache = true; 593 elt.elementModel.isIn2DSnapCache = true;
594 } 594 }
@@ -597,7 +597,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
597 } 597 }
598 598
599 // TODO - Don't traverse components' children 599 // TODO - Don't traverse components' children
600 if(elt.elementModel && elt.elementModel.isComponent) 600// if(elt.elementModel && elt.elementModel.isComponent)
601 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG"))))
601 { 602 {
602 return; 603 return;
603 } 604 }
@@ -1007,7 +1008,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1007 } 1008 }
1008 1009
1009 // TODO - Don't traverse components' children 1010 // TODO - Don't traverse components' children
1010 if(elt.elementModel && elt.elementModel.isComponent) 1011// if(elt.elementModel && elt.elementModel.isComponent)
1012 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG"))))
1011 { 1013 {
1012 return; 1014 return;
1013 } 1015 }
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index a2fac34f..c1f59397 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -580,7 +580,8 @@ exports.ViewUtils = Montage.create(Component, {
580 if (elt.style.height) h = MathUtils.styleToNumber(elt.style.height); 580 if (elt.style.height) h = MathUtils.styleToNumber(elt.style.height);
581 } 581 }
582 582
583 if (elt instanceof SVGSVGElement) { 583// if (elt instanceof SVGSVGElement) {
584 if(elt.nodeName.toLowerCase() === "svg") {
584 if(w instanceof SVGAnimatedLength) 585 if(w instanceof SVGAnimatedLength)
585 w = w.animVal.value; 586 w = w.animVal.value;
586 if(h instanceof SVGAnimatedLength) 587 if(h instanceof SVGAnimatedLength)
@@ -1226,6 +1227,14 @@ exports.ViewUtils = Montage.create(Component, {
1226 } 1227 }
1227 }, 1228 },
1228 1229
1230 getCurrentDocument:
1231 {
1232 value: function()
1233 {
1234 return snapManagerModule.SnapManager.application.ninja.currentDocument;
1235 }
1236 },
1237
1229 setStageZoom: { 1238 setStageZoom: {
1230 value:function( globalPt, zoomFactor ) { 1239 value:function( globalPt, zoomFactor ) {
1231 var localPt; 1240 var localPt;
diff --git a/js/helper-classes/RDGE/GLAnchorPoint.js b/js/helper-classes/RDGE/GLAnchorPoint.js
index 716f59d4..c3e95b34 100755
--- a/js/helper-classes/RDGE/GLAnchorPoint.js
+++ b/js/helper-classes/RDGE/GLAnchorPoint.js
@@ -133,6 +133,13 @@ GLAnchorPoint.prototype.translateAll = function (x, y, z) {
133} 133}
134 134
135 135
136GLAnchorPoint.prototype.scaleAll = function(sx,sy,sz){
137 this._x *= sx;this._prevX *= sx;this._nextX *= sx;
138 this._y *= sy;this._prevY *= sy;this._nextY *= sy;
139 this._z *= sz;this._prevZ *= sz;this._nextZ *= sz;
140}
141
142
136// ********* getters ********** 143// ********* getters **********
137GLAnchorPoint.prototype.getPosX = function () { return this._x; } 144GLAnchorPoint.prototype.getPosX = function () { return this._x; }
138GLAnchorPoint.prototype.getPosY = function () { return this._y; } 145GLAnchorPoint.prototype.getPosY = function () { return this._y; }
diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js
index fdf1595c..5d773c2d 100755
--- a/js/helper-classes/RDGE/GLBrushStroke.js
+++ b/js/helper-classes/RDGE/GLBrushStroke.js
@@ -34,6 +34,13 @@ function GLBrushStroke() {
34 this._strokeMaterial; 34 this._strokeMaterial;
35 this._strokeStyle = "Solid"; 35 this._strokeStyle = "Solid";
36 36
37 //the wetness of the brush (currently this is multiplied to the square of the stroke width, but todo should be changed to not depend on stroke width entirely
38 //smaller value means more samples for the path
39 this._WETNESS_FACTOR = 0.25;
40
41 //prevent extremely long paths that can take a long time to render
42 this._MAX_ALLOWED_SAMPLES = 500;
43
37 //drawing context 44 //drawing context
38 this._world = null; 45 this._world = null;
39 46
@@ -67,7 +74,25 @@ function GLBrushStroke() {
67 74
68 this.getNumPoints = function () { return this._Points.length; } 75 this.getNumPoints = function () { return this._Points.length; }
69 this.getPoint = function (index) { return this._Points[index]; } 76 this.getPoint = function (index) { return this._Points[index]; }
70 this.addPoint = function (anchorPt) { this._Points.push(anchorPt); this._dirty=true; } 77 this.addPoint = function (pt)
78 {
79 //add the point only if it is some epsilon away from the previous point
80 var numPoints = this._Points.length;
81 if (numPoints>0) {
82 var threshold = this._WETNESS_FACTOR*this._strokeWidth;
83 var prevPt = this._Points[numPoints-1];
84 var diffPt = [prevPt[0]-pt[0], prevPt[1]-pt[1]];
85 var diffPtMag = Math.sqrt(diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]);
86 if (diffPtMag>threshold){
87 this._Points.push(pt);
88 this._dirty=true;
89 }
90 }else{
91 this._Points.push(pt);
92 this._dirty=true;
93 }
94 }
95
71 this.insertPoint = function(pt, index){ this._Points.splice(index, 0, pt); this._dirty=true;} 96 this.insertPoint = function(pt, index){ this._Points.splice(index, 0, pt); this._dirty=true;}
72 this.isDirty = function(){return this._dirty;} 97 this.isDirty = function(){return this._dirty;}
73 this.makeDirty = function(){this._dirty=true;} 98 this.makeDirty = function(){this._dirty=true;}
@@ -111,10 +136,45 @@ function GLBrushStroke() {
111 136
112 this.computeMetaGeometry = function(){ 137 this.computeMetaGeometry = function(){
113 if (this._dirty){ 138 if (this._dirty){
139 var numPoints = this._Points.length;
140
141 //**** add samples to the path if needed...linear interpolation for now
142 if (numPoints>1) {
143 var threshold = this._WETNESS_FACTOR*this._strokeWidth;
144 var prevPt = this._Points[0];
145 var prevIndex = 0;
146 for (var i=1;i<numPoints;i++){
147 var pt = this._Points[i];
148 var diff = [pt[0]-prevPt[0], pt[1]-prevPt[1]];
149 var distance = Math.sqrt(diff[0]*diff[0]+diff[1]*diff[1]);
150 if (distance>thresho