Index: /issm/trunk-jpl/src/m/plot/plot_manager.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/plot_manager.js	(revision 19759)
+++ /issm/trunk-jpl/src/m/plot/plot_manager.js	(revision 19760)
@@ -86,5 +86,6 @@
 				break;
 			case 'mesh':
-				plot_mesh(md,options,nlines,ncols,i);
+				//plot_mesh(md,options,nlines,ncols,i);
+				plot_mesh(md.mesh.x,md.mesh.y,[0.0],md.mesh.elements,2,options,canvas,gl);
 				break;
 			case 'none':
@@ -207,19 +208,21 @@
 	}
 
-	//process data and model
-    var meshresults = processmesh(md,data,options);
-	var x = meshresults[0]; 
-	var y = meshresults[1]; 
-	var z = meshresults[2]; 
-	var elements = meshresults[3]; 
-	var is2d = meshresults[4]; 
-	var isplanet = meshresults[5];
-
-	var dataresults = processdata(md,data,options);
-	var data2 = dataresults[0]; 
-	var datatype = dataresults[1];
-
-	//plot unit
-	plot_unit(x,y,z,elements,data2,is2d,isplanet,datatype,options,canvas,gl);
+	if (typeof data !== 'string'){
+		//process data and model
+		var meshresults = processmesh(md,data,options);
+		var x = meshresults[0]; 
+		var y = meshresults[1]; 
+		var z = meshresults[2]; 
+		var elements = meshresults[3]; 
+		var is2d = meshresults[4]; 
+		var isplanet = meshresults[5];
+		
+		var dataresults = processdata(md,data,options);
+		var data2 = dataresults[0]; 
+		var datatype = dataresults[1];
+
+		//plot unit
+		plot_unit(x,y,z,elements,data2,is2d,isplanet,datatype,options,canvas,gl);
+	}
 
 	//apply all options
Index: /issm/trunk-jpl/src/m/plot/plot_mesh.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/plot_mesh.js	(revision 19760)
+++ /issm/trunk-jpl/src/m/plot/plot_mesh.js	(revision 19760)
@@ -0,0 +1,137 @@
+function plot_mesh(x,y,z,elements,datatype,options,canvas,gl) {
+	//   Usage:
+	//      plot_mesh(md,options,nlines,ncols,i);
+	//
+	//   See also: PLOTMODEL
+
+	//declare variables:  {{{
+	var node;
+	var vertices = [];
+	var indices = [];
+	var colors = [];
+	var rgbcolor = [];
+	var xmin,xmax;
+	var ymin,ymax;
+	var zmin,zmax;
+	var scale;
+	//}}}
+
+	//Initialize the buffer structure: 
+	node = Node(gl,options);
+
+	//Compute coordinates and data range: 
+	xmin = ArrayMin(x);
+	xmax = ArrayMax(x);
+	ymin = ArrayMin(y);
+	ymax = ArrayMax(y);
+	zmin = ArrayMin(z);
+	zmax = ArrayMax(z);
+
+	//Compute scaling: 
+	var scale = 1 / (xmax - xmin);
+	node["scale"] = [scale, scale, scale];
+	node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (-2 / scale)];
+	node["modelMatrix"] = recalculateModelMatrix(node);
+	node["drawMode"] = gl.LINES;
+				
+	//some defaults:
+	colors.itemSize = 4;
+
+	//retrieve some options
+	var linewidth=options.getfieldvalue('linewidth',1);
+	var edgecolor=options.getfieldvalue('edgecolor','black');
+
+	/*//plot mesh
+	if (is2d){
+		A=elements(:,1); B=elements(:,2); C=elements(:,3); 
+		patch( 'Faces', [A B C], 'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+	}
+	*/
+	
+	// populate arrays {{{
+	switch(datatype){
+		//element plot {{{
+		case 1:
+			break;
+		//}}}
+		//node plot {{{
+		case 2:
+			if (elements[0].length==6){ //prisms
+				/*A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
+				patch( 'Faces', [A B C],  'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+				patch( 'Faces', [D E F],  'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+				patch( 'Faces', [A B E D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+				patch( 'Faces', [B E F C],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+				patch( 'Faces', [C A D F],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+				*/
+			}
+			else if (elements[0].length==4){ //tetras
+				/*A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4);
+				patch( 'Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+				patch( 'Faces',[A B D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+				patch( 'Faces',[B C D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+				patch( 'Faces',[C A D],'Vertices', [x y z],'FaceVertexCData',zeros(size(x)),'FaceColor','none','EdgeColor',edgecolor,'linewidth',linewidth);
+				*/
+			}
+			else{ //2D triangular elements
+				vertices.itemSize = 3;
+				for(var i = 0; i < x.length; i++){
+					vertices[vertices.length] = x[i];
+					vertices[vertices.length] = y[i];
+					//vertices[vertices.length] = z[i];
+					vertices[vertices.length] = 0;
+
+					//handle mesh/qinterest size mismatch
+					rgbcolor = [0.0, 0.0, 0.0];
+					colors[colors.length] = rgbcolor[0];
+					colors[colors.length] = rgbcolor[1];
+					colors[colors.length] = rgbcolor[2];
+					colors[colors.length] = 1.0;
+				}
+
+				//linearize the elements array: 
+				
+				for(var i = 0; i < elements.length; i++){
+					//convert tris to line edges; generates more edges than necessary, should optimize using node connectivity
+					//matlab indices from 1, so decrement indices.
+					indices[indices.length] = elements[i][0] - 1;
+					indices[indices.length] = elements[i][1] - 1;
+					indices[indices.length] = elements[i][1] - 1;
+					indices[indices.length] = elements[i][2] - 1;
+					indices[indices.length] = elements[i][2] - 1;
+					indices[indices.length] = elements[i][0] - 1;
+				}
+				indices.itemSize = 1;
+			}
+			break;
+		//}}}
+		//quiver plot {{{
+		case 3:
+
+			if (is2d){
+				//plot_quiver(x,y,data(:,1),data(:,2),options);
+			}
+			else{
+				//plot_quiver3(x,y,z,data(:,1),data(:,2),data(:,3),options);
+			}
+
+		//}}}
+		default:
+			throw Error(sprintf("%s%i%s\n",'case ',datatype,' not supported'));
+	}
+	//}}}
+
+	/*//apply options
+	options=addfielddefault(options,'title','Mesh');
+	options=addfielddefault(options,'colorbar',0);
+	applyoptions(md,[],options);
+	*/
+
+	/*Initalize buffers: */
+	node["arrays"] = [vertices, colors, indices];
+	node["buffers"] = initBuffers(gl, node["arrays"]);
+	
+	/*Draw into the canvas:*/
+	console.log(node);
+	draw(gl,options,canvas,node);
+}
Index: /issm/trunk-jpl/src/m/plot/plot_unit.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/plot_unit.js	(revision 19759)
+++ /issm/trunk-jpl/src/m/plot/plot_unit.js	(revision 19760)
@@ -45,5 +45,5 @@
 	switch(datatype){
 
-		//element plot
+		//element plot {{{
 		case 1:
 
@@ -72,6 +72,6 @@
 			}
 			break;
-
-			//node plot
+		//}}}
+		//node plot {{{
 		case 2:
 
@@ -115,6 +115,6 @@
 			}
 			break;
-
-			//quiver plot
+		//}}}
+		//quiver plot {{{
 		case 3:
 
@@ -126,6 +126,7 @@
 			}
 
+		//}}}
 		default:
-				throw Error(sprintf("%s%i%s\n",'case ',datatype,' not supported'));
+			throw Error(sprintf("%s%i%s\n",'case ',datatype,' not supported'));
 	}
 	
