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

Clamp Billboards and Labels to terrain #2653

Merged
merged 43 commits into from
May 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
19f3ff9
Clamp billboards to ground WIP.
bagnell Apr 16, 2015
45265e3
Hook up callbacks when loading tiles in the quadtree. Billboards on t…
bagnell Apr 16, 2015
db403b6
Update quadtree callbacks when billboards are added or removed.
bagnell Apr 17, 2015
b7137f5
Move clamp control from billboard collection to billboard.
bagnell Apr 17, 2015
ac3aee2
Track clamped position differently from user provided position.
bagnell Apr 17, 2015
5298834
Improve performance by not updating entire quadtree when adding or re…
bagnell Apr 17, 2015
6abe6ed
Fix clamping to billboards to ground in 2D, Columbus view and when mo…
bagnell Apr 20, 2015
83f5dc3
Only use one vertex texture fetch for the depth at the center of the …
bagnell Apr 20, 2015
cc013c4
Merge branch 'globe-depth' into billboard-clamp-to-ground
bagnell Apr 20, 2015
9a76c64
Throttle billboards clamped to terrain to only pick the mesh in the g…
bagnell Apr 20, 2015
4583516
Add clamp to ground option to labels.
bagnell Apr 21, 2015
8840623
Clean up picking a terrain tile's mesh and fix billboards when create…
bagnell Apr 21, 2015
f115094
Use the frame number when updating callbacks for rendered tiles inste…
bagnell Apr 21, 2015
27df468
Clamp the entire label instead of the individual billboards of the la…
bagnell Apr 21, 2015
8ce9101
Check the last frame rendered and only use callbacks when a tile tran…
bagnell Apr 21, 2015
0acc702
Improve performance. Associate data with the quadtree that will updat…
bagnell Apr 22, 2015
fefe944
Change clampToGround boolean to heightReference with enum that can be…
bagnell Apr 23, 2015
1bdde11
Change method for determining billboard visibility.
bagnell Apr 24, 2015
e70d140
Add Sandcastle example clamping billboards to the ground.
bagnell Apr 24, 2015
55cc7d3
Add attribute to billboards to compute label visibility.
bagnell Apr 28, 2015
0ae305a
Only update billboard position on terrain loaded.
bagnell Apr 28, 2015
b25eac7
Remove updating the billboard on tile load. Update the position on ti…
bagnell Apr 28, 2015
8d3377c
Fix updating height reference and changine position. Fixed columbus v…
bagnell Apr 28, 2015
ae61e7a
Update Sandcastle example.
bagnell Apr 29, 2015
b941902
Some updates base don review.
bagnell Apr 29, 2015
6fefe5b
Merge branch 'globe-depth' into billboard-clamp-to-ground
bagnell Apr 29, 2015
2b5ae80
Rename maxSize to ownerSize. Update labels and other changes based on…
bagnell Apr 29, 2015
220f3b2
More renames and updates based on review.
bagnell Apr 29, 2015
2ff3d43
Add doc.
bagnell Apr 29, 2015
6c722f9
Update computing screen space position for billboards and labels.
bagnell Apr 29, 2015
9b1f561
Move time slicing code from the billboard/label collection to the qua…
bagnell May 1, 2015
0b2a63a
Stop updating billboards/labels when the height for the lowest level …
bagnell May 1, 2015
26d6ad5
Fix updating billboard/label height reference and position.
bagnell May 4, 2015
d9061fb
Rename from review.
bagnell May 4, 2015
fb7901e
Update Sandcastle example.
bagnell May 4, 2015
344619d
Update doc.
bagnell May 4, 2015
f68c78b
Improve update performance.
bagnell May 4, 2015
1770da4
Update labels/billboards when the terrain provider changes.
bagnell May 4, 2015
9f7f1ab
Fix ciolumbus view. Clean up requires.
bagnell May 5, 2015
58980dc
Re-add eye z offset.
bagnell May 5, 2015
3b7c13b
Add tests for billboards/labels with height references and for the qu…
bagnell May 7, 2015
83fd26d
Merge branch 'globe-depth' into billboard-clamp-to-ground
bagnell May 7, 2015
9fff44c
Update CHANGES.md
bagnell May 7, 2015
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
158 changes: 158 additions & 0 deletions Apps/Sandcastle/gallery/development/BillboardClampToGround.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <!-- Use Chrome Frame in IE -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Clamp billboards to terrain.">
<meta name="cesium-sandcastle-labels" content="Development">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.9/require.js"></script>
<script type="text/javascript">
require.config({
baseUrl : '../../../Source',
waitSeconds : 60
});
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar">
<div id="terrainMenu"></div>
<div id="zoomButtons"></div>
<div id="toggleLighting"></div>
<div id="sampleButtons"></div>
</div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
"use strict";
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');

var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
url : '//assets.agi.com/stk-terrain/world'
});
viewer.terrainProvider = cesiumTerrainProviderMeshes;
viewer.scene.globe.depthTestAgainstTerrain = false;

var ellipsoid = viewer.scene.globe.ellipsoid;
var billboardCollection = viewer.scene.primitives.add(new Cesium.BillboardCollection({
scene : viewer.scene
}));

/*
var labelCollection = viewer.scene.primitives.add(new Cesium.LabelCollection({
scene : viewer.scene
}));
*/

// everest
//var centerLatitude = Cesium.Math.toRadians(27.988257);
//var centerLongitude = Cesium.Math.toRadians(86.925145);

// seneca
var centerLongitude = -1.385205433269729;
var centerLatitude = 0.6777926580888163;

var gridWidth = Math.floor(Math.random() * 100.0);
var gridHeight = Math.floor(Math.random() * 100.0);
var rectangleHalfSize = 0.0005;

var e = new Cesium.Rectangle(centerLongitude - rectangleHalfSize, centerLatitude - rectangleHalfSize, centerLongitude + rectangleHalfSize, centerLatitude + rectangleHalfSize);

for (var y = 0; y < gridHeight; ++y) {
for (var x = 0; x < gridWidth; ++x) {
var longitude = Cesium.Math.lerp(e.west, e.east, x / (gridWidth - 1));
var latitude = Cesium.Math.lerp(e.south, e.north, y / (gridHeight - 1));
var position = new Cesium.Cartographic(longitude, latitude);

billboardCollection.add({
position : ellipsoid.cartographicToCartesian(position),
image : '../images/facility.gif',
heightReference : Cesium.HeightReference.CLAMP_TO_GROUND
});
//labelCollection.add({
// text : 'Label',
// position : ellipsoid.cartographicToCartesian(position),
// heightReference : Cesium.HeightReference.CLAMP_TO_GROUND
//});
}
}

var billboard;

Sandcastle.addToolbarButton('Add billboard', function() {
if (!Cesium.defined(billboard)) {
billboard = billboardCollection.add({
position : ellipsoid.cartographicToCartesian(new Cesium.Cartographic(centerLongitude, centerLatitude, 1000.0)),
image : '../images/Cesium_Logo_overlay.png',
scale : 0.7,
heightReference : Cesium.HeightReference.RELATIVE_TO_GROUND
});
}
});

Sandcastle.addToolbarButton('Remove billboard', function() {
if (Cesium.defined(billboard)) {
billboardCollection.remove(billboard);
billboard = undefined;
}
});

Sandcastle.addToolbarMenu([ {
text : 'Relative to ground',
onselect : function() {
if (Cesium.defined(billboard)) {
billboard.heightReference = Cesium.HeightReference.RELATIVE_TO_GROUND;
}
}
}, {
text : 'Clamp to ground',
onselect : function() {
if (Cesium.defined(billboard)) {
billboard.heightReference = Cesium.HeightReference.CLAMP_TO_GROUND;
}
}
}, {
text : 'None',
onselect : function() {
if (Cesium.defined(billboard)) {
billboard.heightReference = Cesium.HeightReference.NONE;
}
}
}]);

var lonGran = 0.00005;

Sandcastle.addToolbarButton('Increase longitude', function() {
if (Cesium.defined(billboard)) {
var cartographic = ellipsoid.cartesianToCartographic(billboard.position);
cartographic.longitude += lonGran;
billboard.position = ellipsoid.cartographicToCartesian(cartographic);
}
});

Sandcastle.addToolbarButton('Decrease longitude', function() {
if (Cesium.defined(billboard)) {
var cartographic = ellipsoid.cartesianToCartographic(billboard.position);
cartographic.longitude -= lonGran;
billboard.position = ellipsoid.cartographicToCartesian(cartographic);
}
});

//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Change Log
### 1.10 - 2015-06-01
* Breaking changes
*
* Added `Billboard.heightReference` and `Label.heightReference` to clamp billboards and labels to terrain.
* Added new `PointPrimitive` and `PointPrimitiveCollection`, which are faster and use less memory than billboards with circles.
* Changed `Entity.point` back-end graphics to use the new `PointPrimitive` instead of billboards. No change to the `Entity.point` API.
* Upgraded Autolinker from version 0.15.2 to 0.17.1.
Expand Down
Loading