Changeset 19864
- Timestamp:
- 12/07/15 23:23:47 (9 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/plot_manager.js
r19853 r19864 29 29 30 30 //Initialize the buffer structure: 31 var node = Node(gl,options); 31 var nodes = {}; 32 nodes["main"] = Node(gl,options); 32 33 33 34 //figure out if this is a special plot … … 95 96 case 'mesh': 96 97 //plot_mesh(md,options,nlines,ncols,i); 97 plot_mesh(md,options,canvas,gl,node );98 plot_mesh(md,options,canvas,gl,nodes["main"]); 98 99 break; 99 100 case 'none': … … 187 188 188 189 //Figure out if this is a semi-transparent plot. 189 if (options. exist('overlay')){190 plot_overlay(md,data,options,nlines,ncols,i);191 return;190 if (options.getfieldvalue('overlay','off')=='on'){ 191 nodes["overlay"] = Node(gl,options); 192 plot_overlay(md,data,options,canvas,gl,nodes["overlay"]); 192 193 } 193 194 … … 218 219 if (typeof data !== 'string'){ 219 220 //plot unit 220 plot_unit(md,data,options,canvas,gl,node );221 plot_unit(md,data,options,canvas,gl,nodes["main"]); 221 222 } 222 223 223 224 //applyoptions(md,data2,options); 224 applyoptions(md,data,options,canvas,gl,node );225 applyoptions(md,data,options,canvas,gl,nodes["main"]); 225 226 226 227 /*Draw into the canvas:*/ 227 draw(gl,options,canvas,node );228 draw(gl,options,canvas,nodes); 228 229 } -
issm/trunk-jpl/src/m/plot/plot_unit.js
r19854 r19864 140 140 /*Initalize buffers: */ 141 141 node["buffers"] = initBuffers(gl,[vertices, texcoords, indices]); 142 node["overlay"] = false; 142 143 } -
issm/trunk-jpl/src/m/plot/webgl.js
r19853 r19864 22 22 // Clear the color as well as the depth buffer. 23 23 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 24 // Enable color blending/overlay 25 gl.enable(gl.BLEND); 24 26 25 27 // Allocate arrays equal to maximium number of attributes used by any one shader … … 99 101 } //}}} 100 102 function Node(gl,options) { //{{{ 101 102 var node; 103 104 node= {buffers:[], 103 //Returns a Node object that contains default display states for webgl object 104 return {buffers:[], 105 105 shader:gl.shaders["unlit_textured"]["program"], 106 106 draw:null, … … 109 109 useIndexBuffer:true, 110 110 useOrthographic:false, 111 transparency:1.0,111 alpha:1.0, 112 112 disableDepthTest:false, 113 113 enableCullFace:false, … … 120 120 modelMatrix:mat4.create(), 121 121 shaderName:"unlit_textured", 122 overlay:false, 122 123 }; 123 124 return node;125 126 124 } //}}} 127 125 function recalculateModelMatrix(node) { //{{{ … … 210 208 '', 211 209 'uniform sampler2D uColorSampler;', 210 'uniform float uAlpha;', 212 211 '', 213 212 'void main(void) {', 214 ' gl_FragColor = texture2D(uColorSampler, vec2(vTextureCoord.s, vTextureCoord.t));',213 ' gl_FragColor = vec4(texture2D(uColorSampler, vec2(vTextureCoord.s, vTextureCoord.t)).rgb, uAlpha);', 215 214 '}'].join('\n'); 216 215 shaderNames.forEach(function(shaderName){ … … 323 322 } 324 323 gl.uniformMatrix4fv(node["shader"]["uMVPMatrix"], false, mvpMatrix); 325 gl.uniform1f(node["shader"]["uAlpha"], node[" transparency"]);324 gl.uniform1f(node["shader"]["uAlpha"], node["alpha"]); 326 325 if (node["texture"]) { 327 326 gl.activeTexture(gl.TEXTURE0); … … 329 328 gl.uniform1i(node["shader"]["uColorSampler"], 0); 330 329 } 331 if (node["useIndexBuffer"]) { 330 if (node["overlay"] == true) { 331 gl.blendFunc(gl.SRC_ALPHA, gl.ONE); 332 } 333 else { 334 gl.blendFunc (gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); 335 } 336 if (node["useIndexBuffer"] == true) { 332 337 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, node["buffers"][node["buffers"].length - 1]); 333 338 gl.drawElements(node["drawMode"], node["buffers"][node["buffers"].length - 1].numItems, gl.UNSIGNED_SHORT, 0); … … 350 355 } 351 356 } //}}} 352 function draw(gl,options,canvas,node ) { //{{{357 function draw(gl,options,canvas,nodes) { //{{{ 353 358 354 359 // Set clear color to black, fully opaque … … 358 363 } 359 364 else throw Error(sprintf("s%s%s\n","initWebGL error message: cound not find out background color for curent canvas ",canvas)); 360 365 361 366 // Clear the color as well as the depth buffer. 362 367 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 363 368 364 window.requestAnimationFrame(function(time) {draw(gl,options,canvas,node )});369 window.requestAnimationFrame(function(time) {draw(gl,options,canvas,nodes)}); 365 370 updateCameraMatrix(canvas); 366 367 drawSceneGraphNode(gl, canvas, node); 371 for (var node in nodes) { 372 drawSceneGraphNode(gl, canvas, nodes[node]); 373 } 368 374 } //}}} 369 375 //}}}
Note:
See TracChangeset
for help on using the changeset viewer.