diff options
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 102 | ||||
-rwxr-xr-x | js/helper-classes/3D/math-utils.js | 4 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 32 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/rdge-compiled.js | 12 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/runtime.js | 6 |
5 files changed, 113 insertions, 43 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 5d210d41..9c4f31b7 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -654,6 +654,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
654 | value: function () | 654 | value: function () |
655 | { | 655 | { |
656 | this.application.ninja.stage.clearGridCanvas(); | 656 | this.application.ninja.stage.clearGridCanvas(); |
657 | this.drawStageOutline(); | ||
657 | if (!this.isDrawingGrid()) return; | 658 | if (!this.isDrawingGrid()) return; |
658 | 659 | ||
659 | var saveContext = this.getDrawingSurfaceElement(); | 660 | var saveContext = this.getDrawingSurfaceElement(); |
@@ -725,21 +726,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
725 | this._lineColor = saveColor; | 726 | this._lineColor = saveColor; |
726 | this._drawingContext.lineWidth = saveLineWidth; | 727 | this._drawingContext.lineWidth = saveLineWidth; |
727 | 728 | ||
728 | if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") { | ||
729 | // draw an outline around the body | ||
730 | var stagePt = MathUtils.getPointOnPlane([0,0,1,0]); | ||
731 | var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt); | ||
732 | // glmat4.multiply( tMat, stageMat, stageMat); | ||
733 | pt0 = [0, 0, 0]; | ||
734 | pt1 = [0, height, 0]; | ||
735 | delta = [width, 0, 0]; | ||
736 | this.drawGridLines(pt0, pt1, delta, stageMat, 2); | ||
737 | pt0 = [0, 0, 0]; | ||
738 | pt1 = [width, 0, 0]; | ||
739 | delta = [0, height, 0]; | ||
740 | this.drawGridLines(pt0, pt1, delta, stageMat, 2); | ||
741 | } | ||
742 | |||
743 | // draw the lines | 729 | // draw the lines |
744 | this.redrawGridLines(); | 730 | this.redrawGridLines(); |
745 | 731 | ||
@@ -762,15 +748,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
762 | var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt ); | 748 | var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt ); |
763 | for (var i = 0; i < nLines; i++) { | 749 | for (var i = 0; i < nLines; i++) { |
764 | // transform the points from working plane space to world space | 750 | // transform the points from working plane space to world space |
765 | //var t0 = mat.multiply(p0), | ||
766 | // t1 = mat.multiply(p1); | ||
767 | var t0 = glmat4.multiplyVec3( mat, p0, [] ), | 751 | var t0 = glmat4.multiplyVec3( mat, p0, [] ), |
768 | t1 = glmat4.multiplyVec3( mat, p1, [] ); | 752 | t1 = glmat4.multiplyVec3( mat, p1, [] ); |
769 | 753 | ||
770 | // transform from world space to global screen space | 754 | // transform from world space to global screen space |
771 | if (this._sourceSpaceElt) { | 755 | if (this._sourceSpaceElt) { |
772 | // t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); | ||
773 | // t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); | ||
774 | t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat); | 756 | t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat); |
775 | t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat); | 757 | t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat); |
776 | } | 758 | } |
@@ -788,9 +770,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
788 | line.setVisibility(vis); | 770 | line.setVisibility(vis); |
789 | 771 | ||
790 | // increment the points to the next position | 772 | // increment the points to the next position |
791 | // p0 = p0.add(d); p0[3] = 1.0; | ||
792 | p0 = vecUtils.vecAdd(4, p0, d); p0[3] = 1.0; | 773 | p0 = vecUtils.vecAdd(4, p0, d); p0[3] = 1.0; |
793 | // p1 = p1.add(d); p1[3] = 1.0; | ||
794 | p1 = vecUtils.vecAdd(4, p1, d); p1[3] = 1.0; | 774 | p1 = vecUtils.vecAdd(4, p1, d); p1[3] = 1.0; |
795 | } | 775 | } |
796 | } | 776 | } |
@@ -843,25 +823,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
843 | // draw the lines | 823 | // draw the lines |
844 | var line, | 824 | var line, |
845 | nLines = this._gridLineArray.length; | 825 | nLines = this._gridLineArray.length; |
846 | if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") { | ||
847 | nLines = this._gridLineArray.length-4; | ||
848 | } | ||
849 | 826 | ||
850 | for (var i = 0; i < nLines; i++) { | 827 | for (var i = 0; i < nLines; i++) { |
851 | line = this._gridLineArray[i]; | 828 | line = this._gridLineArray[i]; |
852 | this.drawIntersectedLine(line, this._drawingContext); | 829 | this.drawIntersectedLine(line, this._drawingContext); |
853 | } | 830 | } |
854 | 831 | ||
855 | if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") { | ||
856 | this._lineColor = "red"; | ||
857 | i = nLines; | ||
858 | nLines += 4; | ||
859 | for (; i < nLines; i++) { | ||
860 | line = this._gridLineArray[i]; | ||
861 | this.drawIntersectedLine(line, this._drawingContext); | ||
862 | } | ||
863 | } | ||
864 | |||
865 | this.popState(); | 832 | this.popState(); |
866 | } | 833 | } |
867 | }, | 834 | }, |
@@ -1237,6 +1204,73 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
1237 | } | 1204 | } |
1238 | }, | 1205 | }, |
1239 | 1206 | ||
1207 | drawStageOutline : { | ||
1208 | value: function() { | ||
1209 | var context = this.application.ninja.stage.gridContext; | ||
1210 | var stage = this.application.ninja.stage; | ||
1211 | var stageRoot = this.application.ninja.currentDocument.model.documentRoot; | ||
1212 | |||
1213 | // draw an outline around the template body if stage has any transforms | ||
1214 | if(stage.currentDocument.model.views.design._template && !MathUtils.isIdentityMatrix(this.viewUtils.getMatrixFromElement(stageRoot))) { | ||
1215 | var saveContext = this.getDrawingSurfaceElement(); | ||
1216 | this.setDrawingSurfaceElement(this.application.ninja.stage.gridCanvas); | ||
1217 | |||
1218 | var stagePt = MathUtils.getPointOnPlane([0,0,1,0]); | ||
1219 | var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt); | ||
1220 | var width = this.snapManager.getStageWidth(), | ||
1221 | height = this.snapManager.getStageHeight(), | ||
1222 | pt0 = [0, 0, 0], | ||
1223 | pt1 = [0, height, 0], | ||
1224 | delta = [width, 0, 0]; | ||
1225 | |||
1226 | this._gridLineArray.length = 0; | ||
1227 | this.drawGridLines(pt0, pt1, delta, stageMat, 2); | ||
1228 | |||
1229 | pt0 = [0, 0, 0]; | ||
1230 | pt1 = [width, 0, 0]; | ||
1231 | delta = [0, height, 0]; | ||
1232 | this.drawGridLines(pt0, pt1, delta, stageMat, 2); | ||
1233 | |||
1234 | this._lineColor = "red"; | ||
1235 | for (var i = 0; i < 4; i++) { | ||
1236 | this.drawIntersectedLine(this._gridLineArray[i], this._drawingContext); | ||
1237 | } | ||
1238 | |||
1239 | this.setDrawingSurfaceElement(saveContext); | ||
1240 | } | ||
1241 | |||
1242 | // draw reference lines across origin | ||
1243 | var bounds3D = this.viewUtils.getElementBoundsInGlobal(stageRoot); | ||
1244 | var l = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [0, 0, 0], [0, stage.canvas.height, 0], 0.1); | ||
1245 | if(!l) return; | ||
1246 | var r = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [stage.canvas.width, 0, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); | ||
1247 | if(!r) return; | ||
1248 | |||
1249 | var t = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, 0, 0], [stage.canvas.width, 0, 0], 0.1); | ||
1250 | if(!t) return; | ||
1251 | var b = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, stage.canvas.height, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); | ||
1252 | if(!b) return; | ||
1253 | |||
1254 | context.save(); | ||
1255 | context.strokeStyle = "#333"; | ||
1256 | context.lineWidth = 0.5; | ||
1257 | |||
1258 | context.beginPath(); | ||
1259 | |||
1260 | context.moveTo(l[0], l[1]); | ||
1261 | context.lineTo(r[0], r[1]); | ||
1262 | |||
1263 | context.moveTo(t[0], t[1]); | ||
1264 | context.lineTo(b[0], b[1]); | ||
1265 | |||
1266 | context.closePath(); | ||
1267 | context.stroke(); | ||
1268 | |||
1269 | context.fillText("(0, 0)", bounds3D[0][0] + 4, bounds3D[0][1] - 6); | ||
1270 | context.restore(); | ||
1271 | } | ||
1272 | }, | ||
1273 | |||
1240 | draw3DCompass : { | 1274 | draw3DCompass : { |
1241 | value: function() { | 1275 | value: function() { |
1242 | // set the element to be the viewport object - temporarily | 1276 | // set the element to be the viewport object - temporarily |
diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js index 35ee8112..44e2499d 100755 --- a/js/helper-classes/3D/math-utils.js +++ b/js/helper-classes/3D/math-utils.js | |||
@@ -333,7 +333,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { | |||
333 | 333 | ||
334 | //returns the intersection point between the two segments (null if no intersection) | 334 | //returns the intersection point between the two segments (null if no intersection) |
335 | segSegIntersection2D: { | 335 | segSegIntersection2D: { |
336 | value: function (seg0Start, seg0End, seg1Start, seg1End, epsilon) { | 336 | value: function (seg0Start, seg0End, seg1Start, seg1End, epsilon, mustLieInSegements) { |
337 | //check for parallel segments | 337 | //check for parallel segments |
338 | var denom = (seg1End[1] - seg1Start[1]) * (seg0End[0] - seg0Start[0]) - (seg1End[0] - seg1Start[0]) * (seg0End[1] - seg0Start[1]); | 338 | var denom = (seg1End[1] - seg1Start[1]) * (seg0End[0] - seg0Start[0]) - (seg1End[0] - seg1Start[0]) * (seg0End[1] - seg0Start[1]); |
339 | if (Math.abs(denom) <= epsilon) { | 339 | if (Math.abs(denom) <= epsilon) { |
@@ -349,7 +349,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { | |||
349 | paramSeg1 /= denom; | 349 | paramSeg1 /= denom; |
350 | 350 | ||
351 | //check whether the parameters are both between 0 and 1 | 351 | //check whether the parameters are both between 0 and 1 |
352 | if (Math.abs(paramSeg0) > 1.0 || Math.abs(paramSeg1) > 1.0) { | 352 | if (mustLieInSegements && (Math.abs(paramSeg0) > 1.0 || Math.abs(paramSeg1) > 1.0)) { |
353 | return null; //no intersection unless the the intersection point lies on both segments | 353 | return null; //no intersection unless the the intersection point lies on both segments |
354 | } | 354 | } |
355 | 355 | ||
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 5a128408..d7f29caa 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -244,6 +244,38 @@ exports.ViewUtils = Montage.create(Component, { | |||
244 | } | 244 | } |
245 | }, | 245 | }, |
246 | 246 | ||
247 | getElementBoundsInGlobal: { | ||
248 | value: function (elt) { | ||
249 | this.pushViewportObj(elt); | ||