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

Camera-Terrain interaction #1817

Merged
merged 107 commits into from
Jul 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
c70cb42
Do not release terrain mesh data after creating vertex array.
bagnell Apr 17, 2014
c84f71a
Add ray-triangle intersection test.
bagnell Apr 17, 2014
9105d24
Add ray-triangle intersection tests.
bagnell Apr 18, 2014
9602ee4
Add ray-sphere intersection test.
bagnell Apr 18, 2014
2fbcfca
Pick rendered tiles bounding spheres.
bagnell Apr 18, 2014
1ebae09
Pick terrain mesh.
bagnell Apr 22, 2014
2da8bb8
Merge branch 'master' into pick-terrain
bagnell Apr 25, 2014
1342a26
Updates after merge.
bagnell Apr 25, 2014
0265c35
Merge branch 'master' into pick-terrain
bagnell May 1, 2014
5a029eb
Pan terrain in 3D.
bagnell May 6, 2014
0519daf
Merge branch 'master' into pick-terrain
bagnell May 6, 2014
ffd4b44
Pick terrain when tilting in 3D.
bagnell May 6, 2014
00c923f
Add picking terrain and use it when tilting in Columbus view.
bagnell May 7, 2014
24e7da0
Pick terrain in Columbus view when panning.
bagnell May 7, 2014
3f88921
Some clean up.
bagnell May 7, 2014
811ca11
Merge branch 'master' into pick-terrain
bagnell May 7, 2014
76f2bf6
Some more clean up.
bagnell May 7, 2014
04c9464
Fix Sandcastle examples, dynamic object view, and widgets.
bagnell May 7, 2014
b7271ca
Fix Geocoder and HomeButton after last change.
bagnell May 7, 2014
cbf3369
Fix ScreenSpaceCameraController, Geocoder, and HomeButton specs.
bagnell May 8, 2014
f4727fe
Merge branch 'master' into pick-terrain
bagnell May 8, 2014
4ef69e5
Fix tile tests and state machine.
bagnell May 8, 2014
b8a993e
Tilt around picked point.
bagnell May 9, 2014
7ac5b6d
Remove tilt from grazing altitude. Fixes tilting for horizon views an…
bagnell May 9, 2014
4bd2f54
Better mouse handling around the constrained axis.
bagnell May 12, 2014
3d07697
Fix rolling over constrained axis when tilting.
bagnell May 12, 2014
086214c
Clean up allocations.
bagnell May 12, 2014
4d3a8e3
Add tilt around mouse position to Columbus view.
bagnell May 12, 2014
2fe8fc8
Merge branch 'master' into pick-terrain
bagnell May 13, 2014
7a7fad0
Merge branch 'pick-terrain' into tilt-zoom
bagnell May 13, 2014
f63f9ca
Merge branch 'pick-terrain' into camera-terrain
bagnell May 15, 2014
fd8301b
Merge branch 'tilt-zoom' into camera-terrain
bagnell May 15, 2014
ea85024
Fix tests.
bagnell May 16, 2014
2ad5731
Merge branch 'master' into camera-terrain
bagnell May 22, 2014
0766abe
Merge branch 'master' into camera-terrain-merge
bagnell May 22, 2014
5833629
Fix tilting in Columbus view after merge.
bagnell May 23, 2014
8c156b9
Merge branch 'master' into camera-terrain
bagnell May 28, 2014
dd4b158
Add terrain picking that goes through the quad tree instead of the li…
bagnell May 28, 2014
5f79912
Initial camera collision detection/response with terrain. Only works …
bagnell May 31, 2014
0da29d8
Merge branch 'master' into camera-terrain
bagnell Jun 3, 2014
52d6ff3
Merge branch 'camera-terrain' into pick-terrain
bagnell Jun 3, 2014
994fb44
Fix tests.
bagnell Jun 4, 2014
b4a4bd6
Merge branch 'camera-terrain' into pick-terrain
bagnell Jun 4, 2014
012a92f
Add sphere-plane and circle-circle intersection tests.
bagnell Jun 4, 2014
2a506e0
Add plane-plane intersection and 2D line-circle intersection.
bagnell Jun 5, 2014
6ffd412
Merge branch 'master' into camera-terrain
bagnell Jun 5, 2014
6beff5e
Merge branch 'camera-terrain' into pick-terrain
bagnell Jun 5, 2014
69f6483
Add triangle-circle arc intersection test.
bagnell Jun 5, 2014
edb0f7f
Add terrain arc intersection test.
bagnell Jun 5, 2014
658beab
Some terrain arc intersection fixes.
bagnell Jun 6, 2014
7ed6e44
Merge branch 'camera-terrain' into use-ray-intersection
bagnell Jun 6, 2014
ecf42b0
Discretize arc of circle into line segments to use for camera-terrain…
bagnell Jun 7, 2014
4df3dde
Fix intersection when tilting left. Add intersection tests when panni…
bagnell Jun 9, 2014
6b06e29
Merge branch 'use-ray-intersection' into pick-terrain
bagnell Jun 9, 2014
4aabf29
Clean up intersection tests.
bagnell Jun 9, 2014
4ba6870
Clean up and add doc.
bagnell Jun 9, 2014
faa232c
Fix tests.
bagnell Jun 9, 2014
0596893
Update doc and add intersection test specs.
bagnell Jun 9, 2014
a41ea5d
Some fixes after renames and for 2D/CV.
bagnell Jun 9, 2014
9e1550e
Merge branch 'master' into camera-terrain
bagnell Jun 9, 2014
cf100aa
Merge branch 'camera-terrain' into pick-terrain
bagnell Jun 9, 2014
4d8c4f4
Add camera-terrain collision detection to Columbus view.
bagnell Jun 10, 2014
31bbebf
Clean up garbage.
bagnell Jun 10, 2014
2a2dbc2
Add minimum camera height for picking terrain and minimum height for …
bagnell Jun 10, 2014
3ff77a7
Tweak distance moved back from intersection. Use one ray.
bagnell Jun 10, 2014
2be50be
Use a single line segment from camera position to end position after …
bagnell Jun 10, 2014
ebe8cd8
Add line segment-sphere intersection to reduce the number of terrain …
bagnell Jun 10, 2014
10916d5
Add a fast vector rotation by a quaternion.
bagnell Jun 11, 2014
2de6ffc
Merge branch 'master' into camera-terrain
bagnell Jun 11, 2014
d495ba7
Fix Sandcastle example after merge.
bagnell Jun 11, 2014
74dcd8a
Merge branch 'camera-terrain' into pick-terrain
bagnell Jun 11, 2014
4c4dda9
Update CHANGES.md.
bagnell Jun 11, 2014
6b96607
Merge branch 'master' into camera-terrain
bagnell Jun 12, 2014
eddce95
Fix tests after merge.
bagnell Jun 12, 2014
a19f47c
Use a new method for camera collision response.
bagnell Jun 12, 2014
493d57a
Fix crash when tilting. Allow tilting below the point clicked. Remove…
bagnell Jun 13, 2014
3c5549e
Adjust camera orientation after collision with terrain when tilting.
bagnell Jun 13, 2014
5f08530
Adjust camera orientation after collision with terrain when tilting i…
bagnell Jun 13, 2014
37aee14
Adjust camera orientation after tilting without a contrained axis (th…
bagnell Jun 16, 2014
74facc1
Update CHANGES.md and remove unused code.
bagnell Jun 16, 2014
097a74c
Fix panning when looking up at terrain.
bagnell Jun 17, 2014
9833ca3
Fix abrupt orientation change from tiltting when the camera direction…
bagnell Jun 17, 2014
caf1bf4
Merge branch 'master' into camera-terrain
bagnell Jun 18, 2014
9f94ee7
Remove ScreenSpaceCameraController.globe. Fix panning when mouse is o…
bagnell Jun 23, 2014
b78d2ea
Fix Columbus view issue tilting in the wrong direction.
bagnell Jun 23, 2014
d29c9d2
Only roll up the terrain for horizontal tilts, not vertical.
bagnell Jun 23, 2014
5adc1fe
Adjust zoom speed to account for terrain. Fix pan direction in Columb…
bagnell Jun 24, 2014
9222a30
Merge branch 'master' into camera-terrain
bagnell Jun 24, 2014
56da73c
Fix jsHint error and probably the 3D model Sandcastle example.
bagnell Jun 24, 2014
ab047fc
Merge branch 'master' into camera-terrain
bagnell Jun 25, 2014
e113629
Do not start a pan when clicking the sky, but continue to pan when te…
bagnell Jun 25, 2014
a4a95ff
Merge branch 'master' into camera-terrain
bagnell Jun 30, 2014
61c2564
Better panning when camera height is below terrain clicked.
bagnell Jul 1, 2014
27ff51a
Merge branch 'master' into camera-terrain
bagnell Jul 1, 2014
38e96fa
Code updates based on review.
bagnell Jul 1, 2014
f5f9bf1
Slightly better panning when camera height is less that the terrain c…
bagnell Jul 2, 2014
4d78093
Tweak CHANGES.md
pjcozzi Jul 2, 2014
9357a4f
Merge branch 'master' into camera-terrain
bagnell Jul 14, 2014
6eadfaf
Fixes after merge.
bagnell Jul 14, 2014
178ceab
Merge branch 'camera-terrain-merged' into camera-terrain
bagnell Jul 14, 2014
a0c73f1
Merge branch 'master' into camera-terrain
bagnell Jul 16, 2014
f448b38
Revert tilt behavior in columbus view to tilt about the center of the…
bagnell Jul 16, 2014
340af87
Move terrain picking from the quadtree to the globe.
bagnell Jul 17, 2014
0d30629
Fix tilting wrong direction in 3D by using world coordinates.
bagnell Jul 17, 2014
d4627b2
Make tilt in 3D like Columbus view in that it uses the new tilt on te…
bagnell Jul 18, 2014
3a749f8
Merge branch 'master' into camera-terrain
bagnell Jul 18, 2014
3add858
Fix tests.
bagnell Jul 18, 2014
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: 0 additions & 2 deletions Apps/Sandcastle/gallery/3D Models.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
camera.transform = transform;
camera.constrainedAxis = Cesium.Cartesian3.UNIT_Y;
var controller = scene.screenSpaceCameraController;
controller.ellipsoid = Cesium.Ellipsoid.UNIT_SPHERE;
controller.enableTilt = false;
var r = 1.25 * Math.max(model.boundingSphere.radius, camera.frustum.near);
controller.minimumZoomDistance = r * 0.25;
camera.lookAt(new Cesium.Cartesian3(r, r, r), Cesium.Cartesian3.ZERO, Cesium.Cartesian3.UNIT_Y);
Expand Down
8 changes: 0 additions & 8 deletions Apps/Sandcastle/gallery/Camera.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
scene.primitives.removeAll();
scene.tweens.removeAll();

var controller = scene.screenSpaceCameraController;
controller.ellipsoid = scene.globe.ellipsoid;
controller.enableTilt = true;

scene.camera.setTransform(Cesium.Matrix4.IDENTITY);

clock.multiplier = 1.0;
Expand Down Expand Up @@ -135,10 +131,6 @@
Cesium.Matrix4.clone(transform, camera.transform);
camera.constrainedAxis = Cesium.Cartesian3.UNIT_Z;

var controller = scene.screenSpaceCameraController;
controller.ellipsoid = Cesium.Ellipsoid.UNIT_SPHERE;
controller.enableTilt = false;

// Zoom in
camera.lookAt(
new Cesium.Cartesian3(-120000.0, -120000.0, 120000.0),
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Change Log
* `Rectangle.getCenter` -> `Rectangle.center`
* `CullingVolume.getVisibility` -> `CullingVolume.computeVisibility`
* `SimplePolylineGeometry` and `PolylineGeometry` positions curve to follow the ellipsoid surface by default. To disable this behavior, set the option `followSurface=false`.
* Removed `ScreenSpaceCameraController.ellipsoid`. The behavior that depended on the ellipsoid is now determined based on the scene state.
* Sandcastle examples now automatically wrap the example code in RequireJS boilerplate. To upgrade any custom examples, copy the code into an existing example (such as Hello World) and save a new file.
* Replaced `PerspectiveFrustum.fovy` with `PerspectiveFrustum.fov` which will change the field of view angle in either the x or y direction depending on the aspect ratio.
* Added northUpEast transform to help support display of glTF models because Y is their up axis.
Expand All @@ -86,6 +87,10 @@ Change Log
* Added `Primitive.ready`.
* Prevent primitives from flashing off and on when modifying static DataSources.
* Added `scene3DOnly` options to `Viewer`, `CesiumWidget`, and `Scene` constructors. This setting optimizes memory usage and performance for 3D mode at the cost of losing the ability to use 2D or Columbus View.
* Added the following methods to `IntersectionTests`: `rayTriangle`, `lineSegmentTriangle`, `raySphere`, and `lineSegmentSphere`.
* Added `Globe.getHeight` and `Globe.pick` for finding the terrain height at a given Cartographic coordinate and picking the terrain with a ray.
* Modified the default camera tilt mouse behavior to tilt about the point clicked.
* Added camera collision detection with terrain to the default mouse interaction.
* Matrix types now have `add` and `subtract` functions.
* `Matrix3` type now has a `fromCrossProduct` function.

Expand Down
83 changes: 51 additions & 32 deletions Source/Core/Ellipsoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,7 @@ define([
CesiumMath) {
"use strict";

/**
* A quadratic surface defined in Cartesian coordinates by the equation
* <code>(x / a)^2 + (y / b)^2 + (z / c)^2 = 1</code>. Primarily used
* by Cesium to represent the shape of planetary bodies.
*
* Rather than constructing this object directly, one of the provided
* constants is normally used.
* @alias Ellipsoid
* @constructor
*
* @param {Number} [x=0] The radius in the x direction.
* @param {Number} [y=0] The radius in the y direction.
* @param {Number} [z=0] The radius in the z direction.
*
* @exception {DeveloperError} All radii components must be greater than or equal to zero.
*
* @see Ellipsoid.fromCartesian3
* @see Ellipsoid.WGS84
* @see Ellipsoid.UNIT_SPHERE
*/
var Ellipsoid = function(x, y, z) {
function initialize(ellipsoid, x, y, z) {
x = defaultValue(x, 0.0);
y = defaultValue(y, 0.0);
z = defaultValue(z, 0.0);
Expand All @@ -50,29 +30,62 @@ define([
}
//>>includeEnd('debug');

this._radii = new Cartesian3(x, y, z);
ellipsoid._radii = new Cartesian3(x, y, z);

this._radiiSquared = new Cartesian3(x * x,
ellipsoid._radiiSquared = new Cartesian3(x * x,
y * y,
z * z);

this._radiiToTheFourth = new Cartesian3(x * x * x * x,
ellipsoid._radiiToTheFourth = new Cartesian3(x * x * x * x,
y * y * y * y,
z * z * z * z);

this._oneOverRadii = new Cartesian3(x === 0.0 ? 0.0 : 1.0 / x,
ellipsoid._oneOverRadii = new Cartesian3(x === 0.0 ? 0.0 : 1.0 / x,
y === 0.0 ? 0.0 : 1.0 / y,
z === 0.0 ? 0.0 : 1.0 / z);

this._oneOverRadiiSquared = new Cartesian3(x === 0.0 ? 0.0 : 1.0 / (x * x),
ellipsoid._oneOverRadiiSquared = new Cartesian3(x === 0.0 ? 0.0 : 1.0 / (x * x),
y === 0.0 ? 0.0 : 1.0 / (y * y),
z === 0.0 ? 0.0 : 1.0 / (z * z));

this._minimumRadius = Math.min(x, y, z);
ellipsoid._minimumRadius = Math.min(x, y, z);

this._maximumRadius = Math.max(x, y, z);
ellipsoid._maximumRadius = Math.max(x, y, z);

this._centerToleranceSquared = CesiumMath.EPSILON1;
ellipsoid._centerToleranceSquared = CesiumMath.EPSILON1;
}

/**
* A quadratic surface defined in Cartesian coordinates by the equation
* <code>(x / a)^2 + (y / b)^2 + (z / c)^2 = 1</code>. Primarily used
* by Cesium to represent the shape of planetary bodies.
*
* Rather than constructing this object directly, one of the provided
* constants is normally used.
* @alias Ellipsoid
* @constructor
*
* @param {Number} [x=0] The radius in the x direction.
* @param {Number} [y=0] The radius in the y direction.
* @param {Number} [z=0] The radius in the z direction.
*
* @exception {DeveloperError} All radii components must be greater than or equal to zero.
*
* @see Ellipsoid.fromCartesian3
* @see Ellipsoid.WGS84
* @see Ellipsoid.UNIT_SPHERE
*/
var Ellipsoid = function(x, y, z) {
this._radii = undefined;
this._radiiSquared = undefined;
this._radiiToTheFourth = undefined;
this._oneOverRadii = undefined;
this._oneOverRadiiSquared = undefined;
this._minimumRadius = undefined;
this._maximumRadius = undefined;
this._centerToleranceSquared = undefined;

initialize(this, x, y, z);
};

defineProperties(Ellipsoid.prototype, {
Expand Down Expand Up @@ -189,11 +202,17 @@ define([
* @see Ellipsoid.WGS84
* @see Ellipsoid.UNIT_SPHERE
*/
Ellipsoid.fromCartesian3 = function(cartesian) {
Ellipsoid.fromCartesian3 = function(cartesian, result) {
if (!defined(result)) {
result = new Ellipsoid();
}

if (!defined(cartesian)) {
return new Ellipsoid();
return result;
}
return new Ellipsoid(cartesian.x, cartesian.y, cartesian.z);

initialize(result, cartesian.x, cartesian.y, cartesian.z);
return result;
};

/**
Expand Down
Loading