Changeset 19922
- Timestamp:
- 01/02/16 23:24:06 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/webgl.js
r19921 r19922 15 15 gl = null; 16 16 } 17 17 18 18 // Enable depth testing 19 19 gl.enable(gl.DEPTH_TEST); … … 31 31 // Load shaders and store them in gl object 32 32 gl.shaders = loadShaders(gl); 33 34 33 35 34 36 // Add context state variables … … 38 40 canvas.zoomLast = canvas.zoomFactor; 39 41 canvas.cameraMatrix = mat4.create(); 40 canvas.translation = [0,0,options.getfieldvalue('centeroffset',0.25)];42 canvas.translation = options.getfieldvalue('centeroffset',[0,0,0.25]); 41 43 canvas.rotationAzimuthBounds = options.getfieldvalue('azimuthbounds',[0,360]); 42 44 canvas.rotationElevationBounds = options.getfieldvalue('elevationbounds',[-180,180]); 43 45 canvas.rotationDefault = options.getfieldvalue('view',[0,90]); //0 azimuth - up is north, 90 elevation - looking straight down 44 canvas.rotation = queryView(canvas);46 canvas.rotation = canvas.rotationDefault; 45 47 canvas.controlsensitivity = 1; 46 48 … … 163 165 return Math.max(min, Math.min(value, max)); 164 166 } //}}} 165 function queryView(canvas) { //{{{ 166 if (canvas.rotation) { 167 function recoverview(canvasid,defaultview) { //{{{ 168 var canvas = document.getElementById(canvasid); 169 if (canvas && canvas.hasOwnProperty("rotation")) { 167 170 return canvas.rotation; 168 171 } 169 return canvas.rotationDefault; 172 return defaultview; 173 } //}}} 174 function recovercenteroffset(canvasid,defaultcenter) { //{{{ 175 var canvas = document.getElementById(canvasid); 176 if (canvas && canvas.hasOwnProperty("translation")) { 177 return canvas.translation; 178 } 179 return defaultcenter; 170 180 } //}}} 171 181 //}}} … … 441 451 } //}}} 442 452 function draw(gl,options,canvas,nodes) { //{{{ 453 // Ensure canvas and gl viewport sizes are the same 454 var displayWidth = canvas.clientWidth; 455 var displayHeight = canvas.clientHeight; 456 if (canvas.width != displayWidth || canvas.height != displayHeight) { 457 canvas.width = displayWidth; 458 canvas.height = displayHeight; 459 gl.viewport(0, 0, canvas.width, canvas.height); 460 } 461 443 462 // Set clear color to black, fully opaque 444 463 var backgroundcolor=new RGBColor(options.getfieldvalue('backgroundcolor','lightcyan')); … … 457 476 // Else, clear the color as well as the depth buffer for new frame 458 477 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 478 459 479 window.requestAnimationFrame(function(time) {draw(gl,options,canvas,nodes)}); 460 480
Note:
See TracChangeset
for help on using the changeset viewer.