[21337] | 1 | Index: ../trunk-jpl/src/m/plot/webgl.js
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/m/plot/webgl.js (revision 20769)
|
---|
| 4 | +++ ../trunk-jpl/src/m/plot/webgl.js (revision 20770)
|
---|
| 5 | @@ -49,7 +49,7 @@
|
---|
| 6 | canvas.zoomFactor = clamp(options.getfieldvalue('zoom',1.0), canvas.zoomBounds[0], canvas.zoomBounds[1]);
|
---|
| 7 | canvas.zoomLast = canvas.zoomFactor;
|
---|
| 8 | canvas.cameraMatrix = mat4.create();
|
---|
| 9 | - canvas.translation = options.getfieldvalue('centeroffset',[0,0,0.0]);
|
---|
| 10 | + canvas.translation = options.getfieldvalue('origin',[0,0,0.0]);
|
---|
| 11 | canvas.rotationAzimuthBounds = options.getfieldvalue('azlim',[0,360]);
|
---|
| 12 | canvas.rotationElevationBounds = options.getfieldvalue('ellim',[-180,180]);
|
---|
| 13 | canvas.rotationDefault = options.getfieldvalue('view',[0,90]); //0 azimuth - up is north, 90 elevation - looking straight down
|
---|
| 14 | @@ -60,13 +60,6 @@
|
---|
| 15 | canvas.movieReverse = false;
|
---|
| 16 | canvas.movieIncrement = true;
|
---|
| 17 | canvas.moviefps = options.getfieldvalue('moviefps',5);
|
---|
| 18 | -
|
---|
| 19 | - if (canvas.twod) {
|
---|
| 20 | - canvas.rotationAzimuthBounds = [0,0];
|
---|
| 21 | - canvas.rotationElevationBounds = [90,90];
|
---|
| 22 | - canvas.rotationDefault = [0,90];
|
---|
| 23 | - canvas.rotation = canvas.rotationDefault;
|
---|
| 24 | - }
|
---|
| 25 |
|
---|
| 26 | // Add event listeners for canvas
|
---|
| 27 | var displayview = options.getfieldvalue('displayview','off') == 'on';
|
---|
| 28 | @@ -395,12 +388,13 @@
|
---|
| 29 | var rotationMatrix = mat4.create();
|
---|
| 30 | var azimuthRotationMatrix = mat4.create();
|
---|
| 31 | var elevationRotationMatrix = mat4.create();
|
---|
| 32 | + var aspectRatio = canvas.clientWidth / canvas.clientHeight;
|
---|
| 33 |
|
---|
| 34 | if (canvas.twod) {
|
---|
| 35 | - mat4.ortho(pMatrix, -1/canvas.zoomFactor, 1/canvas.zoomFactor, -1/canvas.zoomFactor, 1/canvas.zoomFactor, -1.0, 10000.0);
|
---|
| 36 | + mat4.ortho(pMatrix, -1*aspectRatio/canvas.zoomFactor, 1*aspectRatio/canvas.zoomFactor, -1*aspectRatio/canvas.zoomFactor, 1*aspectRatio/canvas.zoomFactor, -1.0, 10000.0);
|
---|
| 37 | }
|
---|
| 38 | else {
|
---|
| 39 | - mat4.perspective(pMatrix, 60 * Math.PI / 180, canvas.clientWidth / canvas.clientHeight, 0.001, 10000.0);
|
---|
| 40 | + mat4.perspective(pMatrix, 60 * Math.PI / 180, aspectRatio, 0.001, 10000.0);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | //Apply worldspace translation
|
---|
| 44 | @@ -408,9 +402,16 @@
|
---|
| 45 | mat4.multiply(vMatrix, translateMatrix, vMatrix);
|
---|
| 46 |
|
---|
| 47 | //Calculate rotation around camera focal point about worldspace origin
|
---|
| 48 | - mat4.rotate(azimuthRotationMatrix, azimuthRotationMatrix, radians(canvas.rotation[0]), [0, 1, 0]);
|
---|
| 49 | - mat4.rotate(elevationRotationMatrix, elevationRotationMatrix, radians(canvas.rotation[1]), [1, 0, 0]);
|
---|
| 50 | - mat4.multiply(rotationMatrix, elevationRotationMatrix, azimuthRotationMatrix);
|
---|
| 51 | + if (canvas.twod) {
|
---|
| 52 | + mat4.rotate(azimuthRotationMatrix, azimuthRotationMatrix, radians(canvas.rotation[0]), [0, 1, 0]);
|
---|
| 53 | + mat4.rotate(elevationRotationMatrix, elevationRotationMatrix, radians(canvas.rotation[1]), [1, 0, 0]);
|
---|
| 54 | + mat4.multiply(rotationMatrix, elevationRotationMatrix, azimuthRotationMatrix);
|
---|
| 55 | + }
|
---|
| 56 | + else {
|
---|
| 57 | + mat4.rotate(azimuthRotationMatrix, azimuthRotationMatrix, radians(0), [0, 1, 0]);
|
---|
| 58 | + mat4.rotate(elevationRotationMatrix, elevationRotationMatrix, radians(90), [1, 0, 0]);
|
---|
| 59 | + mat4.multiply(rotationMatrix, elevationRotationMatrix, azimuthRotationMatrix);
|
---|
| 60 | + }
|
---|
| 61 |
|
---|
| 62 | //Apply rotation and scaling transform
|
---|
| 63 | mat4.multiply(vMatrix, rotationMatrix, vMatrix);
|
---|