Changeset 21173
- Timestamp:
- 08/31/16 00:56:52 (9 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/applyoptions.js
r21138 r21173 332 332 } //}}} 333 333 //Atmosphere {{{ 334 if (options.exist('atmosphere')) { 335 if (options.getfieldvalue('atmosphere')=='on') { 336 var meshresults = processmesh(md,data,options); 337 var x = meshresults[0]; 338 var y = meshresults[1]; 339 var z = meshresults[2]; 340 var elements = meshresults[3]; 341 var is2d = meshresults[4]; 342 var isplanet = meshresults[5]; 343 344 var modelxlim = [ArrayMin(x),ArrayMax(x)]; 345 var modelylim = [ArrayMin(y),ArrayMax(y)]; 346 var modelzlim = [ArrayMin(z),ArrayMax(z)]; 347 var xlim = options.getfieldvalue('xlim',modelxlim); 348 var ylim = options.getfieldvalue('ylim',modelylim); 349 var zlim = options.getfieldvalue('zlim',modelzlim); 350 xmin = xlim[0]; 351 xmax = xlim[1]; 352 ymin = ylim[0]; 353 ymax = ylim[1]; 354 zmin = zlim[0]; 355 zmax = zlim[1]; 356 357 var scale = 1; 358 var atmosphereScale = 1.25; 359 360 //Atmosphere 334 if (options.exist('render')) { 335 var meshresults = processmesh(md,data,options); 336 var x = meshresults[0]; 337 var y = meshresults[1]; 338 var z = meshresults[2]; 339 var elements = meshresults[3]; 340 var is2d = meshresults[4]; 341 var isplanet = meshresults[5]; 342 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 var global = vec3.length([(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2]) < 6371000/10; //tolerance for global models = center is 637100 meters away from center of earth 357 var atmosphereScale = 1.25; 358 var translation = global ? [(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2] : [(xmin + xmax) / 2, (ymin + ymax) - 6371000, (zmin + zmax) / 2]; 359 360 if (options.getfieldvalue('render',[]).indexOf('sky')!=-1) { 361 //atmosphere 361 362 var node = Node(gl,options); 362 363 canvas.nodes[canvas.nodes.length] = node; 364 node["name"] = "atmosphere"; 363 365 node["shaderName"] = "SkyFromSpace"; 364 366 node["shader"] = gl["shaders"][node["shaderName"]]; … … 367 369 node["mesh"] = GL.Mesh.icosahedron({size:6371000*atmosphereScale,subdivisions:6}); 368 370 node["useIndexBuffer"] = false; 369 node["rotation"] = [0, 0,0];370 node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (2 / scale)];371 node[" scale"] = [scale, scale, scale];371 node["rotation"] = [0, 0, 0] 372 node["translation"] = translation; 373 node["center"] = [0, 0, 0]; 372 374 node["modelMatrix"] = recalculateModelMatrix(node); 373 374 //Skysphere 375 var node = Node(gl,options); 375 } 376 if (options.getfieldvalue('render',[]).indexOf('space')!=-1) { 377 //skysphere 378 node = Node(gl,options); 376 379 canvas.nodes[canvas.nodes.length] = node; 380 node["name"] = "skysphere"; 377 381 node["shaderName"] = "Textured"; 378 382 node["shader"] = gl["shaders"][node["shaderName"]]; … … 382 386 node["texture"] = initTexture(gl,'../../../js/textures/TychoSkymapII_t4_2k.jpg'); 383 387 node["useIndexBuffer"] = false; 384 node["rotation"] = [0, 0,0];385 node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (2 / scale)];386 node[" scale"] = [scale, scale, scale];388 node["rotation"] = [0, 0, 0] 389 node["translation"] = translation; 390 node["center"] = [0, 0, 0]; 387 391 node["modelMatrix"] = recalculateModelMatrix(node); 388 392 } -
issm/trunk-jpl/src/m/plot/plot_mesh.js
r21138 r21173 61 61 var node = Node(gl,options); 62 62 canvas.nodes[canvas.nodes.length] = node; 63 scale = 1;63 node["name"] = "mesh"; 64 64 node["shaderName"] = "Colored"; 65 65 node["shader"] = gl["shaders"][node["shaderName"]]; 66 66 node["lineWidth"] = options.getfieldvalue('linewidth',1); 67 node["scale"] = [scale, scale, scale * matrixscale]; 68 node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (2 / scale)]; 67 node["scale"] = [1, 1, matrixscale]; 68 node["rotation"] = [-90, 0, 0]; 69 node["translation"] = [(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2]; 70 node["center"] = [(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2]; 69 71 node["modelMatrix"] = recalculateModelMatrix(node); 70 72 node["drawMode"] = gl.LINES; -
issm/trunk-jpl/src/m/plot/plot_overlay.js
r21164 r21173 15 15 var ymin,ymax; 16 16 var zmin,zmax; 17 var scale,matrixscale,vertexscale;17 var matrixscale,vertexscale; 18 18 19 19 //Process data and model … … 61 61 var node = Node(gl,options); 62 62 canvas.nodes[canvas.nodes.length] = node; 63 scale = 1;64 node["shaderName"] = (options.getfieldvalue(' atmosphere','off') == 'on') ? "GroundFromSpace" : "Textured";63 node["name"] = "overlay"; 64 node["shaderName"] = (options.getfieldvalue('render',[]).indexOf('ground')!=-1) ? "GroundFromSpace" : "Textured"; 65 65 node["shader"] = gl["shaders"][node["shaderName"]]; 66 node["scale"] = [scale, scale, scale * matrixscale]; 67 node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (2 / scale)]; 66 node["scale"] = [1, 1, matrixscale]; 67 node["rotation"] = [-90, 0, 0]; 68 node["translation"] = [(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2]; 69 node["center"] = [(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2]; 68 70 node["modelMatrix"] = recalculateModelMatrix(node); 69 71 node["texture"] = initTexture(gl,options.getfieldvalue('overlay_image')); … … 96 98 zmax = zlim[1]; 97 99 98 node[" translation"] = [node["translation"][0], node["translation"][1], (zmax) / (-1 / scale)];100 node["center"] = [node["center"][0], node["center"][1], -zmax]; 99 101 } 100 102 -
issm/trunk-jpl/src/m/plot/plot_quiver.js
r21138 r21173 63 63 var node = Node(gl,options); 64 64 canvas.nodes[canvas.nodes.length] = node; 65 scale = 1;65 node["name"] = "quiver"; 66 66 node["shaderName"] = "Colored"; 67 67 node["shader"] = gl["shaders"][node["shaderName"]]; 68 68 node["lineWidth"] = options.getfieldvalue('linewidth',1); 69 node["scale"] = [scale, scale, scale * matrixscale]; 70 node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (2 / scale)]; 69 node["scale"] = [1, 1, matrixscale]; 70 node["rotation"] = [-90, 0, 0]; 71 node["translation"] = [(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2]; 72 node["center"] = [(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2]; 71 73 node["modelMatrix"] = recalculateModelMatrix(node); 72 74 node["drawMode"] = gl.LINES; -
issm/trunk-jpl/src/m/plot/plot_unit.js
r21138 r21173 25 25 var zmin,zmax; 26 26 var datamin,datamax,datadelta; 27 var scale,matrixscale,vertexscale;27 var matrixscale,vertexscale; 28 28 29 29 //Compue scaling through matrices for 2d meshes and vertices for 3d meshes … … 63 63 var node = Node(gl,options); 64 64 canvas.nodes[canvas.nodes.length] = node; 65 scale = 1;65 node["name"] = "unit"; 66 66 node["shaderName"] = "Textured"; 67 67 node["shader"] = gl["shaders"][node["shaderName"]]; 68 node["scale"] = [scale, scale, scale * matrixscale]; 69 node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (2 / scale)]; 68 node["scale"] = [1, 1, matrixscale]; 69 node["rotation"] = [-90, 0, 0]; 70 node["translation"] = [(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2]; 71 node["center"] = [(xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2]; 70 72 node["modelMatrix"] = recalculateModelMatrix(node); 71 73 node["alpha"] = options.getfieldvalue('alpha',1.0); … … 75 77 node["maskColor"] = options.getfieldvalue('innermaskcolor',[0.0,0.0,1.0,1.0]); 76 78 node["enabled"] = options.getfieldvalue('nodata','off') == 'off'; 79 vec3.add(canvas.translation, canvas.translation, node["center"]); 77 80 78 81 switch(datatype){ … … 236 239 var buffer = node["mesh"].getBuffer("coords"); 237 240 buffer.data = texcoords[node["movieFrame"]]; 238 buffer.upload( gl.DYNAMIC_DRAW);241 buffer.upload(canvas.gl.DYNAMIC_DRAW); 239 242 }, node["movieInterval"]); 240 243 if (canvas["progressBar"]) { -
issm/trunk-jpl/src/m/plot/plotdoc.js
r21164 r21173 16 16 console.log(' - "mesh": draw mesh using trisurf'); 17 17 console.log(' - "quiver": quiver plot'); 18 console.log(' "2d": renders orthographic camera with view set to [0, 90] (default "off", ex: "on", "off")'); 19 console.log(' "backgroundcolor": plot background color. (default "lightcyan", ex: "green","blue")'); 18 20 console.log(' "caxis": modify colorbar range. (array of type [a, b] where b>=a)'); 19 console.log(' "backgroundcolor": plot background color. (default "lightcyan", ex: "green","blue")');20 21 console.log(' "colorbar": add colorbar (default "off", ex: "on", "off")'); 21 22 console.log(' "colorbarid": colorbar canvas id (string)'); … … 29 30 console.log(' "colorbarheight": multiplier (default 1) to the default height colorbar'); 30 31 console.log(' "colormap": same as standard matlab option (default "jet", ex: "hsv","cool","spring","gray","Ala","Rignot",...)'); 32 console.log(' "controlsensitivity": sensitivty of view/zoom changes as a percentage of default (default 1, ex: 0.5, 2.75)'); 33 console.log(' "displayview": print view value to console (default "off", ex: "on", "off")'); 34 console.log(' "displayzoom": print zoom value to console (default "off", ex: "on", "off")'); 31 35 console.log(' "edgecolor": same as standard matlab option EdgeColor (default "black", ex: color name: "blue" or RGB array: [0.5, 0.2, 0.8])'); 36 console.log(' "heightscale": scaling factor to accentuate height. (default 1, ex: 0.5, 100)'); 37 console.log(' "linewidth*": line width for mesh, quiver, and contour plots, currently limited by WebGL to 1. (default 1, ex: 2, 5)'); 38 console.log(' "log": value of log (default 10, ex: 2, Math.E)'); 39 console.log(' "mask": list of flags of size numberofnodes or numberofelements. Only "true" values are plotted '); 40 console.log(' "moviefps": frames per second when displaying transient runs (default 5, ex: 1, 10)'); 41 console.log(' "innermask*": Special mask that colors all parts of a data mesh below a height a certain color. provide innermaskheight and innermaskcolor options also (default "off", ex: "on", "off")'); 42 console.log(' "outermask*": Special mask that colors all parts of a overlay mesh below a height a certain color. provide outermaskheight and outermaskcolor options also (default "off", ex: "on", "off")'); 43 console.log(' "overlay": overlay a radar amplitude image behind (default "off", ex: "on", "off")'); 44 console.log(' "overlay_image": path to overlay image (default "off", ex: "on", "off")'); 45 console.log(' "scaling": scaling factor used by quiver plots. Default is 0.4'); 46 console.log(' "alpha": transparency coefficient 0.0 to 1.0, the lower, the more transparent. (default 1.0, ex: 0.5, 0.25)'); 47 console.log(' "azlim": azimuth view limits (ex: [0, 180])'); 48 console.log(' "ellim": elevation view limits (ex: [-90, 90])'); 49 console.log(' "origin": initial camera offset from model center (default [0,0,0.0], ex: [-2, 1.5, 0.01])'); 50 console.log(' "render": toggle sky, ground, and space rendering. (default [], ex: ["sky", "space"], ["ground"])'); 32 51 console.log(' "viewPanning": enable view origin panning with two-finger touch or shift+mouse drag. (default "off", ex: "on", "off")'); 33 52 console.log(' "view": initial azimuth and elevation angles for camera (default [0,90], ex: [90, 180]'); 34 console.log(' "zoom": initial camera zoom as a percentage of default (default 1, ex: 1.5, 0.01)');35 console.log(' "centeroffset": initial camera offset from model center (default [0,0,0.0], ex: [-2, 1.5, 0.01])');36 53 console.log(' "xlim": x coordinates to fit inside camera (ex: [0, 500])'); 37 54 console.log(' "ylim": y coordinates to fit inside camera (ex: [0, 500])'); 38 55 console.log(' "zlim": z coordinates to fit inside camera (ex: [0, 500])'); 39 console.log(' "azlim": azimuth view limits (ex: [0, 180])');40 console.log(' "ellim": elevation view limits (ex: [-90, 90])');41 56 console.log(' "zoomlim": zoom view limits (ex: [0.05, 10])'); 42 console.log(' "displayview": print view value to console'); 43 console.log(' "displayzoom": print zoom value to console'); 44 console.log(' "controlsensitivity": sensitivty of view/zoom changes as a percentage of default (default 1, ex: 0.5, 2.75)'); 45 console.log(' "2d": renders orthographic camera with view set to [0, 90] (default "off", ex: "on", "off")'); 46 console.log(' "moviefps": frames per second when displaying transient runs (default 5, ex: 1, 10)'); 47 console.log(' "overlay": overlay a radar amplitude image behind (default "off", ex: "on", "off")'); 48 console.log(' "overlay_image": path to overlay image (default "off", ex: "on", "off")'); 49 console.log(' "atmosphere": toggle atmospheric/skysphere shading. (default "off", ex: "on", "off")'); 50 console.log(' "alpha": transparency coefficient 0.0 to 1.0, the lower, the more transparent. (default 1.0, ex: 0.5, 0.25)'); 51 console.log(' "heightscale": scaling factor to accentuate height. (default 1, ex: 0.5, 100)'); 52 console.log(' "scaling*": scaling factor used by quiver plots. Default is 0.4'); 53 console.log(' "linewidth*": line width for mesh, quiver, and contour plots, currently limited by WebGL to 1. (default 1, ex: 2, 5)'); 57 console.log(' "zoom": initial camera zoom as a percentage of default (default 1, ex: 1.5, 0.01)'); 54 58 console.log(' "cloud*": plot a cloud of points, given a flat array of 3d coordinates (ex: [0.0, 0.0, 0.0, 1.0, 1.0, 1.0])'); 55 59 console.log(' "expdisp*": plot exp file on top of a data plot. provide exp file as an argument (use a cell of strings if more than one)'); 56 60 console.log(' "textlabels*": plot text labels rendered in 3d space, using an array of text/coordinate pairs (ex: [{"pos":[0.0,0.0,0.0],"text":"origin"}])'); 57 console.log(' "outermask*": Special mask that colors all parts of a overlay mesh below a height a certain color. provide outermaskheight and outermaskcolor options also (default "off", ex: "on", "off")'); 58 console.log(' "innermask*": Special mask that colors all parts of a data mesh below a height a certain color. provide innermaskheight and innermaskcolor options also (default "off", ex: "on", "off")'); 59 console.log(' "mask": list of flags of size numberofnodes or numberofelements. Only "true" values are plotted '); 60 console.log(' "log": value of log'); 61 61 62 console.log(' '); 62 63 console.log(' Examples:'); -
issm/trunk-jpl/src/m/plot/webgl.js
r21138 r21173 83 83 } //}}} 84 84 function Node(gl,options) { //{{{ 85 //Returns a Node object that contains default display states for webgl object 86 return {buffers:[], 85 //Returns a Node object that contains default display states for webgl object. center represents pivot point of rotation. 86 return { 87 buffers:[], 88 name:"node", 87 89 shader:gl.shaders["Colored"], 88 90 draw:null, … … 97 99 drawMode:gl.TRIANGLES, 98 100 texture:null, 101 scale:vec3.fromValues(1, 1, 1), 102 rotation:vec3.create(), 99 103 translation:vec3.create(), 100 rotation:vec3.fromValues(-90, 0, 0), 101 scale:vec3.fromValues(1, 1, 1), 104 center:vec3.create(), 102 105 modelMatrix:mat4.create(), 103 106 shaderName:"Colored", … … 106 109 maskHeight:150.0, 107 110 maskColor:vec4.fromValues(0.0, 0.0, 1.0, 1.0), 108 enabled:true ,111 enabled:true 109 112 }; 110 113 } //}}} 114 function displayNodes() { 115 var nodes = $('.sim-canvas')[0].nodes; 116 console.log("Nodes:"); 117 for (var node in nodes) { 118 console.log("name", nodes[node]["name"], "translation", nodes[node]["translation"], "center", nodes[node]["center"], "rotation", nodes[node]["rotation"]); 119 } 120 } 111 121 function recalculateModelMatrix(node) { //{{{ 112 122 //TODO: move to 0,0,0, rotate,move back to normal space, then apply transform 113 123 var modelMatrix = mat4.create(); 114 124 125 var translationMatrix = mat4.create(); 126 mat4.translate(translationMatrix, translationMatrix, [-node["center"][0],-node["center"][1],-node["center"][2]]); //scale/rotation centering 127 mat4.multiply(modelMatrix, translationMatrix, modelMatrix); 128 115 129 var scaleMatrix = mat4.create(); 116 130 mat4.scale(scaleMatrix, scaleMatrix, node["scale"]); 117 131 mat4.multiply(modelMatrix, scaleMatrix, modelMatrix); 118 119 var translationMatrix = mat4.create();120 mat4.translate(translationMatrix, translationMatrix, node["translation"]); //relative translation121 mat4.multiply(modelMatrix, translationMatrix, modelMatrix);122 132 123 133 var zRotationMatrix = mat4.create(); … … 130 140 mat4.rotate(xRotationMatrix, xRotationMatrix, radians(node["rotation"][0]), [1.0, 0.0, 0.0]); 131 141 mat4.multiply(modelMatrix, xRotationMatrix, modelMatrix); 132 142 143 mat4.identity(translationMatrix); 144 mat4.translate(translationMatrix, translationMatrix, node["center"]); //relative translation 145 mat4.multiply(modelMatrix, translationMatrix, modelMatrix); 146 147 // mat4.identity(translationMatrix); 148 // mat4.translate(translationMatrix, translationMatrix, [-node["translation"][0],-node["translation"][1],-node["translation"][2]]); //absolute translation 149 // mat4.multiply(modelMatrix, translationMatrix, modelMatrix); 150 151 mat4.identity(translationMatrix); 152 mat4.translate(translationMatrix, translationMatrix, node["translation"]); //absolute translation 153 mat4.multiply(modelMatrix, translationMatrix, modelMatrix); 133 154 return modelMatrix; 134 155 } //}}} … … 153 174 function loadShaders(gl) { //{{{ 154 175 shaders = {}; 155 shaders["Colored"] = new Shader.fromURL(" /js/shaders/Colored.vsh", "/js/shaders/Colored.fsh");156 shaders["Textured"] = new Shader.fromURL(" /js/shaders/Textured.vsh", "/js/shaders/Textured.fsh");157 shaders["SkyFromSpace"] = new Shader.fromURL(" /js/shaders/SkyFromSpace.vert", "/js/shaders/SkyFromSpace.frag");158 shaders["GroundFromSpace"] = new Shader.fromURL(" /js/shaders/GroundFromSpace.vert", "/js/shaders/GroundFromSpace.frag");176 shaders["Colored"] = new Shader.fromURL("../../../js/shaders/Colored.vsh", "../../../js/shaders/Colored.fsh"); 177 shaders["Textured"] = new Shader.fromURL("../../../js/shaders/Textured.vsh", "../../../js/shaders/Textured.fsh"); 178 shaders["SkyFromSpace"] = new Shader.fromURL("../../../js/shaders/SkyFromSpace.vert", "../../../js/shaders/SkyFromSpace.frag"); 179 shaders["GroundFromSpace"] = new Shader.fromURL("../../../js/shaders/GroundFromSpace.vert", "../../../js/shaders/GroundFromSpace.frag"); 159 180 return shaders; 160 181 } //}}} … … 168 189 if (ev.srcEvent.shiftKey || ev.pointers.length == 2) { 169 190 if (!canvas.viewPanning) return; 170 var deltaX = (canvas.lastDeltaX - ev.deltaX) / canvas.clientWidth / canvas.zoom * -2 * canvas.controlSensitivity ;171 var deltaY = (canvas.lastDeltaY - ev.deltaY) / canvas.clientHeight / canvas.zoom * -2 * canvas.controlSensitivity ;191 var deltaX = (canvas.lastDeltaX - ev.deltaX) / canvas.clientWidth / canvas.zoom * -2 * canvas.controlSensitivity * 6371000.0; 192 var deltaY = (canvas.lastDeltaY - ev.deltaY) / canvas.clientHeight / canvas.zoom * -2 * canvas.controlSensitivity * 6371000.0; 172 193 173 194 if (canvas.twod) { 174 195 canvas.translation[0] += Math.cos(radians(canvas.rotation[0])) * deltaX - Math.sin(radians(0)) * deltaY; 175 canvas.translation[ 1] += Math.sin(radians(canvas.rotation[0])) * deltaX + Math.cos(radians(0)) * deltaY;196 canvas.translation[2] += Math.sin(radians(canvas.rotation[0])) * deltaX + Math.cos(radians(0)) * deltaY; 176 197 } 177 198 else { 178 199 canvas.translation[0] += Math.cos(radians(canvas.rotation[0])) * deltaX - Math.sin(radians(canvas.rotation[0])) * deltaY; 179 canvas.translation[ 1] += Math.sin(radians(canvas.rotation[0])) * deltaX + Math.cos(radians(canvas.rotation[0])) * deltaY;200 canvas.translation[2] += Math.sin(radians(canvas.rotation[0])) * deltaX + Math.cos(radians(canvas.rotation[0])) * deltaY; 180 201 } 181 202 } … … 203 224 } 204 225 else { 205 canvas.zoom = clamp(ev.scale * canvas.zoomLast, canvas.zoomBounds[0], canvas.zoomBounds[1]); 206 if (displaylog) console.log(canvas.zoom); 226 modifyZoom(ev.scale * canvas.zoomLast, canvas, displaylog); 207 227 } 208 228 } //}}} 209 229 function onZoom(ev,canvas,displaylog) { //{{{ 210 230 ev.preventDefault(); 211 var delta = clamp(ev.scale || ev.wheelDelta || -ev.detail, -1, 1) * canvas.controlSensitivity * canvas.zoom / 20; 212 canvas.zoom = clamp(canvas.zoom + delta, canvas.zoomBounds[0], canvas.zoomBounds[1]); 213 231 var delta = clamp(ev.scale || ev.wheelDelta || -ev.detail, -1, 1) * canvas.controlSensitivity * canvas.zoom / 10; 232 modifyZoom(canvas.zoom + delta, canvas, displaylog); 233 } //}}} 234 function modifyZoom(value,canvas,displaylog) { //{{{ 235 canvas.zoom = clamp(value, canvas.zoomBounds[0], canvas.zoomBounds[1]); 214 236 if (displaylog) console.log(canvas.zoom); 215 237 } //}}} … … 230 252 } 231 253 else { 232 mat4.perspective(pMatrix, 60 * Math.PI / 180, aspectRatio, 100 0, 10000000000.0);254 mat4.perspective(pMatrix, 60 * Math.PI / 180, aspectRatio, 100, 1000000000.0); 233 255 } 234 256 235 257 //Apply worldspace translation 236 mat4.translate(translateMatrix, translateMatrix, [ 6371000.0 * canvas.translation[0], 6371000.0 * canvas.translation[2], 6371000.0 * canvas.translation[1]]);258 mat4.translate(translateMatrix, translateMatrix, [-canvas["translation"][0],-canvas["translation"][1],-canvas["translation"][2]]); 237 259 mat4.multiply(vMatrix, translateMatrix, vMatrix); 238 260
Note:
See TracChangeset
for help on using the changeset viewer.