Ignore:
Timestamp:
04/28/16 22:58:29 (9 years ago)
Author:
dlcheng
Message:

CHG (javascript): Addressing NaN data handling bugs and mask option.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/plot/plot_unit.js

    r20565 r20579  
    1 function plot_unit(md,data,options,canvas,gl,node) {
     1function plot_unit(md,data,datatype,options,canvas,gl,node) {
    22        //PLOT_UNIT - unit plot, display data
    33        //
     
    2626        var is2d = meshresults[4];
    2727        var isplanet = meshresults[5];
    28        
    29         var     dataresults = processdata(md,data,options);
    30         var     data2 = dataresults[0];
    31         var     datatype = dataresults[1];
    3228
    3329        //Compue scaling through matrices for 2d meshes and vertices for 3d meshes
     
    112108                                for(var i = 0; i < x.length; i++){
    113109                                        //Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing
    114                                         if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i])) {
     110                                        if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i]) || isNaN(data[i])) {
    115111                                                nanindices[i] = i;
    116112                                                vertices[vertices.length] = vertex[0];
    117113                                                vertices[vertices.length] = vertex[1];
    118114                                                vertices[vertices.length] = vertex[2];
     115                                               
     116                                                texcoords[texcoords.length] = 0.0;
     117                                                texcoords[texcoords.length] = 0.0;
    119118                                                continue;
    120119                                        }
     
    144143
    145144                        }
     145               
    146146                        //Initalize buffers
    147147                        node["arrays"] = [vertices, texcoords, indices];
     
    175175                                for(var i = 0; i < x.length; i++){
    176176                                        //Check for NaN values and remove from indices array as necessary, but preserve vertex array spacing
    177                                         if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i])) {
     177                                        if (isNaN(x[i]) || isNaN(y[i]) || isNaN(z[i]) || isNaN(data[i])) {
    178178                                                nanindices[i] = i;
    179179                                                vertices[vertices.length] = vertex[0];
    180180                                                vertices[vertices.length] = vertex[1];
    181181                                                vertices[vertices.length] = vertex[2];
     182                                               
     183                                                texcoords[texcoords.length] = 0.0;
     184                                                texcoords[texcoords.length] = 0.0;
    182185                                                continue;
    183186                                        }
     
    191194                                        vertices[vertices.length] = vertex[2];
    192195                                }       
    193                                
    194196                                //Transpose data to obtain column addressable data matrix
    195197                                data = data[0].map(function(col, i) {
     
    271273                        throw Error(sprintf("%s%i%s\n",'case ',datatype,' not supported'));
    272274        }
     275       
    273276        if (canvas.requestDrawing) draw(gl,options,canvas);
    274277}
Note: See TracChangeset for help on using the changeset viewer.