Skip to content

Commit

Permalink
Merge branch 'master' into texture-compression
Browse files Browse the repository at this point in the history
  • Loading branch information
bagnell committed Jan 26, 2017
2 parents 304d32a + 84e0a08 commit 40f8bcd
Show file tree
Hide file tree
Showing 169 changed files with 5,172 additions and 2,958 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 1 addition & 2 deletions Apps/Sandcastle/gallery/CZML.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
viewer.scene.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(-116.52, 35.02, 95000),
orientation: {
heading: 6,
picth: -Cesium.Math.PI_OVER_TWO
heading: 6
}
});
});
Expand Down
90 changes: 90 additions & 0 deletions Apps/Sandcastle/gallery/Custom Geocoder.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Cluster labels, billboards and points.">
<meta name="cesium-sandcastle-labels" content="Tutorials,Showcases">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/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);
#toolbar {
background: rgba(42, 42, 42, 0.8);
padding: 4px;
border-radius: 4px;
}
#toolbar input {
vertical-align: middle;
padding-top: 2px;
padding-bottom: 2px;
}
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin

/**
* This class is an example of a custom geocoder. It provides geocoding through the OpenStreetMap Nominatim service.
* @alias OpenStreetMapNominatimGeocoder
* @constructor
*/
function OpenStreetMapNominatimGeocoder() {
}

/**
* The function called to geocode using this geocoder service.
*
* @param {String} input The query to be sent to the geocoder service
* @returns {Promise<GeocoderResult[]>}
*/
OpenStreetMapNominatimGeocoder.prototype.geocode = function (input) {
var endpoint = 'http://nominatim.openstreetmap.org/search?';
var query = 'format=json&q=' + input;
var requestString = endpoint + query;
return Cesium.loadJson(requestString)
.then(function (results) {
var bboxDegrees;
return results.map(function (resultObject) {
bboxDegrees = resultObject.boundingbox;
return {
displayName: resultObject.display_name,
destination: Cesium.Rectangle.fromDegrees(
bboxDegrees[2],
bboxDegrees[0],
bboxDegrees[3],
bboxDegrees[1]
)
};
});
});
};

var viewer = new Cesium.Viewer('cesiumContainer', {
geocoder: new OpenStreetMapNominatimGeocoder()
});

//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>
105 changes: 105 additions & 0 deletions Apps/Sandcastle/gallery/Imagery Layers Split.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Use the split property to only show layers on one side of a slider.">
<meta name="cesium-sandcastle-labels" content="Beginner, Tutorials, Showcases">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/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);

#slider {
position: absolute;
left: 50%;
top: 0px;
background-color: #D3D3D3;
width: 2px;
height: 100%;
z-index: 9999;
}

#slider:hover {
cursor: ew-resize;
}

</style>

<div id="cesiumContainer" class="fullSize">
<div id="slider"></div>
</div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>

<script id="cesium_sandcastle_script">


function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider : new Cesium.ArcGisMapServerImageryProvider({
url : 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer'
}),
baseLayerPicker : false
});

var layers = viewer.imageryLayers;
var blackMarble = layers.addImageryProvider(Cesium.createTileMapServiceImageryProvider({
url : 'https://cesiumjs.org/blackmarble',
credit : 'Black Marble imagery courtesy NASA Earth Observatory',
flipXY : true // Only old gdal2tile.py generated tilesets need this flag.
}));
blackMarble.splitDirection = Cesium.ImagerySplitDirection.LEFT; // Only show to the left of the slider.

// Sync the position of the slider with the split position
var slider = document.getElementById('slider');
viewer.scene.imagerySplitPosition = (slider.offsetLeft) / slider.parentElement.offsetWidth;

var dragStartX = 0;

document.getElementById('slider').addEventListener('mousedown', mouseDown, false);
window.addEventListener('mouseup', mouseUp, false);

function mouseUp() {
window.removeEventListener('mousemove', sliderMove, true);
}

function mouseDown(e) {
var slider = document.getElementById('slider');
dragStartX = e.clientX - slider.offsetLeft;
window.addEventListener('mousemove', sliderMove, true);
}

function sliderMove(e) {
var slider = document.getElementById('slider');
var splitPosition = (e.clientX - dragStartX) / slider.parentElement.offsetWidth;
slider.style.left = 100.0 * splitPosition + "%";
viewer.scene.imagerySplitPosition = splitPosition;
}


//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>

</body>
</html>
Binary file added Apps/Sandcastle/gallery/Imagery Layers Split.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 29 additions & 22 deletions Apps/Sandcastle/gallery/Picking.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
}
});
viewer.zoomTo(modelEntity);

var labelEntity = viewer.entities.add({
label : {
show : false,
Expand All @@ -174,36 +174,43 @@
}
});

var sceneModeWarningPosted = false;

// Mouse over the globe to see the cartographic position
handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var foundPosition = false;

var scene = viewer.scene;
var pickedObject = scene.pick(movement.endPosition);
if (scene.pickPositionSupported && Cesium.defined(pickedObject) && pickedObject.id === modelEntity) {
var cartesian = viewer.scene.pickPosition(movement.endPosition);

if (Cesium.defined(cartesian)) {
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2);
var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2);
var heightString = cartographic.height.toFixed(2);

labelEntity.position = cartesian;
labelEntity.label.show = true;
labelEntity.label.text =
'Lon: ' + (' ' + longitudeString).slice(-7) + '\u00B0' +
'\nLat: ' + (' ' + latitudeString).slice(-7) + '\u00B0' +
'\nAlt: ' + (' ' + heightString).slice(-7) + 'm';

var camera = scene.camera;
labelEntity.label.eyeOffset = new Cesium.Cartesian3(0.0, 0.0, camera.frustum.near * 1.5 - Cesium.Cartesian3.distance(cartesian, camera.position));

foundPosition = true;
if (scene.mode === Cesium.SceneMode.SCENE3D) {
var cartesian = viewer.scene.pickPosition(movement.endPosition);

if (Cesium.defined(cartesian)) {
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2);
var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2);
var heightString = cartographic.height.toFixed(2);

labelEntity.position = cartesian;
labelEntity.label.show = true;
labelEntity.label.text =
'Lon: ' + (' ' + longitudeString).slice(-7) + '\u00B0' +
'\nLat: ' + (' ' + latitudeString).slice(-7) + '\u00B0' +
'\nAlt: ' + (' ' + heightString).slice(-7) + 'm';

var camera = scene.camera;
labelEntity.label.eyeOffset = new Cesium.Cartesian3(0.0, 0.0, camera.frustum.near * 1.5 - Cesium.Cartesian3.distance(cartesian, camera.position));

foundPosition = true;
}
} else if (!sceneModeWarningPosted) {
sceneModeWarningPosted = true;
console.log("pickPosition is currently only supported in 3D mode.");
}
}

if (!foundPosition) {
labelEntity.label.show = false;
}
Expand Down
32 changes: 20 additions & 12 deletions Apps/Sandcastle/gallery/Terrain.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
}

function sampleTerrainSuccess() {
function sampleTerrainSuccess(terrainSamplePositions) {
var ellipsoid = Cesium.Ellipsoid.WGS84;

//By default, Cesium does not obsure geometry
Expand Down Expand Up @@ -162,22 +162,13 @@
viewer.entities.resumeEvents();
}

Sandcastle.addToggleButton('Enable Lighting', viewer.scene.globe.enableLighting, function(checked) {
viewer.scene.globe.enableLighting = checked;
});

Sandcastle.addToggleButton('Enable fog', viewer.scene.fog.enabled, function(checked) {
viewer.scene.fog.enabled = checked;
});

Sandcastle.addToolbarButton('Sample Everest Terrain', function() {
function createGrid(rectangleHalfSize) {
var gridWidth = 41;
var gridHeight = 41;
var everestLatitude = Cesium.Math.toRadians(27.988257);
var everestLongitude = Cesium.Math.toRadians(86.925145);
var rectangleHalfSize = 0.005;
var e = new Cesium.Rectangle(everestLongitude - rectangleHalfSize, everestLatitude - rectangleHalfSize, everestLongitude + rectangleHalfSize, everestLatitude + rectangleHalfSize);
terrainSamplePositions = [];
var terrainSamplePositions = [];
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));
Expand All @@ -186,9 +177,26 @@
terrainSamplePositions.push(position);
}
}
return terrainSamplePositions;
}

Sandcastle.addToggleButton('Enable Lighting', viewer.scene.globe.enableLighting, function(checked) {
viewer.scene.globe.enableLighting = checked;
});

Sandcastle.addToggleButton('Enable fog', viewer.scene.fog.enabled, function(checked) {
viewer.scene.fog.enabled = checked;
});

Sandcastle.addToolbarButton('Sample Everest Terrain at Level 9', function() {
var terrainSamplePositions = createGrid(0.005);
Cesium.when(Cesium.sampleTerrain(viewer.terrainProvider, 9, terrainSamplePositions), sampleTerrainSuccess);
lookAtMtEverest();
}, 'sampleButtons');

Sandcastle.addToolbarButton('Sample Most Detailed Everest Terrain', function() {
var terrainSamplePositions = createGrid(0.0005);
Cesium.when(Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, terrainSamplePositions), sampleTerrainSuccess);
lookAtMtEverest();
}, 'sampleButtons');

Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/development/Multiple Shadows.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

var shadowMap = new Cesium.ShadowMap({
context : scene.context,
scene : scene,
lightCamera : pointLightCamera,
isPointLight : true,
softShadows : false
Expand Down
20 changes: 20 additions & 0 deletions Apps/Sandcastle/gallery/development/Polylines.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@
material : Cesium.Material.fromType(Cesium.Material.PolylineArrowType)
});
Sandcastle.declare(localPolyline); // For highlighting on mouseover in Sandcastle.

//Polyline using the fade material
var fadingPolyline = polylines.add({
positions : Cesium.PolylinePipeline.generateCartesianArc({
positions : Cesium.Cartesian3.fromDegreesArrayHeights([-75, 43, 500000,
-125, 43, 500000])
}),
width : 5,
material : Cesium.Material.fromType(Cesium.Material.FadeType, {
repeat: false,
fadeInColor: Cesium.Color.CYAN,
fadeOutColor: Cesium.Color.CYAN.withAlpha(0),
time: new Cesium.Cartesian2(0.0, 0.0),
fadeDirection: {
x: true,
y: false
}
})
});
Sandcastle.declare(fadingPolyline); // For highlighting on mouseover in Sandcastle.
}

var viewer = new Cesium.Viewer('cesiumContainer');
Expand Down
Binary file modified Apps/Sandcastle/gallery/development/Polylines.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 40f8bcd

Please sign in to comment.