|
| 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="Set the texture minification and magnification filters of an imagery layer."> |
| 8 | + <meta name="cesium-sandcastle-labels" content="Beginner, Tutorials, Showcases"> |
| 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 | + require.config({ |
| 14 | + baseUrl : '../../../Source', |
| 15 | + waitSeconds : 60 |
| 16 | + }); |
| 17 | + </script> |
| 18 | +</head> |
| 19 | +<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html"> |
| 20 | + |
| 21 | +<style> |
| 22 | + @import url(../templates/bucket.css); |
| 23 | + |
| 24 | + #slider { |
| 25 | + position: absolute; |
| 26 | + left: 50%; |
| 27 | + top: 0px; |
| 28 | + background-color: #D3D3D3; |
| 29 | + width: 2px; |
| 30 | + height: 100%; |
| 31 | + z-index: 9999; |
| 32 | + } |
| 33 | + |
| 34 | + #slider:hover { |
| 35 | + cursor: ew-resize; |
| 36 | + } |
| 37 | + |
| 38 | +</style> |
| 39 | + |
| 40 | +<div id="cesiumContainer" class="fullSize"> |
| 41 | + <div id="slider"></div> |
| 42 | +</div> |
| 43 | +<div id="loadingOverlay"><h1>Loading...</h1></div> |
| 44 | +<div id="toolbar"></div> |
| 45 | + |
| 46 | +<script id="cesium_sandcastle_script"> |
| 47 | + |
| 48 | + |
| 49 | +function startup(Cesium) { |
| 50 | + 'use strict'; |
| 51 | +//Sandcastle_Begin |
| 52 | +var viewer = new Cesium.Viewer('cesiumContainer'); |
| 53 | +viewer.camera.flyTo({destination : new Cesium.Rectangle.fromDegrees(-84, 43, -80, 47)}); |
| 54 | + |
| 55 | +var layers = viewer.imageryLayers; |
| 56 | +layers.removeAll(); |
| 57 | + |
| 58 | +var layerLinear = layers.addImageryProvider(Cesium.createTileMapServiceImageryProvider({ |
| 59 | + url : require.toUrl('Assets/Textures/NaturalEarthII') |
| 60 | +})); |
| 61 | + |
| 62 | +var layerNearest = layers.addImageryProvider(Cesium.createTileMapServiceImageryProvider({ |
| 63 | + url : require.toUrl('Assets/Textures/NaturalEarthII') |
| 64 | +})); |
| 65 | + |
| 66 | +// Set the texture minification and magnification filters of layerNearest. Default is LINEAR. |
| 67 | +layerNearest.minificationFilter = Cesium.TextureMinificationFilter.NEAREST; |
| 68 | +layerNearest.magnificationFilter = Cesium.TextureMagnificationFilter.NEAREST; |
| 69 | + |
| 70 | +// The remaining code installs a split layer so the effect of the texture filters becomes apparent. |
| 71 | + |
| 72 | +layerNearest.splitDirection = Cesium.ImagerySplitDirection.RIGHT; |
| 73 | + |
| 74 | +var slider = document.getElementById('slider'); |
| 75 | +viewer.scene.imagerySplitPosition = (slider.offsetLeft) / slider.parentElement.offsetWidth; |
| 76 | + |
| 77 | +var dragStartX = 0; |
| 78 | + |
| 79 | +document.getElementById('slider').addEventListener('mousedown', mouseDown, false); |
| 80 | +window.addEventListener('mouseup', mouseUp, false); |
| 81 | + |
| 82 | +function mouseUp() { |
| 83 | + window.removeEventListener('mousemove', sliderMove, true); |
| 84 | +} |
| 85 | + |
| 86 | +function mouseDown(e) { |
| 87 | + var slider = document.getElementById('slider'); |
| 88 | + dragStartX = e.clientX - slider.offsetLeft; |
| 89 | + window.addEventListener('mousemove', sliderMove, true); |
| 90 | +} |
| 91 | + |
| 92 | +function sliderMove(e) { |
| 93 | + var slider = document.getElementById('slider'); |
| 94 | + var splitPosition = (e.clientX - dragStartX) / slider.parentElement.offsetWidth; |
| 95 | + slider.style.left = 100.0 * splitPosition + "%"; |
| 96 | + viewer.scene.imagerySplitPosition = splitPosition; |
| 97 | +} |
| 98 | +//Sandcastle_End |
| 99 | + |
| 100 | + Sandcastle.finishedLoading(); |
| 101 | +} |
| 102 | +if (typeof Cesium !== "undefined") { |
| 103 | + startup(Cesium); |
| 104 | +} else if (typeof require === "function") { |
| 105 | + require(["Cesium"], startup); |
| 106 | +} |
| 107 | +</script> |
| 108 | + |
| 109 | +</body> |
| 110 | +</html> |
0 commit comments