aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorhwc4872012-04-26 12:50:57 -0700
committerhwc4872012-04-26 12:50:57 -0700
commit4b83774cdbfbf30add9a8fa2f11b1c4ff35179fa (patch)
treec8bdc04b07d9b1193ae8a553cf8d570d19a852ca /js
parent34e6aa5a76fb49c3d9251cedf128c6ed971abb5c (diff)
downloadninja-4b83774cdbfbf30add9a8fa2f11b1c4ff35179fa.tar.gz
canvas interaction
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js16
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js10
-rwxr-xr-xjs/lib/drawing/world.js2
-rwxr-xr-xjs/tools/ShapeTool.js18
4 files changed, 30 insertions, 16 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index ff5192b3..454b7154 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -207,16 +207,16 @@ exports.HTMLDocument = Montage.create(TextDocument, {
207 var elt = this.documentRoot; 207 var elt = this.documentRoot;
208 if (elt) 208 if (elt)
209 { 209 {
210 /*
211 // Use this code to test the runtime version of WebGL
212 var cdm = new NinjaCvsRt.CanvasDataManager();
213 cdm.loadGLData(elt, value, null );
214 */
215
216 // /*
210 var nWorlds= value.length; 217 var nWorlds= value.length;
211 for (var i=0; i<nWorlds; i++) 218 for (var i=0; i<nWorlds; i++)
212 { 219 {
213 /*
214 // Use this code to test the runtime version of WebGL
215 var cdm = new NinjaCvsRt.CanvasDataManager();
216 cdm.loadGLData(elt, value, null );
217 */
218
219 // /*
220 // get the data for the next canvas 220 // get the data for the next canvas
221 var importStr = value[i]; 221 var importStr = value[i];
222 222
@@ -281,8 +281,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
281 } 281 }
282 } 282 }
283 } 283 }
284 // */
285 } 284 }
285 // */
286 } 286 }
287 } 287 }
288 }, 288 },
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 2c975985..dcfd5ddc 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -948,7 +948,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
948 { 948 {
949 949
950 // see if we can snap to a contained geometry object 950 // see if we can snap to a contained geometry object
951 if (hitRec && this.getGLWorld(elt) && !this.isARectangle(elt)) 951 if (hitRec && this.getGLWorld(elt)) // && !this.isARectangle(elt))
952 { 952 {
953 var localPt = hitRec.calculateElementWorldPoint(); 953 var localPt = hitRec.calculateElementWorldPoint();
954 if (hitRec.getType() != hitRec.SNAP_TYPE_ELEMENT) 954 if (hitRec.getType() != hitRec.SNAP_TYPE_ELEMENT)
@@ -1346,13 +1346,13 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1346 var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); 1346 var dist = vecUtils.vecDist(2, globalPt, targetScrPt );
1347 if (dist < this.ELEMENT_VERTEX_HIT_RAD) 1347 if (dist < this.ELEMENT_VERTEX_HIT_RAD)
1348 { 1348 {
1349 console.log( "hit a vertex" ); 1349 //console.log( "hit a vertex" );
1350 1350
1351 // check if the distance is less than 1351 // check if the distance is less than
1352 // the distance on the current hit record 1352 // the distance on the current hit record
1353 if (dist <= vecUtils.vecDist(2, targetScrPt, hitRec.getScreenPoint() )) 1353 //if (dist <= vecUtils.vecDist(2, targetScrPt, hitRec.getScreenPoint() ))
1354 { 1354 {
1355 console.log( "rejected - further than existing snap" ); 1355 //console.log( "rejected - further than existing snap" );
1356 1356
1357 hitRec.setScreenPoint( globalPt ); 1357 hitRec.setScreenPoint( globalPt );
1358 //var localMatInv = hitRec.getPlaneMatrix().inverse(); 1358 //var localMatInv = hitRec.getPlaneMatrix().inverse();
@@ -1388,7 +1388,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1388 var dist = vecUtils.vecDist(2, globalPt, targetScrPt ); 1388 var dist = vecUtils.vecDist(2, globalPt, targetScrPt );
1389 if (dist < this.ELEMENT_EDGE_HIT_RAD) 1389 if (dist < this.ELEMENT_EDGE_HIT_RAD)
1390 { 1390 {
1391 console.log( "hit an edge" ); 1391 //console.log( "hit an edge" );
1392 1392
1393 // check if the distance is less than 1393 // check if the distance is less than
1394 // the distance on the current hit record 1394 // the distance on the current hit record
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 7ee9ee00..7ce23921 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -758,7 +758,7 @@ World.prototype.exportJSON = function () {
758 // would not be destructive of the data. You would be wrong... 758 // would not be destructive of the data. You would be wrong...
759 // We need to rebuild everything 759 // We need to rebuild everything
760 if (this._useWebGL) { 760 if (this._useWebGL) {
761 if (worldObj.children && (worldObj.children.length === 1)) { 761 if (worldObj.children && (worldObj.children.length >= 1)) {
762 this.rebuildTree(this._geomRoot); 762 this.rebuildTree(this._geomRoot);
763 this.restartRenderLoop(); 763 this.restartRenderLoop();
764 } 764 }
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index b2948fe7..74e692b6 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -69,6 +69,7 @@ exports.ShapeTool = Montage.create(DrawingTool, {
69 drawData.planeMat, drawData.midPt, canvas, true); 69 drawData.planeMat, drawData.midPt, canvas, true);
70 70
71 canvas.elementModel.isShape = true; 71 canvas.elementModel.isShape = true;
72 this.application.ninja.elementMediator.addElements(canvas, elementModel.data);
72 } else { 73 } else {
73 canvas = this._targetedElement; 74 canvas = this._targetedElement;
74 if (!canvas.getAttribute( "data-RDGE-id" )) 75 if (!canvas.getAttribute( "data-RDGE-id" ))
@@ -77,8 +78,8 @@ exports.ShapeTool = Montage.create(DrawingTool, {
77 if(!canvas.elementModel.shapeModel) { 78 if(!canvas.elementModel.shapeModel) {
78 canvas.elementModel.shapeModel = Montage.create(ShapeModel); 79 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
79 } 80 }
81 this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data);
80 } 82 }
81 this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data);
82 } 83 }
83 84
84 this.endDraw(event); 85 this.endDraw(event);
@@ -213,7 +214,20 @@ exports.ShapeTool = Montage.create(DrawingTool, {
213 _useExistingCanvas: { 214 _useExistingCanvas: {
214 value: function() 215 value: function()
215 { 216 {
216 return (this._targetedElement && !ShapesController.isElementAShape(this._targetedElement)); 217 var target;
218 if (this._targetedElement && (this._targetedElement.nodeName === "CANVAS") && !ShapesController.isElementAShape(this._targetedElement))
219 target = this._targetedElement;
220 else
221 {
222 var container = this.application.ninja.currentSelectedContainer;
223 if (container && (container.nodeName === "CANVAS"))
224 {
225 target = container;
226 this._targetedElement = target;
227 }
228 }
229
230 return target;
217 } 231 }
218 } 232 }
219 233