Skip to content

Commit 6b6f55c

Browse files
author
Josh Bernstein
committedOct 23, 2017
Merge branch 'master' into 5819_fix_for_empty_icon_tag
2 parents fa1e73e + 9758800 commit 6b6f55c

15 files changed

+367
-85
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) ||

‎Source/Scene/ImageryLayer.js

+93-14
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ define([
136136
* the gamma value to use for the tile. The function is executed for every
137137
* frame and for every tile, so it must be fast.
138138
* @param {ImagerySplitDirection|Function} [options.splitDirection=ImagerySplitDirection.NONE] The {@link ImagerySplitDirection} split to apply to this layer.
139+
* @param {TextureMinificationFilter} [options.minificationFilter=TextureMinificationFilter.LINEAR] The
140+
* texture minification filter to apply to this layer. Possible values
141+
* are <code>TextureMinificationFilter.LINEAR</code> and
142+
* <code>TextureMinificationFilter.NEAREST</code>.
143+
* @param {TextureMagnificationFilter} [options.magnificationFilter=TextureMagnificationFilter.LINEAR] The
144+
* texture minification filter to apply to this layer. Possible values
145+
* are <code>TextureMagnificationFilter.LINEAR</code> and
146+
* <code>TextureMagnificationFilter.NEAREST</code>.
139147
* @param {Boolean} [options.show=true] True if the layer is shown; otherwise, false.
140148
* @param {Number} [options.maximumAnisotropy=maximum supported] The maximum anisotropy level to use
141149
* for texture filtering. If this parameter is not specified, the maximum anisotropy supported
@@ -211,6 +219,32 @@ define([
211219
*/
212220
this.splitDirection = defaultValue(options.splitDirection, defaultValue(imageryProvider.defaultSplit, ImageryLayer.DEFAULT_SPLIT));
213221

222+
/**
223+
* The {@link TextureMinificationFilter} to apply to this layer.
224+
* Possible values are {@link TextureMinificationFilter.LINEAR} (the default)
225+
* and {@link TextureMinificationFilter.NEAREST}.
226+
*
227+
* To take effect, this property must be set immediately after adding the imagery layer.
228+
* Once a texture is loaded it won't be possible to change the texture filter used.
229+
*
230+
* @type {TextureMinificationFilter}
231+
* @default {@link ImageryLayer.DEFAULT_MINIFICATION_FILTER}
232+
*/
233+
this.minificationFilter = defaultValue(options.minificationFilter, defaultValue(imageryProvider.defaultMinificationFilter, ImageryLayer.DEFAULT_MINIFICATION_FILTER));
234+
235+
/**
236+
* The {@link TextureMagnificationFilter} to apply to this layer.
237+
* Possible values are {@link TextureMagnificationFilter.LINEAR} (the default)
238+
* and {@link TextureMagnificationFilter.NEAREST}.
239+
*
240+
* To take effect, this property must be set immediately after adding the imagery layer.
241+
* Once a texture is loaded it won't be possible to change the texture filter used.
242+
*
243+
* @type {TextureMagnificationFilter}
244+
* @default {@link ImageryLayer.DEFAULT_MAGNIFICATION_FILTER}
245+
*/
246+
this.magnificationFilter = defaultValue(options.magnificationFilter, defaultValue(imageryProvider.defaultMagnificationFilter, ImageryLayer.DEFAULT_MAGNIFICATION_FILTER));
247+
214248
/**
215249
* Determines if this layer is shown.
216250
*
@@ -309,13 +343,29 @@ define([
309343
ImageryLayer.DEFAULT_GAMMA = 1.0;
310344

311345
/**
312-
* This value is used as the default spliat for the imagery layer if one is not provided during construction
346+
* This value is used as the default split for the imagery layer if one is not provided during construction
313347
* or by the imagery provider.
314348
* @type {ImagerySplitDirection}
315349
* @default ImagerySplitDirection.NONE
316350
*/
317351
ImageryLayer.DEFAULT_SPLIT = ImagerySplitDirection.NONE;
318352

353+
/**
354+
* This value is used as the default texture minification filter for the imagery layer if one is not provided
355+
* during construction or by the imagery provider.
356+
* @type {TextureMinificationFilter}
357+
* @default TextureMinificationFilter.LINEAR
358+
*/
359+
ImageryLayer.DEFAULT_MINIFICATION_FILTER = TextureMinificationFilter.LINEAR;
360+
361+
/**
362+
* This value is used as the default texture magnification filter for the imagery layer if one is not provided
363+
* during construction or by the imagery provider.
364+
* @type {TextureMagnificationFilter}
365+
* @default TextureMagnificationFilter.LINEAR
366+
*/
367+
ImageryLayer.DEFAULT_MAGNIFICATION_FILTER = TextureMagnificationFilter.LINEAR;
368+
319369
/**
320370
* Gets a value indicating whether this layer is the base layer in the
321371
* {@link ImageryLayerCollection}. The base layer is the one that underlies all
@@ -764,6 +814,11 @@ define([
764814
}
765815
}
766816

817+
var sampler = new Sampler({
818+
minificationFilter : this.minificationFilter,
819+
magnificationFilter : this.magnificationFilter
820+
});
821+
767822
// Imagery does not need to be discarded, so upload it to WebGL.
768823
var texture;
769824
if (defined(image.internalFormat)) {
@@ -774,13 +829,15 @@ define([
774829
height : image.height,
775830
source : {
776831
arrayBufferView : image.bufferView
777-
}
832+
},
833+
sampler : sampler
778834
});
779835
} else {
780836
texture = new Texture({
781837
context : context,
782838
source : image,
783-
pixelFormat : imageryProvider.hasAlphaChannel ? PixelFormat.RGBA : PixelFormat.RGB
839+
pixelFormat : imageryProvider.hasAlphaChannel ? PixelFormat.RGBA : PixelFormat.RGB,
840+
sampler : sampler
784841
});
785842
}
786843

@@ -793,30 +850,52 @@ define([
793850
imagery.state = ImageryState.TEXTURE_LOADED;
794851
};
795852

853+
function getSamplerKey(minificationFilter, magnificationFilter, maximumAnisotropy) {
854+
return minificationFilter + ':' + magnificationFilter + ':' + maximumAnisotropy;
855+
}
856+
796857
function finalizeReprojectTexture(imageryLayer, context, imagery, texture) {
858+
var minificationFilter = imageryLayer.minificationFilter;
859+
var magnificationFilter = imageryLayer.magnificationFilter;
860+
var usesLinearTextureFilter = minificationFilter === TextureMinificationFilter.LINEAR && magnificationFilter === TextureMagnificationFilter.LINEAR;
797861
// Use mipmaps if this texture has power-of-two dimensions.
798-
if (!PixelFormat.isCompressedFormat(texture.pixelFormat) && CesiumMath.isPowerOfTwo(texture.width) && CesiumMath.isPowerOfTwo(texture.height)) {
799-
var mipmapSampler = context.cache.imageryLayer_mipmapSampler;
862+
// In addition, mipmaps are only generated if the texture filters are both LINEAR.
863+
if (usesLinearTextureFilter && !PixelFormat.isCompressedFormat(texture.pixelFormat) && CesiumMath.isPowerOfTwo(texture.width) && CesiumMath.isPowerOfTwo(texture.height)) {
864+
minificationFilter = TextureMinificationFilter.LINEAR_MIPMAP_LINEAR;
865+
var maximumSupportedAnisotropy = ContextLimits.maximumTextureFilterAnisotropy;
866+
var maximumAnisotropy = Math.min(maximumSupportedAnisotropy, defaultValue(imageryLayer._maximumAnisotropy, maximumSupportedAnisotropy));
867+
var mipmapSamplerKey = getSamplerKey(minificationFilter, magnificationFilter, maximumAnisotropy);
868+
var mipmapSamplers = context.cache.imageryLayerMipmapSamplers;
869+
if (!defined(mipmapSamplers)) {
870+
mipmapSamplers = {};
871+
context.cache.imageryLayerMipmapSamplers = mipmapSamplers;
872+
}
873+
var mipmapSampler = mipmapSamplers[mipmapSamplerKey];
800874
if (!defined(mipmapSampler)) {
801-
var maximumSupportedAnisotropy = ContextLimits.maximumTextureFilterAnisotropy;
802-
mipmapSampler = context.cache.imageryLayer_mipmapSampler = new Sampler({
875+
mipmapSampler = mipmapSamplers[mipmapSamplerKey] = new Sampler({
803876
wrapS : TextureWrap.CLAMP_TO_EDGE,
804877
wrapT : TextureWrap.CLAMP_TO_EDGE,
805-
minificationFilter : TextureMinificationFilter.LINEAR_MIPMAP_LINEAR,
806-
magnificationFilter : TextureMagnificationFilter.LINEAR,
807-
maximumAnisotropy : Math.min(maximumSupportedAnisotropy, defaultValue(imageryLayer._maximumAnisotropy, maximumSupportedAnisotropy))
878+
minificationFilter : minificationFilter,
879+
magnificationFilter : magnificationFilter,
880+
maximumAnisotropy : maximumAnisotropy
808881
});
809882
}
810883
texture.generateMipmap(MipmapHint.NICEST);
811884
texture.sampler = mipmapSampler;
812885
} else {
813-
var nonMipmapSampler = context.cache.imageryLayer_nonMipmapSampler;
886+
var nonMipmapSamplerKey = getSamplerKey(minificationFilter, magnificationFilter, 0);
887+
var nonMipmapSamplers = context.cache.imageryLayerNonMipmapSamplers;
888+
if (!defined(nonMipmapSamplers)) {
889+
nonMipmapSamplers = {};
890+
context.cache.imageryLayerNonMipmapSamplers = nonMipmapSamplers;
891+
}
892+
var nonMipmapSampler = nonMipmapSamplers[nonMipmapSamplerKey];
814893
if (!defined(nonMipmapSampler)) {
815-
nonMipmapSampler = context.cache.imageryLayer_nonMipmapSampler = new Sampler({
894+
nonMipmapSampler = nonMipmapSamplers[nonMipmapSamplerKey] = new Sampler({
816895
wrapS : TextureWrap.CLAMP_TO_EDGE,
817896
wrapT : TextureWrap.CLAMP_TO_EDGE,
818-
minificationFilter : TextureMinificationFilter.LINEAR,
819-
magnificationFilter : TextureMagnificationFilter.LINEAR
897+
minificationFilter : minificationFilter,
898+
magnificationFilter : magnificationFilter
820899
});
821900
}
822901
texture.sampler = nonMipmapSampler;

‎Source/Scene/ImageryProvider.js

+16
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ define([
9393
*/
9494
this.defaultGamma = undefined;
9595

96+
/**
97+
* The default texture minification filter to apply to this provider.
98+
*
99+
* @type {TextureMinificationFilter}
100+
* @default undefined
101+
*/
102+
this.defaultMinificationFilter = undefined;
103+
104+
/**
105+
* The default texture magnification filter to apply to this provider.
106+
*
107+
* @type {TextureMagnificationFilter}
108+
* @default undefined
109+
*/
110+
this.defaultMagnificationFilter = undefined;
111+
96112
DeveloperError.throwInstantiationError();
97113
}
98114

‎Specs/DataSources/KmlTourFlyToSpec.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/*global defineSuite*/
21
defineSuite([
32
'DataSources/KmlTourFlyTo',
43
'DataSources/KmlCamera',

‎Specs/DataSources/KmlTourSpec.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/*global defineSuite*/
21
defineSuite([
32
'DataSources/KmlTour',
43
'DataSources/KmlTourFlyTo',

‎Specs/Renderer/RenderStateSpec.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
defineSuite([
2+
'Renderer/RenderState',
3+
'Core/defined',
24
'Core/WebGLConstants',
35
'Core/WindingOrder',
46
'Renderer/ContextLimits',
5-
'Renderer/RenderState',
67
'Specs/createContext'
78
], function(
9+
RenderState,
10+
defined,
811
WebGLConstants,
912
WindingOrder,
1013
ContextLimits,
11-
RenderState,
1214
createContext) {
1315
'use strict';
1416

@@ -407,19 +409,9 @@ defineSuite([
407409
expect(cache[fullKey]).not.toBeDefined();
408410
});
409411

410-
it('freezes render states', function(){
412+
it('freezes render states', function() {
411413
var rs = RenderState.fromCache();
412-
expect(function() {
413-
rs.depthRange = {};
414-
}).toThrow();
415-
416-
expect(function() {
417-
rs.frontFace = WindingOrder.COUNTER_CLOCKWISE;
418-
}).toThrow();
419-
420-
expect(function() {
421-
rs._applyFunctions.push(function(){});
422-
}).not.toThrow();
414+
expect(Object.isFrozen(rs)).toBe(!window.specsUsingRelease);
423415
});
424416

425417
it('fails to create (frontFace)', function() {
+8-52
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,23 @@
1-
/*global defineSuite*/
21
defineSuite([
32
'Renderer/freezeRenderState'
43
], function(
54
freezeRenderState) {
65
'use strict';
76

8-
it('works for literals', function() {
7+
it('works as expected', function() {
98
var fresh = {
109
a: 1,
11-
b: 'b',
12-
c: 2.2,
13-
u: undefined,
14-
n: null
15-
};
16-
17-
var frozen = freezeRenderState(fresh);
18-
19-
expect(function() {
20-
frozen.a = 2;
21-
}).toThrow();
22-
23-
expect(function() {
24-
frozen.b = 'c';
25-
}).toThrow();
26-
27-
expect(function() {
28-
frozen.c = 2;
29-
}).toThrow();
30-
31-
});
32-
33-
it('works for deep objects', function() {
34-
var fresh = {
35-
a: 2,
36-
o: {
37-
b: 2,
10+
b: {
3811
c: 'c'
39-
}
40-
};
41-
42-
var frozen = freezeRenderState(fresh);
43-
44-
expect(function() {
45-
frozen.o.b = 3;
46-
frozen.o.c = 'dddd';
47-
}).toThrow();
48-
});
49-
50-
it('ignores _applyFunctions', function() {
51-
var fresh = {
52-
a: 1,
12+
},
5313
_applyFunctions: [function() { }]
5414
};
5515

5616
var frozen = freezeRenderState(fresh);
57-
58-
expect(function() {
59-
frozen.a = 0;
60-
}).toThrow();
61-
62-
expect(function() {
63-
frozen._applyFunctions.push(function() { });
64-
}).not.toThrow();
17+
expect(Object.isFrozen(frozen)).toBe(true);
18+
expect(Object.isFrozen(frozen.a)).toBe(true);
19+
expect(Object.isFrozen(frozen.b)).toBe(true);
20+
expect(Object.isFrozen(frozen.c)).toBe(true);
21+
expect(Object.isFrozen(frozen._applyFunctions)).toBe(false);
6522
});
66-
6723
});

‎Specs/Scene/ImageryLayerSpec.js

+48
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ defineSuite([
77
'Core/Rectangle',
88
'Core/RequestScheduler',
99
'Renderer/ComputeEngine',
10+
'Renderer/TextureMagnificationFilter',
11+
'Renderer/TextureMinificationFilter',
1012
'Scene/ArcGisMapServerImageryProvider',
1113
'Scene/BingMapsImageryProvider',
1214
'Scene/createTileMapServiceImageryProvider',
@@ -30,6 +32,8 @@ defineSuite([
3032
Rectangle,
3133
RequestScheduler,
3234
ComputeEngine,
35+
TextureMagnificationFilter,
36+
TextureMinificationFilter,
3337
ArcGisMapServerImageryProvider,
3438
BingMapsImageryProvider,
3539
createTileMapServiceImageryProvider,
@@ -187,6 +191,9 @@ defineSuite([
187191
return imagery.state === ImageryState.READY;
188192
}).then(function() {
189193
expect(imagery.texture).toBeDefined();
194+
expect(imagery.texture.sampler).toBeDefined();
195+
expect(imagery.texture.sampler.minificationFilter).toEqual(TextureMinificationFilter.LINEAR_MIPMAP_LINEAR);
196+
expect(imagery.texture.sampler.magnificationFilter).toEqual(TextureMinificationFilter.LINEAR);
190197
expect(textureBeforeReprojection).not.toEqual(imagery.texture);
191198
imagery.releaseReference();
192199
});
@@ -269,6 +276,9 @@ defineSuite([
269276
return imagery.state === ImageryState.READY;
270277
}).then(function() {
271278
expect(imagery.texture).toBeDefined();
279+
expect(imagery.texture.sampler).toBeDefined();
280+
expect(imagery.texture.sampler.minificationFilter).toEqual(TextureMinificationFilter.LINEAR_MIPMAP_LINEAR);
281+
expect(imagery.texture.sampler.magnificationFilter).toEqual(TextureMinificationFilter.LINEAR);
272282
expect(textureBeforeReprojection).not.toEqual(imagery.texture);
273283
imagery.releaseReference();
274284
});
@@ -315,6 +325,9 @@ defineSuite([
315325
return imagery.state === ImageryState.READY;
316326
}).then(function() {
317327
expect(imagery.texture).toBeDefined();
328+
expect(imagery.texture.sampler).toBeDefined();
329+
expect(imagery.texture.sampler.minificationFilter).toEqual(TextureMinificationFilter.LINEAR_MIPMAP_LINEAR);
330+
expect(imagery.texture.sampler.magnificationFilter).toEqual(TextureMinificationFilter.LINEAR);
318331
expect(imagery.texture).toBe(imagery.textureWebMercator);
319332
imagery.releaseReference();
320333
});
@@ -367,6 +380,41 @@ defineSuite([
367380
expect(layer.isDestroyed()).toEqual(true);
368381
});
369382

383+
it('allows setting texture filter properties', function() {
384+
var provider = new SingleTileImageryProvider({
385+
url : 'Data/Images/Red16x16.png'
386+
});
387+
388+
// expect default LINEAR
389+
var layer = new ImageryLayer(provider);
390+
expect(layer.minificationFilter).toEqual(TextureMinificationFilter.LINEAR);
391+
expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.LINEAR);
392+
layer.destroy();
393+
394+
// change to NEAREST
395+
layer = new ImageryLayer(provider, {
396+
minificationFilter: TextureMinificationFilter.NEAREST,
397+
magnificationFilter: TextureMagnificationFilter.NEAREST
398+
});
399+
expect(layer.minificationFilter).toEqual(TextureMinificationFilter.NEAREST);
400+
expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.NEAREST);
401+
layer.destroy();
402+
});
403+
404+
it('uses default texture filter properties of ImageryProvider', function() {
405+
var provider = new SingleTileImageryProvider({
406+
url : 'Data/Images/Red16x16.png'
407+
});
408+
409+
provider.defaultMinificationFilter = TextureMinificationFilter.NEAREST;
410+
provider.defaultMagnificationFilter = TextureMinificationFilter.NEAREST;
411+
412+
var layer = new ImageryLayer(provider);
413+
expect(layer.minificationFilter).toEqual(TextureMinificationFilter.NEAREST);
414+
expect(layer.magnificationFilter).toEqual(TextureMagnificationFilter.NEAREST);
415+
layer.destroy();
416+
});
417+
370418
it('returns HTTP status code information in TileProviderError', function() {
371419
// Web browsers unfortunately provide very little information about what went wrong when an Image fails
372420
// to load. But when an imagery provider is configured to use a TileDiscardPolicy, Cesium downloads the image

‎Specs/Scene/TimeDynamicImagerySpec.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/*global defineSuite*/
21
defineSuite([
32
'Scene/TimeDynamicImagery',
43
'Core/Clock',

‎Specs/customizeJasmine.js

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ define([
4242
});
4343
}
4444

45+
window.specsUsingRelease = release;
46+
4547
window.fdefineSuite = function(deps, name, suite, categories) {
4648
defineSuite(deps, name, suite, categories, true);
4749
};

‎Specs/spec-main.js

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
}
2222

2323
var built = getQueryParameter('built');
24+
var release = getQueryParameter('release');
2425

2526
var toRequire = ['Cesium'];
2627

@@ -73,6 +74,8 @@
7374
*/
7475
window.jasmine = jasmineRequire.core(jasmineRequire);
7576

77+
window.specsUsingRelease = release;
78+
7679
window.defineSuite = function(deps, name, suite, categories) {
7780
/*global define,describe*/
7881
if (typeof suite === 'object' || typeof suite === 'string') {

0 commit comments

Comments
 (0)
Please sign in to comment.