Changeset 19992


Ignore:
Timestamp:
01/23/16 22:57:50 (9 years ago)
Author:
dlcheng
Message:

CHG (javascript): Implementing point cloud rendering.

Location:
issm/trunk-jpl/src/m/plot
Files:
2 edited

Legend:

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

    r19965 r19992  
    2121                                        })
    2222                                });
    23                                 data = data[node["movieFrame"]].slice(0,-1);
     23                                data = data[node['movieFrame']].slice(0,-1);
    2424                                console.log(data);
    2525                        } //}}}
     
    209209        }
    210210        //}}}
    211         //Make texture canvas //{{{
     211        //texture canvas //{{{
    212212        var tcontext,tcanvas,tcanvasid,tcanvashtml,tURL,tgradient;
    213213        tcanvasid = 'texturecanvas';
     
    235235        tcontext.fillRect(0,0,256,256);
    236236        tURL = tcanvashtml.toDataURL();
    237         node["texture"] = initTexture(gl,tURL);
     237        node['texture'] = initTexture(gl,tURL);
    238238        //}}}
    239         //expdisp contours
     239        //expdisp contours {{{
    240240        if (options.exist('expdisp')) {
    241                 canvas.nodes["expdisp"] = Node(gl,options);
    242                 var node = canvas.nodes["expdisp"];
     241                canvas.nodes['expdisp'] = Node(gl,options);
     242                var node = canvas.nodes['expdisp'];
    243243               
    244244                //declare variables:  {{{
     
    262262                //}}}
    263263
    264                 //Compute coordinates and data range:
     264                //Compute coordinates and data range: //{{{
    265265                var modelxlim = [ArrayMin(x),ArrayMax(x)];
    266266                var modelylim = [ArrayMin(y),ArrayMax(y)];
     
    275275                zmin = zlim[0];
    276276                zmax = zlim[1];
    277 
    278                 //Compute scaling:
     277                //}}}
     278
     279                //Compute scaling: //{{{
    279280                var scale = 1 / (xmax - xmin);
    280                 node["shaderName"] = "colored";
    281                 node["shader"] = gl["shaders"][node["shaderName"]]["program"];
    282                 node["scale"] = [scale, scale, scale*options.getfieldvalue('heightscale',1)];
    283                 node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (-2 / scale)];
    284                 node["modelMatrix"] = recalculateModelMatrix(node);
    285                 node["drawMode"] = gl.LINE_LOOP;
    286                 node["drawOrder"] = 0;
    287                 node["useIndexBuffer"] = false;
    288                 node["disableDepthTest"] = true;
    289                                        
     281                node['shaderName'] = 'colored';
     282                node['shader'] = gl['shaders'][node['shaderName']]['program'];
     283                node['scale'] = [scale, scale, scale*options.getfieldvalue('heightscale',1)];
     284                node['translation'] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (-2 / scale)];
     285                node['modelMatrix'] = recalculateModelMatrix(node);
     286                node['drawMode'] = gl.LINE_LOOP;
     287                node['drawOrder'] = 0;
     288                node['useIndexBuffer'] = false;
     289                node['disableDepthTest'] = true;
     290                //}}}
     291
    290292                //some defaults:
    291293                colors.itemSize = 4;
     
    309311                }
    310312
    311                 /*Initalize buffers: */
    312                 node["arrays"] = [vertices, colors];
    313                 node["buffers"] = initBuffers(gl, node["arrays"]);
    314         }
     313                //Initalize buffers:
     314                node['arrays'] = [vertices, colors];
     315                node['buffers'] = initBuffers(gl, node['arrays']);
     316        } //}}}
     317        //cloud of points {{{
     318        if (options.exist('cloud')) {
     319                canvas.nodes['cloud'] = Node(gl,options);
     320                var node = canvas.nodes['cloud'];
     321
     322                //declare variables:  {{{
     323                var vertices = [];
     324                var indices = [];
     325                var colors = [];
     326                var rgbcolor = [];
     327                var xmin,xmax;
     328                var ymin,ymax;
     329                var zmin,zmax;
     330                var scale;
     331               
     332                //Process data and model
     333                var x = options.getfieldvalue('cloud')['x'];
     334                var y = options.getfieldvalue('cloud')['y'];
     335                var z = Array.apply(null, Array(x.length)).map(Number.prototype.valueOf,0);
     336               
     337                if (options.getfieldvalue('cloud')['z']) {
     338                        z = options.getfieldvalue('cloud')['z'];
     339                }
     340                //}}}
     341
     342                //Compute coordinates and data range: //{{{
     343                var modelxlim = [ArrayMin(x),ArrayMax(x)];
     344                var modelylim = [ArrayMin(y),ArrayMax(y)];
     345                var modelzlim = [ArrayMin(z),ArrayMax(z)];
     346                var xlim = options.getfieldvalue('xlim',modelxlim);
     347                var ylim = options.getfieldvalue('ylim',modelylim);
     348                var zlim = options.getfieldvalue('zlim',modelzlim);
     349                xmin = xlim[0];
     350                xmax = xlim[1];
     351                ymin = ylim[0];
     352                ymax = ylim[1];
     353                zmin = zlim[0];
     354                zmax = zlim[1];
     355                //}}}
     356
     357                //Compute scaling: //{{{
     358                var scale = 1 / (xmax - xmin);
     359                node['shaderName'] = 'colored';
     360                node['shader'] = gl['shaders'][node['shaderName']]['program'];
     361                node['scale'] = [scale, scale, scale*options.getfieldvalue('heightscale',1)];
     362                node['translation'] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (-2 / scale)];
     363                node['modelMatrix'] = recalculateModelMatrix(node);
     364                node['drawMode'] = gl.POINTS;
     365                node['drawOrder'] = 0;
     366                node['useIndexBuffer'] = false;
     367                node['disableDepthTest'] = true;
     368                //}}}
     369
     370                //some defaults:
     371                colors.itemSize = 4;
     372
     373                //retrieve some options
     374                var linewidth=options.getfieldvalue('linewidth',1);
     375                var edgecolor=options.getfieldvalue('edgecolor','black'); //RGBCOLOR?
     376
     377                vertices.itemSize = 3;
     378                for(var i = 0; i < x.length; i++){
     379                        vertices[vertices.length] = x[i];
     380                        vertices[vertices.length] = y[i];
     381                        vertices[vertices.length] = z[i];
     382
     383                        //edgecolor
     384                        rgbcolor = [0.0, 0.0, 0.0];
     385                        colors[colors.length] = rgbcolor[0];
     386                        colors[colors.length] = rgbcolor[1];
     387                        colors[colors.length] = rgbcolor[2];
     388                        colors[colors.length] = 1.0;
     389                }
     390
     391                //Initalize buffers:
     392                node['arrays'] = [vertices, colors];
     393                node['buffers'] = initBuffers(gl, node['arrays']);
     394        } //}}}
    315395}
  • issm/trunk-jpl/src/m/plot/webgl.js

    r19965 r19992  
    199199                '',
    200200                'void main(void) {',
     201                '       gl_PointSize = 3.0;',
    201202                '       gl_Position = uMVPMatrix * vec4(aVertexPosition.xyz, 1.0);',
    202203                '       vColor = vec4(aVertexColor.xyz, uAlpha);',
     
    221222                '',
    222223                'void main(void) {',
     224                '       gl_PointSize = 3.0;',
    223225                '       gl_Position = uMVPMatrix * vec4(aVertexPosition.xyz, 1.0);',
    224226                '       vTextureCoord = aTextureCoord;',
Note: See TracChangeset for help on using the changeset viewer.