<commit_before><!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, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <meta name="description" content="Drag and drop CZML files onto the Cesium Viewer Widget to visualize time dynamic data.">
    <title>Cesium Demo</title>
    <script>
    var Sandcastle = {};
    Sandcastle.declare = function () {};
    Sandcastle.highlight = function () {};
    Sandcastle.registered = [];
    if (window.location.protocol === 'file:') {
        if (confirm("You must host this app on a web server.\nSee contributor's guide for more info?")) {
            window.location = 'https://github.com/AnalyticalGraphicsInc/cesium/wiki/Contributor%27s-Guide';
        }
    }
    </script>
    <script data-dojo-config="async: 1, tlmSiblingOfDojo: 0" src="../../../ThirdParty/dojo-release-1.7.2-src/dojo/dojo.js"></script>
    <script type="text/javascript">
    require({
        baseUrl : '../../..',
        packages: [
            { name: 'dojo', location: 'ThirdParty/dojo-release-1.7.2-src/dojo' },
            { name: 'dijit', location: 'ThirdParty/dojo-release-1.7.2-src/dijit' },
            { name: 'dojox', location: 'ThirdParty/dojo-release-1.7.2-src/dojox' },
            { name: 'Source', location: 'Source' },
            { name: 'Core', location: 'Source/Core' },
            { name: 'DynamicScene', location: 'Source/DynamicScene' },
            { name: 'Renderer', location: 'Source/Renderer' },
            { name: 'Scene', location: 'Source/Scene' },
            { name: 'Shaders', location: 'Source/Shaders' },
            { name: 'ThirdParty', location: 'Source/ThirdParty' },
            { name: 'Widgets', location: 'Source/Widgets' },
            { name: 'Workers', location: 'Source/Workers' }
        ]
    });
    </script>
    <link rel="Stylesheet" href="../../../ThirdParty/dojo-release-1.7.2-src/dijit/themes/claro/claro.css" type="text/css">
    <link rel="Stylesheet" href="../../../Source/Widgets/Dojo/CesiumViewerWidget.css" type="text/css">
</head>
<body class="claro">
<style>
body {
    background: #000;
    color: #eee;
    font-family: sans-serif;
    font-size: 9pt;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.fullSize {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    border: none;
    width: 100%;
    height: 100%;
    z-index: -1;
}
#toolbar {
    margin: 5px;
    padding: 2px 5px;
    position: absolute;
}
</style>

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

<script id="cesium_sandcastle_script">
require([
    'Source/Cesium', 'Widgets/Dojo/CesiumViewerWidget',
    'dojo/on', 'dojo/dom'
], function(
    Cesium, CesiumViewerWidget,
    on, dom)
{
    "use strict";

    var ellipsoid = Cesium.Ellipsoid.WGS84;
    var scene; 
    var cb;
    var mousePosition;

    function ellipsoidIntersections(ellipsoid, ray) {
        var position = ray.origin;
        var direction = ray.direction;
        var oneOverRadii = ellipsoid.getOneOverRadii();

        var scaledPosition = position.multiplyComponents(oneOverRadii);
        var scaledDirection = direction.multiplyComponents(oneOverRadii);

        var a = scaledDirection.magnitudeSquared();
        var b = 2.0 * scaledPosition.dot(scaledDirection);
        var c = scaledPosition.magnitudeSquared() - 1.0;

        var b2 = b * b;
        var four_ac = 4.0 * a * c;
        var radicand = b2 - four_ac;

        if (radicand < 0.0) {
            return undefined;
        }

        var q = -0.5 * (b + sign(b) * Math.sqrt(radicand));
        if (b > 0.0) {
            return [q / a, c / q];
        }
        return [c / q, q / a];
    }

    function sign(x) {
        if (x < 0.0) {
            return -1.0;
        } else if (x > 0.0) {
            return 1.0;
        }
        return 0.0;
    }

    function keydownHandler(e) {
        switch (e.keyCode) {
        case 'F'.charCodeAt(0):
            cb._surface.toggleLodUpdate();
            break;
        case 'B'.charCodeAt(0):
            var camera = scene.getCamera();
            var pickRay = camera.getPickRay(mousePosition);
            var intersectionDistance = ellipsoidIntersections(ellipsoid, pickRay)[0];
            var intersectionPoint = pickRay.getPoint(intersectionDistance);
            var cartographicPick = ellipsoid.cartesianToCartographic(intersectionPoint);
            cb._surface.debugShowBoundingSphereOfTileAt(cartographicPick);
            break;
        case 'V'.charCodeAt(0):
            var camera = scene.getCamera();
            console.log('position: ' + camera.getPositionWC() + ' direction: ' + camera.getDirectionWC() + ' up: ' + camera.getUpWC());
            break;
        case 'L'.charCodeAt(0):
            var position = new Cesium.Cartesian3(-2444822.7410362503, -4495391.442027786, 3800016.0770029235);
            var direction = new Cesium.Cartesian3(0.2306406390807245, 0.8212545213405562, 0.5218677100397503);
            var up = new Cesium.Cartesian3(-0.31881470184216937, -0.44294118336776583, 0.8379500545772692);
            var camera = scene.getCamera();
            camera.lookAt(position, position.add(direction), up);
            break;
        case 'C'.charCodeAt(0):
            var position = new Cesium.Cartesian3(-2444319.744271441, -4490462.305656268, 3800605.179680734);
            var direction = new Cesium.Cartesian3(0.3079076572929976, 0.5183187255969877, 0.7978336751954334);
            var up = new Cesium.Cartesian3(-0.38141711164833125, -0.7009912978668698, 0.6026045031832784);
            var camera = scene.getCamera();
            camera.lookAt(position, position.add(direction), up);
            break;
        }
    }

    var cesiumViewerWidget = new CesiumViewerWidget({
        postSetup : function(widget) {
            scene = widget.scene;
            cb = scene.getPrimitives().getCentralBody();

            var terrainProvider = new Cesium.TileMapServiceTerrainProvider({
                url : 'http://cesium.agi.com/terrain'
            });
            
            /*var terrainProvider = new Cesium.ArcGisImageServerTerrainProvider({
                url : 'http://elevation.arcgisonline.com/ArcGIS/rest/services/WorldElevation/DTMEllipsoidal/ImageServer',
                token : '<KEY>',
                proxy : new Cesium.DefaultProxy('/terrain/')
            });

            cb._surface._terrainProvider = terrainProvider;
            
            // TODO: this shouldn't be necessary
            var surface = cb._surface;
            var levelZeroTiles = surface._levelZeroTiles;
            for (var i = 0; i < levelZeroTiles.length; ++i) {
                levelZeroTiles[i].freeResources();
            }
            surface._levelZeroTiles = terrainProvider.tilingScheme.createLevelZeroTiles();*/

            scene.getCamera().frustum.near = 10.0;
            cb.affectedByLighting = false;
            
            /*var imageryLayerCollection = cb.getImageLayers();
            imageryLayerCollection.removeAll();
            
            var esriImageryProvider = new Cesium.ArcGisMapServerImageryProvider({
              url : 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer',
              proxy : new Cesium.DefaultProxy('/proxy/')
            });
            var esriLayer = imageryLayerCollection.addImageryProvider(esriImageryProvider);
  
            var esriStreetsImageryProvider = new Cesium.ArcGisMapServerImageryProvider({
                url : 'http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer',
                proxy : new Cesium.DefaultProxy('/proxy/')
            });
            var esriStreetsLayer = imageryLayerCollection.addImageryProvider(esriStreetsImageryProvider);*/
            
            document.addEventListener('keydown', keydownHandler, false);
            
            var handler = new Cesium.EventHandler(widget.canvas);

            handler.setMouseAction(function(movement) {
                mousePosition = movement.endPosition;
                // Use movement.startPosition, movement.endPosition
            }, Cesium.MouseEventType.MOVE);

            widget.startRenderLoop();
        }
    }).placeAt(dom.byId("cesiumContainer"));
    
    dom.byId('toolbar').innerHTML = '';
});
</script>
</body>
</html>
<commit_msg>Re-activate terrain in the terrain demo.<commit_after><!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, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <meta name="description" content="Drag and drop CZML files onto the Cesium Viewer Widget to visualize time dynamic data.">
    <title>Cesium Demo</title>
    <script>
    var Sandcastle = {};
    Sandcastle.declare = function () {};
    Sandcastle.highlight = function () {};
    Sandcastle.registered = [];
    if (window.location.protocol === 'file:') {
        if (confirm("You must host this app on a web server.\nSee contributor's guide for more info?")) {
            window.location = 'https://github.com/AnalyticalGraphicsInc/cesium/wiki/Contributor%27s-Guide';
        }
    }
    </script>
    <script data-dojo-config="async: 1, tlmSiblingOfDojo: 0" src="../../../ThirdParty/dojo-release-1.7.2-src/dojo/dojo.js"></script>
    <script type="text/javascript">
    require({
        baseUrl : '../../..',
        packages: [
            { name: 'dojo', location: 'ThirdParty/dojo-release-1.7.2-src/dojo' },
            { name: 'dijit', location: 'ThirdParty/dojo-release-1.7.2-src/dijit' },
            { name: 'dojox', location: 'ThirdParty/dojo-release-1.7.2-src/dojox' },
            { name: 'Source', location: 'Source' },
            { name: 'Core', location: 'Source/Core' },
            { name: 'DynamicScene', location: 'Source/DynamicScene' },
            { name: 'Renderer', location: 'Source/Renderer' },
            { name: 'Scene', location: 'Source/Scene' },
            { name: 'Shaders', location: 'Source/Shaders' },
            { name: 'ThirdParty', location: 'Source/ThirdParty' },
            { name: 'Widgets', location: 'Source/Widgets' },
            { name: 'Workers', location: 'Source/Workers' }
        ]
    });
    </script>
    <link rel="Stylesheet" href="../../../ThirdParty/dojo-release-1.7.2-src/dijit/themes/claro/claro.css" type="text/css">
    <link rel="Stylesheet" href="../../../Source/Widgets/Dojo/CesiumViewerWidget.css" type="text/css">
</head>
<body class="claro">
<style>
body {
    background: #000;
    color: #eee;
    font-family: sans-serif;
    font-size: 9pt;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.fullSize {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    border: none;
    width: 100%;
    height: 100%;
    z-index: -1;
}
#toolbar {
    margin: 5px;
    padding: 2px 5px;
    position: absolute;
}
</style>

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

<script id="cesium_sandcastle_script">
require([
    'Source/Cesium', 'Widgets/Dojo/CesiumViewerWidget',
    'dojo/on', 'dojo/dom'
], function(
    Cesium, CesiumViewerWidget,
    on, dom)
{
    "use strict";

    var ellipsoid = Cesium.Ellipsoid.WGS84;
    var scene; 
    var cb;
    var mousePosition;

    function ellipsoidIntersections(ellipsoid, ray) {
        var position = ray.origin;
        var direction = ray.direction;
        var oneOverRadii = ellipsoid.getOneOverRadii();

        var scaledPosition = position.multiplyComponents(oneOverRadii);
        var scaledDirection = direction.multiplyComponents(oneOverRadii);

        var a = scaledDirection.magnitudeSquared();
        var b = 2.0 * scaledPosition.dot(scaledDirection);
        var c = scaledPosition.magnitudeSquared() - 1.0;

        var b2 = b * b;
        var four_ac = 4.0 * a * c;
        var radicand = b2 - four_ac;

        if (radicand < 0.0) {
            return undefined;
        }

        var q = -0.5 * (b + sign(b) * Math.sqrt(radicand));
        if (b > 0.0) {
            return [q / a, c / q];
        }
        return [c / q, q / a];
    }

    function sign(x) {
        if (x < 0.0) {
            return -1.0;
        } else if (x > 0.0) {
            return 1.0;
        }
        return 0.0;
    }

    function keydownHandler(e) {
        switch (e.keyCode) {
        case 'F'.charCodeAt(0):
            cb._surface.toggleLodUpdate();
            break;
        case 'B'.charCodeAt(0):
            var camera = scene.getCamera();
            var pickRay = camera.getPickRay(mousePosition);
            var intersectionDistance = ellipsoidIntersections(ellipsoid, pickRay)[0];
            var intersectionPoint = pickRay.getPoint(intersectionDistance);
            var cartographicPick = ellipsoid.cartesianToCartographic(intersectionPoint);
            cb._surface.debugShowBoundingSphereOfTileAt(cartographicPick);
            break;
        case 'V'.charCodeAt(0):
            var camera = scene.getCamera();
            console.log('position: ' + camera.getPositionWC() + ' direction: ' + camera.getDirectionWC() + ' up: ' + camera.getUpWC());
            break;
        case 'L'.charCodeAt(0):
            var position = new Cesium.Cartesian3(-2444822.7410362503, -4495391.442027786, 3800016.0770029235);
            var direction = new Cesium.Cartesian3(0.2306406390807245, 0.8212545213405562, 0.5218677100397503);
            var up = new Cesium.Cartesian3(-0.31881470184216937, -0.44294118336776583, 0.8379500545772692);
            var camera = scene.getCamera();
            camera.lookAt(position, position.add(direction), up);
            break;
        case 'C'.charCodeAt(0):
            var position = new Cesium.Cartesian3(-2444319.744271441, -4490462.305656268, 3800605.179680734);
            var direction = new Cesium.Cartesian3(0.3079076572929976, 0.5183187255969877, 0.7978336751954334);
            var up = new Cesium.Cartesian3(-0.38141711164833125, -0.7009912978668698, 0.6026045031832784);
            var camera = scene.getCamera();
            camera.lookAt(position, position.add(direction), up);
            break;
        }
    }

    var cesiumViewerWidget = new CesiumViewerWidget({
        postSetup : function(widget) {
            scene = widget.scene;
            cb = scene.getPrimitives().getCentralBody();

            var terrainProvider = new Cesium.TileMapServiceTerrainProvider({
                url : 'http://cesium.agi.com/terrain'
            });

            cb._surface._terrainProvider = terrainProvider;

            /*var terrainProvider = new Cesium.ArcGisImageServerTerrainProvider({
                url : 'http://elevation.arcgisonline.com/ArcGIS/rest/services/WorldElevation/DTMEllipsoidal/ImageServer',
                token : '<KEY>',
                proxy : new Cesium.DefaultProxy('/terrain/')
            });

            cb._surface._terrainProvider = terrainProvider;
            
            // TODO: this shouldn't be necessary
            var surface = cb._surface;
            var levelZeroTiles = surface._levelZeroTiles;
            for (var i = 0; i < levelZeroTiles.length; ++i) {
                levelZeroTiles[i].freeResources();
            }
            surface._levelZeroTiles = terrainProvider.tilingScheme.createLevelZeroTiles();*/

            scene.getCamera().frustum.near = 10.0;
            cb.affectedByLighting = false;
            
            /*var imageryLayerCollection = cb.getImageLayers();
            imageryLayerCollection.removeAll();
            
            var esriImageryProvider = new Cesium.ArcGisMapServerImageryProvider({
              url : 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer',
              proxy : new Cesium.DefaultProxy('/proxy/')
            });
            var esriLayer = imageryLayerCollection.addImageryProvider(esriImageryProvider);
  
            var esriStreetsImageryProvider = new Cesium.ArcGisMapServerImageryProvider({
                url : 'http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer',
                proxy : new Cesium.DefaultProxy('/proxy/')
            });
            var esriStreetsLayer = imageryLayerCollection.addImageryProvider(esriStreetsImageryProvider);*/
            
            document.addEventListener('keydown', keydownHandler, false);
            
            var handler = new Cesium.EventHandler(widget.canvas);

            handler.setMouseAction(function(movement) {
                mousePosition = movement.endPosition;
                // Use movement.startPosition, movement.endPosition
            }, Cesium.MouseEventType.MOVE);

            widget.startRenderLoop();
        }
    }).placeAt(dom.byId("cesiumContainer"));
    
    dom.byId('toolbar').innerHTML = '';
});
</script>
</body>
</html>

{'fraction_non_alphanumeric': 0.13406848520023215, 'fraction_numerical': 0.045850261172373764, 'mean_word_length': 2.298430321592649, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 69, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5198886', 'n_tokens_mistral': 5862, 'n_tokens_neox': 5246, 'n_words': 993}