|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> |
| 7 | + <meta name="description" content="Apply simple color-to-alpha on imagery layers."> |
| 8 | + <meta name="cesium-sandcastle-labels" content="Beginner, Tutorials"> |
| 9 | + <title>Cesium Demo</title> |
| 10 | + <script type="text/javascript" src="../Sandcastle-header.js"></script> |
| 11 | + <script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script> |
| 12 | + <script type="text/javascript"> |
| 13 | + if(typeof require === 'function') { |
| 14 | + require.config({ |
| 15 | + baseUrl : '../../../Source', |
| 16 | + waitSeconds : 120 |
| 17 | + }); |
| 18 | + } |
| 19 | + </script> |
| 20 | +</head> |
| 21 | +<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html"> |
| 22 | +<style> |
| 23 | + @import url(../templates/bucket.css); |
| 24 | + #toolbar { |
| 25 | + background: rgba(42, 42, 42, 0.8); |
| 26 | + padding: 4px; |
| 27 | + border-radius: 4px; |
| 28 | + } |
| 29 | +</style> |
| 30 | +<div id="cesiumContainer" class="fullSize"></div> |
| 31 | +<div id="loadingOverlay"><h1>Loading...</h1></div> |
| 32 | +<div id="toolbar"> |
| 33 | + <table><tbody> |
| 34 | + <tr> |
| 35 | + <td>Threshold</td> |
| 36 | + <td> |
| 37 | + <input type="range" min="0.0" max="1.0" step="0.01" data-bind="value: threshold, valueUpdate: 'input'"> |
| 38 | + </td> |
| 39 | + </tr> |
| 40 | + </tbody></table> |
| 41 | +</div> |
| 42 | +<script id="cesium_sandcastle_script"> |
| 43 | +function startup(Cesium) { |
| 44 | + 'use strict'; |
| 45 | +//Sandcastle_Begin |
| 46 | +var viewer = new Cesium.Viewer('cesiumContainer'); |
| 47 | + |
| 48 | +var layers = viewer.scene.imageryLayers; |
| 49 | + |
| 50 | +// Set oceans on Bing base layer to transparent |
| 51 | +var baseLayer = layers.get(0); |
| 52 | +baseLayer.colorToAlpha = new Cesium.Color(0.0, 0.016, 0.059); |
| 53 | +baseLayer.colorToAlphaThreshold = 0.2; |
| 54 | + |
| 55 | +// Add a bump layer with adjustable threshold |
| 56 | +var singleTileLayer = layers.addImageryProvider(new Cesium.SingleTileImageryProvider({ |
| 57 | + url : '../images/earthbump1k.jpg', |
| 58 | + rectangle : Cesium.Rectangle.fromDegrees(-180.0, -90.0, 180.0, 90.0) |
| 59 | +})); |
| 60 | + |
| 61 | +singleTileLayer.colorToAlpha = new Cesium.Color(0.0, 0.0, 0.0, 1.0); |
| 62 | +singleTileLayer.colorToAlphaThreshold = 0.1; |
| 63 | + |
| 64 | +var viewModel = { |
| 65 | + threshold : singleTileLayer.colorToAlphaThreshold |
| 66 | +}; |
| 67 | + |
| 68 | +Cesium.knockout.track(viewModel); |
| 69 | + |
| 70 | +var toolbar = document.getElementById('toolbar'); |
| 71 | +Cesium.knockout.applyBindings(viewModel, toolbar); |
| 72 | + |
| 73 | +Cesium.knockout.getObservable(viewModel, 'threshold').subscribe( |
| 74 | + function(newValue) { |
| 75 | + singleTileLayer.colorToAlphaThreshold = parseFloat(viewModel.threshold); |
| 76 | + } |
| 77 | +);//Sandcastle_End |
| 78 | + Sandcastle.finishedLoading(); |
| 79 | +} |
| 80 | +if (typeof Cesium !== 'undefined') { |
| 81 | + startup(Cesium); |
| 82 | +} else if (typeof require === 'function') { |
| 83 | + require(['Cesium'], startup); |
| 84 | +} |
| 85 | +</script> |
| 86 | +</body> |
| 87 | +</html> |
0 commit comments