Created
March 6, 2015 14:40
-
-
Save emackey/a46ff6fe102c5d79ecf3 to your computer and use it in GitHub Desktop.
Updated version of the old Sandcastle Minimalist example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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="Use Viewer to start building new applications or easily embed Cesium into existing applications."> | |
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases"> | |
<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> | |
<script id="cesium_sandcastle_script"> | |
function startup(Cesium) { | |
"use strict"; | |
//Sandcastle_Begin | |
var canvas = document.createElement('canvas'); | |
canvas.className = "fullSize"; | |
document.getElementById('cesiumContainer').appendChild(canvas); | |
var scene = new Cesium.Scene({ | |
canvas : canvas | |
}); | |
var primitives = scene.primitives; | |
scene.globe = new Cesium.Globe(); | |
var imageryUrl = '../../../Source/Assets/Textures/'; | |
var imageryProvider = new Cesium.TileMapServiceImageryProvider({ | |
url : imageryUrl + 'NaturalEarthII' | |
}); | |
scene.imageryLayers.addImageryProvider(imageryProvider); | |
scene.skyAtmosphere = new Cesium.SkyAtmosphere(); | |
var skyBoxBaseUrl = imageryUrl + 'SkyBox/tycho2t3_80'; | |
scene.skyBox = new Cesium.SkyBox({ | |
sources : { | |
positiveX : skyBoxBaseUrl + '_px.jpg', | |
negativeX : skyBoxBaseUrl + '_mx.jpg', | |
positiveY : skyBoxBaseUrl + '_py.jpg', | |
negativeY : skyBoxBaseUrl + '_my.jpg', | |
positiveZ : skyBoxBaseUrl + '_pz.jpg', | |
negativeZ : skyBoxBaseUrl + '_mz.jpg' | |
} | |
}); | |
function animate() { | |
// INSERT CODE HERE to update primitives based on changes to animation time, camera parameters, etc. | |
} | |
function tick() { | |
scene.initializeFrame(); | |
animate(); | |
scene.render(); | |
Cesium.requestAnimationFrame(tick); | |
} | |
tick(); | |
// Prevent right-click from opening a context menu. | |
canvas.oncontextmenu = function () { | |
return false; | |
}; | |
/////////////////////////////////////////////////////////////////////////// | |
// Example resize handler | |
var onResize = function () { | |
var width = canvas.clientWidth; | |
var height = canvas.clientHeight; | |
if (canvas.width === width && canvas.height === height) { | |
return; | |
} | |
canvas.width = width; | |
canvas.height = height; | |
scene.camera.frustum.aspectRatio = width / height; | |
}; | |
window.addEventListener('resize', onResize, false); | |
onResize(); | |
//Sandcastle_End | |
Sandcastle.finishedLoading(); | |
} | |
if (typeof Cesium !== "undefined") { | |
startup(Cesium); | |
} else if (typeof require === "function") { | |
require(["Cesium"], startup); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment