Changeset 20792
- Timestamp:
- 06/22/16 14:14:46 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/plot_quiver.js
r20769 r20792 25 25 var is2d = meshresults[4]; 26 26 var isplanet = meshresults[5]; 27 var vx = md.initialization.vx; 28 var vy = md.initialization.vy; 27 var v = md.initialization.vel; 28 var vx = md.initialization.vx; 29 var vy = md.initialization.vy; 29 30 30 31 //Compue scaling through matrices for 2d meshes and vertices for 3d meshes … … 93 94 vertices.itemSize = 3; 94 95 var xyz = vec3.create(); 96 var xyz = vec3.create(); 95 97 var direction = vec3.create(); 96 98 var vertex = vec3.create(); 99 var vertexBase = vec3.create(); 100 var verticesArrow = [vec3.fromValues(0.0, 0.0, 0.0), vec3.fromValues(1.0, 0.0, 0.0), vec3.fromValues(0.667, -0.167, 0.0), vec3.fromValues(1.0, 0.0, 0.0), vec3.fromValues(0.667, 0.166, 0.0), vec3.fromValues(1.0, 0.0, 0.0)]; 97 101 var magnitude; 98 102 var color = edgecolor; 99 103 var scaling = options.getfieldvalue('scaling',1); 104 var scale; 100 105 for(var i = 0; i < x.length; i++){ 101 106 //Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing 102 107 if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i])) continue; 103 108 //Scale vertices 104 xyz 1= vec3.fromValues(x[i], y[i], z[i]);105 magnitude = vec3.length(xyz 1) + md.geometry.surface[i] * vertexscale;106 vec3.normalize(direction, xyz 1);109 xyz = vec3.fromValues(x[i], y[i], z[i]); 110 magnitude = vec3.length(xyz) + md.geometry.surface[i] * vertexscale; 111 vec3.normalize(direction, xyz); 107 112 vec3.scale(vertex, direction, magnitude); 108 vertices[vertices.length] = vertex[0]; 109 vertices[vertices.length] = vertex[1]; 110 vertices[vertices.length] = vertex[2]; 113 vec3.copy(vertexBase, vertex); 111 114 112 xyz2 = vec3.fromValues(vx[i], vy[i], 0.0); 113 magnitude = 1000.0*scaling; //mesh resolution 114 vec3.normalize(direction, xyz2); 115 vec3.scale(direction, direction, magnitude); 116 vec3.add(vertex, direction, vertex); 117 vertices[vertices.length] = vertex[0]; 118 vertices[vertices.length] = vertex[1]; 119 vertices[vertices.length] = vertex[2]; 120 121 colors[colors.length] = color[0]; 122 colors[colors.length] = color[1]; 123 colors[colors.length] = color[2]; 124 colors[colors.length] = color[3]; 125 colors[colors.length] = color[0]; 126 colors[colors.length] = color[1]; 127 colors[colors.length] = color[2]; 128 colors[colors.length] = color[3]; 115 scale = scaling*v[i]; 116 var modelMatrix = mat4.create(); 117 var scaleMatrix = mat4.create(); 118 var rotationMatrix = mat4.create(); 119 mat4.scale(scaleMatrix, scaleMatrix, vec3.fromValues(scale, scale, scale)); 120 mat4.rotate(rotationMatrix, rotationMatrix, Math.atan2(vy[i], vx[i]), [0.0, 0.0, 1.0]); 121 mat4.multiply(modelMatrix, rotationMatrix, scaleMatrix); 122 123 var temp = vec3.fromValues(0.0, 0.0, 0.0); 124 for (var j = 0; j < 6; j++){ 125 vec3.transformMat4(vertex, verticesArrow[j], modelMatrix); 126 vec3.add(vertex, vertex, vertexBase); 127 vertices[vertices.length] = vertex[0]; 128 vertices[vertices.length] = vertex[1]; 129 vertices[vertices.length] = vertex[2]; 130 131 colors[colors.length] = color[0]; 132 colors[colors.length] = color[1]; 133 colors[colors.length] = color[2]; 134 colors[colors.length] = color[3]; 135 } 129 136 } 130 137 }
Note:
See TracChangeset
for help on using the changeset viewer.