Skip to content

Commit 3410eb9

Browse files
authored
Merge pull request #5890 from CCI-Tools/new_texture_sampler_prop
Set texture sampler properties of ImageryLayer
2 parents d2a7982 + cdc9045 commit 3410eb9

8 files changed

+348
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
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>
Loading

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
Change Log
22
==========
3+
34
### 1.39 - 2017-11-01
45

56
* Added the ability to load Cesium's assets from the local file system if security permissions allow it. [#5830](https://github.com/AnalyticalGraphicsInc/cesium/issues/5830)
67
* Added function that inserts missing namespace declarations into KML files. [#5860](https://github.com/AnalyticalGraphicsInc/cesium/pull/5860)
78
* Added support for the layer.json `parentUrl` property in `CesiumTerrainProvider` to allow for compositing of tilesets.
89
* Fixed a bug that caused KML ground overlays to appear distorted when rotation was applied. [#5914](https://github.com/AnalyticalGraphicsInc/cesium/issues/5914)
10+
* Added two new properties to `ImageryLayer` that allow for adjusting the texture sampler used for up- and down-sampling of image tiles, namely `minificationFilter` and `magnificationFilter` with possible values `LINEAR` (the default) and `NEAREST` defined in `TextureMinificationFilter` and `TextureMagnificationFilter`. [#5846](https://github.com/AnalyticalGraphicsInc/cesium/issues/5846)
11+
* The enums `TextureMinificationFilter` and `TextureMagnificationFilter` have been made public to support the new texture filter properties mentioned above.
912
* KML files load when a Network Link fails [#5871](https://github.com/AnalyticalGraphicsInc/cesium/pull/5871)
1013
* Adds `invertClassification` and `invertClassificationColor` to `Scene`. When `invertClassification` is `true`, any 3D Tiles geometry that is not classified by a `ClassificationPrimitive` or `GroundPrimitive` will have its color multiplied by `invertClassificationColor`. [#5836](https://github.com/AnalyticalGraphicsInc/cesium/pull/5836)
1114
* Added `eyeSeparation` and `focalLength` properties to `Scene` to configure VR settings. [#5917](https://github.com/AnalyticalGraphicsInc/cesium/pull/5917)

Source/Renderer/TextureMagnificationFilter.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,38 @@ define([
77
'use strict';
88

99
/**
10-
* @private
10+
* Enumerates all possible filters used when magnifying WebGL textures, which takes places when zooming
11+
* into imagery. Provides the possible values for the {@link ImageryLayer#magnificationFilter} property.
12+
*
13+
* @exports TextureMagnificationFilter
14+
*
15+
* @see TextureMinificationFilter
16+
* @see ImageryLayer#magnificationFilter
1117
*/
1218
var TextureMagnificationFilter = {
19+
/**
20+
* Nearest neighbor sampling of image pixels to texture.
21+
*
22+
* @type {Number}
23+
* @constant
24+
*/
1325
NEAREST : WebGLConstants.NEAREST,
26+
/**
27+
* Bi-linear interpolation of image pixels to texture.
28+
*
29+
* @type {Number}
30+
* @constant
31+
*/
1432
LINEAR : WebGLConstants.LINEAR,
1533

34+
/**
35+
* Validates the given <code>textureMinificationFilter</code> with respect to the possible enum values.
36+
*
37+
* @private
38+
*
39+
* @param textureMagnificationFilter
40+
* @returns {Boolean} <code>true</code> if <code>textureMagnificationFilter</code> is valid.
41+
*/
1642
validate : function(textureMagnificationFilter) {
1743
return ((textureMagnificationFilter === TextureMagnificationFilter.NEAREST) ||
1844
(textureMagnificationFilter === TextureMagnificationFilter.LINEAR));

Source/Renderer/TextureMinificationFilter.js

+51-1
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,66 @@ define([
77
'use strict';
88

99
/**
10-
* @private
10+
* Enumerates all possible filters used when minifying WebGL textures, which takes places when zooming
11+
* out of imagery. Provides the possible values for the {@link ImageryLayer#minificationFilter} property.
12+
*
13+
* @exports TextureMinificationFilter
14+
*
15+
* @see TextureMagnificationFilter
16+
* @see ImageryLayer#minificationFilter
1117
*/
1218
var TextureMinificationFilter = {
19+
/**
20+
* Nearest neighbor sampling of image pixels to texture.
21+
*
22+
* @type {Number}
23+
* @constant
24+
*/
1325
NEAREST : WebGLConstants.NEAREST,
26+
/**
27+
* Bi-linear interpolation of image pixels to texture.
28+
*
29+
* @type {Number}
30+
* @constant
31+
*/
1432
LINEAR : WebGLConstants.LINEAR,
33+
/**
34+
* WebGL <code>NEAREST_MIPMAP_NEAREST</code> interpolation of image pixels to texture.
35+
*
36+
* @type {Number}
37+
* @constant
38+
*/
1539
NEAREST_MIPMAP_NEAREST : WebGLConstants.NEAREST_MIPMAP_NEAREST,
40+
/**
41+
* WebGL <code>LINEAR_MIPMAP_NEAREST</code> interpolation of image pixels to texture.
42+
*
43+
* @type {Number}
44+
* @constant
45+
*/
1646
LINEAR_MIPMAP_NEAREST : WebGLConstants.LINEAR_MIPMAP_NEAREST,
47+
/**
48+
* WebGL <code>NEAREST_MIPMAP_LINEAR</code> interpolation of image pixels to texture.
49+
*
50+
* @type {Number}
51+
* @constant
52+
*/
1753
NEAREST_MIPMAP_LINEAR : WebGLConstants.NEAREST_MIPMAP_LINEAR,
54+
/**
55+
* WebGL <code>LINEAR_MIPMAP_LINEAR</code> interpolation of image pixels to texture.
56+
*
57+
* @type {Number}
58+
* @constant
59+
*/
1860
LINEAR_MIPMAP_LINEAR : WebGLConstants.LINEAR_MIPMAP_LINEAR,
1961

62+
/**
63+
* Validates the given <code>textureMinificationFilter</code> with respect to the possible enum values.
64+
*
65+
* @private
66+
*
67+
* @param textureMinificationFilter
68+
* @returns {Boolean} <code>true</code> if <code>textureMinificationFilter</code> is valid.
69+
*/
2070
validate : function(textureMinificationFilter) {
2171
return ((textureMinificationFilter === TextureMinificationFilter.NEAREST) ||
2272
(textureMinificationFilter === TextureMinificationFilter.LINEAR) ||

0 commit comments

Comments
 (0)