Changeset 19919
- Timestamp:
- 12/30/15 18:22:41 (9 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/plot_mesh.js
r19915 r19919 50 50 node["overlay"] = false; 51 51 node["drawOrder"] = 0; 52 node["maskEnabled"] = options.exist('mask'); 53 node["maskHeight"] = options.getfieldvalue('maskheight',150.0)*options.getfieldvalue('heightscale',1); 54 node["maskColor"] = options.getfieldvalue('maskcolor',[0.0,0.0,1.0,1.0]); 52 55 53 56 //some defaults: -
issm/trunk-jpl/src/m/plot/plot_overlay.js
r19917 r19919 55 55 node["overlay"] = false; 56 56 node["drawOrder"] = 1; 57 node["maskEnabled"] = options.getfieldvalue('outermask','off') == 'on'; 58 node["maskHeight"] = options.getfieldvalue('outermaskheight',150.0)*options.getfieldvalue('heightscale',1); 59 node["maskColor"] = options.getfieldvalue('outermaskcolor',[0.0,0.0,1.0,1.0]); 57 60 58 61 //some defaults: -
issm/trunk-jpl/src/m/plot/plot_unit.js
r19917 r19919 61 61 node["overlay"] = options.getfieldvalue('overlay','off') == 'on'; 62 62 node["drawOrder"] = 0; 63 node["maskEnabled"] = options.getfieldvalue('innermask','off') == 'on'; 64 node["maskHeight"] = options.getfieldvalue('innermaskheight',150.0)*options.getfieldvalue('heightscale',1); 65 node["maskColor"] = options.getfieldvalue('innermaskcolor',[0.0,0.0,1.0,1.0]); 63 66 64 67 switch(datatype){ -
issm/trunk-jpl/src/m/plot/webgl.js
r19918 r19919 51 51 var mc = new Hammer.Manager(canvas); 52 52 53 mc.add(new Hammer.Pan({ threshold: 0, pointers: 0}));54 mc.add(new Hammer.Pinch({ threshold:0})).recognizeWith(mc.get('pan'));53 mc.add(new Hammer.Pan({threshold:0, pointers:0})); 54 mc.add(new Hammer.Pinch({threshold:0})).recognizeWith(mc.get('pan')); 55 55 56 56 mc.on("panstart panmove", function (ev) {onPan(ev,canvas);}); … … 124 124 overlay:false, 125 125 drawOrder:0, 126 maskEnabled:false, 127 maskHeight:150.0, 128 maskColor:vec4.fromValues(0.0, 0.0, 1.0, 1.0), 126 129 }; 127 130 } //}}} … … 194 197 '', 195 198 'varying vec2 vTextureCoord;', 199 'varying float vZCoord;', 196 200 '', 197 201 'void main(void) {', 198 202 ' gl_Position = uMVPMatrix * vec4(aVertexPosition.xyz, 1.0);', 199 203 ' vTextureCoord = aTextureCoord;', 204 ' vZCoord = aVertexPosition.z;', 200 205 '}'].join('\n'); 201 206 shaders["unlit_textured"]["fsh"]["string"] = … … 203 208 '', 204 209 'varying vec2 vTextureCoord;', 210 'varying float vZCoord;', 205 211 '', 206 212 'uniform sampler2D uColorSampler;', 207 213 'uniform float uAlpha;', 214 'uniform bool uMaskEnabled;', 215 'uniform float uMaskHeight;', 216 'uniform vec4 uMaskColor;', 208 217 '', 209 218 'void main(void) {', 210 ' gl_FragColor = vec4(texture2D(uColorSampler, vec2(vTextureCoord.s, vTextureCoord.t)).rgb, uAlpha);', 219 ' if (uMaskEnabled && (vZCoord < uMaskHeight)) {', 220 ' gl_FragColor = uMaskColor;', 221 ' }', 222 ' else {', 223 ' gl_FragColor = vec4(texture2D(uColorSampler, vec2(vTextureCoord.s, vTextureCoord.t)).rgb, uAlpha);', 224 ' }', 211 225 '}'].join('\n'); 212 226 shaderNames.forEach(function(shaderName){ … … 290 304 canvas.lastDeltaY = 0; 291 305 } 292 // if single finger/pan without modifier key, rotate around center 293 //canvas.translation[0] += (canvas.lastDeltaX - ev.deltaX) / canvas.clientWidth * canvas.zoomFactor * 2; 294 //canvas.translation[1] -= (canvas.lastDeltaY - ev.deltaY) / canvas.clientHeight * canvas.zoomFactor * 2; 295 // else if double finger/pan with modifier key, move camera center 296 canvas.rotation[0] += degrees((canvas.lastDeltaX - ev.deltaX) / canvas.clientWidth * canvas.zoomFactor * 2); 297 canvas.rotation[1] += degrees((canvas.lastDeltaY - ev.deltaY) / canvas.clientHeight * canvas.zoomFactor * 2); 298 299 if (canvas.rotation[0] > 360) {canvas.rotation[0] -= 360}; 300 if (canvas.rotation[0] < 0) {canvas.rotation[0] += 360}; 301 if (canvas.rotation[1] > 180) {canvas.rotation[1] -= 360}; 302 if (canvas.rotation[1] < -180) {canvas.rotation[1] += 360}; 303 304 canvas.rotation[0] = clamp(canvas.rotation[0], canvas.rotationAzimuthBounds[0], canvas.rotationAzimuthBounds[1]); 305 canvas.rotation[1] = clamp(canvas.rotation[1], canvas.rotationElevationBounds[0], canvas.rotationElevationBounds[1]) 306 306 if (ev.srcEvent.shiftKey || ev.pointers.length == 2) { 307 var deltaX = (canvas.lastDeltaX - ev.deltaX) / canvas.clientWidth * canvas.zoomFactor * 2; 308 var deltaY = (canvas.lastDeltaY - ev.deltaY) / canvas.clientHeight * canvas.zoomFactor * 2; 309 310 canvas.translation[0] += Math.cos(radians(canvas.rotation[0])) * deltaX - Math.sin(radians(canvas.rotation[0])) * deltaY; 311 //console.log(Math.cos(radians(canvas.rotation[0])) * deltaX, Math.sin(radians(canvas.rotation[0])) * deltaY); 312 canvas.translation[1] += Math.sin(radians(canvas.rotation[0])) * deltaX + Math.cos(radians(canvas.rotation[0])) * deltaY; 313 } 314 else { 315 canvas.rotation[0] += degrees((canvas.lastDeltaX - ev.deltaX) / canvas.clientWidth * canvas.zoomFactor * 2); 316 canvas.rotation[1] += degrees((canvas.lastDeltaY - ev.deltaY) / canvas.clientHeight * canvas.zoomFactor * 2); 317 318 if (canvas.rotation[0] > 360) {canvas.rotation[0] -= 360}; 319 if (canvas.rotation[0] < 0) {canvas.rotation[0] += 360}; 320 if (canvas.rotation[1] > 180) {canvas.rotation[1] -= 360}; 321 if (canvas.rotation[1] < -180) {canvas.rotation[1] += 360}; 322 323 canvas.rotation[0] = clamp(canvas.rotation[0], canvas.rotationAzimuthBounds[0], canvas.rotationAzimuthBounds[1]); 324 canvas.rotation[1] = clamp(canvas.rotation[1], canvas.rotationElevationBounds[0], canvas.rotationElevationBounds[1]) 325 } 307 326 canvas.lastDeltaX = ev.deltaX; 308 327 canvas.lastDeltaY = ev.deltaY; … … 329 348 //{{{ Drawing Functions 330 349 function updateCameraMatrix(canvas) { //{{{ 331 350 //Update view matrix and multiply with projection matrix to get the view-projection (camera) matrix. 332 351 var vMatrix = mat4.create(); 333 352 var pMatrix = mat4.create(); 353 var translateMatrix = mat4.create(); 334 354 var rotationMatrix = mat4.create(); 335 355 var azimuthRotationMatrix = mat4.create(); … … 337 357 338 358 mat4.perspective(pMatrix, 90 * Math.PI / 180, canvas.clientWidth / canvas.clientHeight, 0.001, 10000.0); 359 360 //Apply worldspace translation 361 mat4.translate(translateMatrix, translateMatrix, [canvas.translation[0], 0.0, canvas.translation[1]]); 362 mat4.multiply(vMatrix, translateMatrix, vMatrix); 339 363 340 364 //Calculate rotation around camera focal point about worldspace origin … … 346 370 mat4.multiply(vMatrix, rotationMatrix, vMatrix); 347 371 348 //Apply screenspace relativetranslation349 var translateMatrix = mat4.create();350 mat4.translate(translateMatrix, translateMatrix, [ canvas.translation[0], canvas.translation[1], canvas.zoomFactor]);372 //Apply screenspace translation 373 mat4.identity(translateMatrix); 374 mat4.translate(translateMatrix, translateMatrix, [0.0, 0.0, canvas.zoomFactor]); 351 375 mat4.multiply(vMatrix, translateMatrix, vMatrix); 352 376 … … 371 395 gl.uniformMatrix4fv(node["shader"]["uMVPMatrix"], false, mvpMatrix); 372 396 gl.uniform1f(node["shader"]["uAlpha"], node["alpha"]); 397 gl.uniform1i(node["shader"]["uMaskEnabled"], node["maskEnabled"]); 398 gl.uniform1f(node["shader"]["uMaskHeight"], node["maskHeight"]); 399 gl.uniform4fv(node["shader"]["uMaskColor"], node["maskColor"]); 373 400 if (node["texture"]) { 374 401 gl.activeTexture(gl.TEXTURE0);
Note:
See TracChangeset
for help on using the changeset viewer.