Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orthographic projection in 3D and Columbus view #5021

Merged
merged 53 commits into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
316ea87
Orthographic projection WIP.
bagnell Jan 31, 2017
ee297a3
Fix camera jittering when zooming. Temporarily disable atmosphere and…
bagnell Feb 1, 2017
4b0788a
Disable horizon culling and fog.
bagnell Feb 2, 2017
89fe621
Fix picking culling volume, view rectangle distance. Disable OIT.
bagnell Feb 2, 2017
1c57a52
Fix picking from depth buffer with orthographic projection. Fix zoomi…
bagnell Feb 2, 2017
72d7441
Fix when camera is in a reference frame not the identity.
bagnell Feb 3, 2017
c19cf65
Fix panning on terrain.
bagnell Feb 3, 2017
47174b4
Add separate centered and off-center orthographic frustums.
bagnell Feb 3, 2017
6daca54
Update aspect ratio on canvas resize.
bagnell Feb 3, 2017
d3aef4e
Disable environmental effects.
bagnell Feb 3, 2017
dc6d9a7
Fix OIT.
bagnell Feb 3, 2017
75a0367
Merge branch 'master' into ortho-3d
bagnell Feb 15, 2017
7b31fb9
Another fix for OIT.
bagnell Feb 16, 2017
08b1ff4
Only adjust orthographic frustum width on zoom. Makes panning and til…
bagnell Feb 17, 2017
34cf3e4
Fix viewing a rectangle in 3d.
bagnell Feb 17, 2017
4d92e00
Add projection picker widget. Still need svgs.
bagnell Feb 17, 2017
50f97b0
Fix mouse input camera interaction when in columbus view with an orth…
bagnell Feb 20, 2017
4ebcc64
Tweak adjusting the frustum width based on depth buffer pick or terra…
bagnell Feb 20, 2017
f7ee919
Fix issue with zoom where the camera wouldn't focus on the target pos…
bagnell Feb 20, 2017
303b568
Fix height and zoom when switching to orthographic mode.
bagnell Feb 20, 2017
b059be9
New icons for perspective and orthographic.
emackey Feb 21, 2017
110027f
Merge pull request #5020 from AnalyticalGraphicsInc/persp-ortho-icons
bagnell Feb 21, 2017
51b53b8
Rename OrthographicFrustumSpec -> OrthographicOffCenterFrustumSpec.
bagnell Feb 21, 2017
fbf5d77
Fix broken tests.
bagnell Feb 21, 2017
9e1f19f
Merge branch 'master' into ortho-3d
bagnell Feb 22, 2017
0af61cc
Remove slide animation when switching projection and correctly hide d…
bagnell Feb 22, 2017
4ab7c6d
Grey out the button when in 2D.
bagnell Feb 22, 2017
b09ab6e
Disable button, disable drop down and display orthographic icon in 2D.
bagnell Feb 22, 2017
e51da6a
Fix icon after morphs. Keep orthographic when morphing from 3D to 2D/…
bagnell Feb 22, 2017
b335fcc
Add checks for write types of frustums in the current scene mode.
bagnell Feb 22, 2017
5389dab
Fix shadows and OIT in orthographic.
bagnell Feb 23, 2017
4040a1b
Fix zooming issue.
bagnell Feb 24, 2017
d5d8ebd
Fix WGS84 to window coordinates.
bagnell Feb 27, 2017
0ada6b0
Enable fog with an orthographic projection.
bagnell Feb 27, 2017
45e26f8
Add tests.
bagnell Feb 28, 2017
4d7f8c7
Merge branch 'master' into ortho-3d
bagnell Mar 7, 2017
fa2200e
slightly extend skirts away from the mesh instead of dropping them st…
bagnell Mar 7, 2017
f32f814
Add flanges to heightmap tessellator.
bagnell Mar 8, 2017
b1b29ed
Preserve projection when morphing.
bagnell Mar 8, 2017
d8481d8
Adjust ortho frustum when moving camera, fix camera changed event, di…
bagnell Mar 8, 2017
403ffe3
Merge branch 'master' into ortho-3d
bagnell Mar 8, 2017
0ab7292
Fix tests.
bagnell Mar 9, 2017
dd5e8ce
Add projection picker tests.
bagnell Mar 9, 2017
cf71123
Disable VR button when in orthographic.
bagnell Mar 9, 2017
3937422
Deprecate OrthographicFrustum plane distance properties.
bagnell Mar 9, 2017
620c090
Code updates from review.
bagnell Mar 9, 2017
b0f06c5
Update debug camera for orthographic projections.
bagnell Mar 9, 2017
e13bc3d
Adjust frustum when morphing and when the camera is above a certain h…
bagnell Mar 13, 2017
6c7f5bb
Update CHANGES.md.
bagnell Mar 13, 2017
ad83a40
Merge branch 'master' into ortho-3d
bagnell Mar 14, 2017
e2ecaa0
Fix camera when click-dragging space close to the surface.
bagnell Mar 15, 2017
0dc974d
Merge branch 'master' into ortho-3d
bagnell Mar 15, 2017
9182136
Default to not creating the projection picker.
bagnell Mar 15, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/development/Shadows.html
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@
var frustumSize = 55.0;
var frustumNear = 1.0;
var frustumFar = 400.0;
var frustum = new Cesium.OrthographicFrustum();
var frustum = new Cesium.OrthographicOffCenterFrustum();
frustum.left = -frustumSize;
frustum.right = frustumSize;
frustum.bottom = -frustumSize;
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Change Log

### 1.32 - 2017-04-03

* Deprecated
* The `left`, `right`, `bottom`, and `top` properties of `OrthographicFrustum` are deprecated and will be removed in 1.33. Use `OrthographicOffCenterFrustum` instead.
* Added `Camera.flyTo` and `Camera.flyToBoundingSphere` options [#5070](https://github.com/AnalyticalGraphicsInc/cesium/pull/5070)
* `flyOverLongitude` to select one of two possible on Globe paths which camera should fly.
* `flyOverLongitudeWeight` to set a threshold: how many times the `flyOverLongitude` way can be than shortest path.
Expand All @@ -15,6 +17,7 @@ Change Log
* Fixed an issue with `PinBuilder` where inset images could have low-alpha fringes against an opaque background. [#5099](https://github.com/AnalyticalGraphicsInc/cesium/pull/5099)
* Fixed a bug in `ModelAnimationCache` causing different animations to reference the same animation. [#5064](https://github.com/AnalyticalGraphicsInc/cesium/pull/5064)
* Fixed a bug that caused an exception in `CesiumInspectorViewModel` when using the NW / NE / SW / SE / Parent buttons to navigate to a terrain tile that is not yet loaded.
* Added support for an orthographic projection in 3D and Columbus view. Set `projectionPicker` to `true` in the options when creating a `Viewer` to add a widget that will switch projections. [#5021](https://github.com/AnalyticalGraphicsInc/cesium/pull/5021)

### 1.31 - 2017-03-01

Expand Down
30 changes: 24 additions & 6 deletions Source/Core/HeightmapTessellator.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ define([
var elementMultiplier = defaultValue(structure.elementMultiplier, HeightmapTessellator.DEFAULT_STRUCTURE.elementMultiplier);
var isBigEndian = defaultValue(structure.isBigEndian, HeightmapTessellator.DEFAULT_STRUCTURE.isBigEndian);

var granularityX = Rectangle.computeWidth(nativeRectangle) / (width - 1);
var granularityY = Rectangle.computeHeight(nativeRectangle) / (height - 1);
var rectangleWidth = Rectangle.computeWidth(nativeRectangle);
var rectangleHeight = Rectangle.computeHeight(nativeRectangle);

var granularityX = rectangleWidth / (width - 1);
var granularityY = rectangleHeight / (height - 1);

var radiiSquared = ellipsoid.radiiSquared;
var radiiSquaredX = radiiSquared.x;
Expand Down Expand Up @@ -337,10 +340,29 @@ define([

heightSample = (heightSample * heightScale + heightOffset) * exaggeration;

var u = (longitude - geographicWest) / (geographicEast - geographicWest);
u = CesiumMath.clamp(u, 0.0, 1.0);
uvs[index] = new Cartesian2(u, v);

maximumHeight = Math.max(maximumHeight, heightSample);
minimumHeight = Math.min(minimumHeight, heightSample);

if (colIndex !== col || rowIndex !== row) {
var percentage = 0.00001;
if (colIndex < 0) {
longitude -= percentage * rectangleWidth;
} else {
longitude += percentage * rectangleWidth;
}
if (rowIndex < 0) {
latitude += percentage * rectangleHeight;
} else {
latitude -= percentage * rectangleHeight;
}

cosLatitude = cos(latitude);
nZ = sin(latitude);
kZ = radiiSquaredZ * nZ;
heightSample -= skirtHeight;
}

Expand All @@ -365,10 +387,6 @@ define([
positions[index] = position;
heights[index] = heightSample;

var u = (longitude - geographicWest) / (geographicEast - geographicWest);
u = CesiumMath.clamp(u, 0.0, 1.0);
uvs[index] = new Cartesian2(u, v);

if (includeWebMercatorT) {
webMercatorTs[index] = webMercatorT;
}
Expand Down
11 changes: 0 additions & 11 deletions Source/Renderer/AutomaticUniforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,17 +530,6 @@ define([
}
}),

/**
* @private
*/
czm_inverseProjectionOIT : new AutomaticUniform({
size : 1,
datatype : WebGLConstants.FLOAT_MAT4,
getValue : function(uniformState) {
return uniformState.inverseProjectionOIT;
}
}),

/**
* An automatic GLSL uniform representing a 4x4 projection transformation matrix with the far plane at infinity,
* that transforms eye coordinates to clip coordinates. Clip coordinates is the
Expand Down
36 changes: 9 additions & 27 deletions Source/Renderer/UniformState.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define([
'../Core/Matrix4',
'../Core/Simon1994PlanetaryPositions',
'../Core/Transforms',
'../Scene/OrthographicFrustum',
'../Scene/SceneMode'
], function(
BoundingRectangle,
Expand All @@ -28,6 +29,7 @@ define([
Matrix4,
Simon1994PlanetaryPositions,
Transforms,
OrthographicFrustum,
SceneMode) {
'use strict';

Expand Down Expand Up @@ -80,9 +82,6 @@ define([
this._inverseProjectionDirty = true;
this._inverseProjection = new Matrix4();

this._inverseProjectionOITDirty = true;
this._inverseProjectionOIT = new Matrix4();

this._modelViewDirty = true;
this._modelView = new Matrix4();

Expand Down Expand Up @@ -147,6 +146,7 @@ define([
this._frustum2DWidth = 0.0;
this._eyeHeight2D = new Cartesian2();
this._resolutionScale = 1.0;
this._orthographicIn3D = false;

this._fogDensity = undefined;

Expand Down Expand Up @@ -393,17 +393,6 @@ define([
}
},

/**
* @memberof UniformState.prototype
* @private
*/
inverseProjectionOIT : {
get : function() {
cleanInverseProjectionOIT(this);
return this._inverseProjectionOIT;
}
},

/**
* @memberof UniformState.prototype
* @type {Matrix4}
Expand Down Expand Up @@ -834,7 +823,6 @@ define([
Matrix4.clone(matrix, uniformState._projection);

uniformState._inverseProjectionDirty = true;
uniformState._inverseProjectionOITDirty = true;
uniformState._viewProjectionDirty = true;
uniformState._inverseViewProjectionDirty = true;
uniformState._modelViewProjectionDirty = true;
Expand Down Expand Up @@ -896,6 +884,8 @@ define([
this._entireFrustum.x = camera.frustum.near;
this._entireFrustum.y = camera.frustum.far;
this.updateFrustum(camera.frustum);

this._orthographicIn3D = this._mode !== SceneMode.SCENE2D && camera.frustum instanceof OrthographicFrustum;
};

/**
Expand All @@ -913,7 +903,7 @@ define([
this._currentFrustum.x = frustum.near;
this._currentFrustum.y = frustum.far;

if (!defined(frustum.top)) {
if (defined(frustum._offCenterFrustum)) {
frustum = frustum._offCenterFrustum;
}

Expand Down Expand Up @@ -987,18 +977,10 @@ define([
if (uniformState._inverseProjectionDirty) {
uniformState._inverseProjectionDirty = false;

Matrix4.inverse(uniformState._projection, uniformState._inverseProjection);
}
}

function cleanInverseProjectionOIT(uniformState) {
if (uniformState._inverseProjectionOITDirty) {
uniformState._inverseProjectionOITDirty = false;

if (uniformState._mode !== SceneMode.SCENE2D && uniformState._mode !== SceneMode.MORPHING) {
Matrix4.inverse(uniformState._projection, uniformState._inverseProjectionOIT);
if (uniformState._mode !== SceneMode.SCENE2D && uniformState._mode !== SceneMode.MORPHING && !uniformState._orthographicIn3D) {
Matrix4.inverse(uniformState._projection, uniformState._inverseProjection);
} else {
Matrix4.clone(Matrix4.IDENTITY, uniformState._inverseProjectionOIT);
Matrix4.clone(Matrix4.ZERO, uniformState._inverseProjection);
}
}
}
Expand Down
Loading