Skip to content

Commit 6896cd5

Browse files
author
Tom Fili
authored
Merge pull request #6136 from AnalyticalGraphicsInc/cesium-ion
New utility object for working with the Cesium ion beta API
2 parents 9dc0836 + fe92f99 commit 6896cd5

File tree

6 files changed

+554
-48
lines changed

6 files changed

+554
-48
lines changed

CHANGES.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ Change Log
99
* For all classes/functions that can now take a `Resource` instance, all additional parameters that are part of the `Resource` class have been deprecated and will be removed in Cesium 1.44. This generally includes `proxy`, `headers` and `query` parameters.
1010
* Major refactor of URL handling. All classes that take a url parameter, can now take a Resource or a String. This includes all imagery providers, all terrain providers, `Cesium3DTileset`, `KMLDataSource`, `CZMLDataSource`, `GeoJsonDataSource`, `Model`, `Billboard`, along with all the low level `load*()` functions.
1111
* Added `ClippingPlaneCollection.isSupported` function for checking if rendering with clipping planes is supported.
12+
* Added new `CesiumIon` utility class for working with the Cesium ion beta API.
1213
* Improved CZML Custom Properties sandcastle example [#6086](https://github.com/AnalyticalGraphicsInc/cesium/pull/6086)
13-
* Added `Plane.projectPointOntoPlane` for projecting a `Cartesian3` position onto a `Plane` [#6092](https://github.com/AnalyticalGraphicsInc/cesium/pull/6092)
14-
* Added `Cartesian3.projectVector` for projecting one vector to another [#6093](https://github.com/AnalyticalGraphicsInc/cesium/pull/6093)
14+
* Added `Plane.projectPointOntoPlane` for projecting a `Cartesian3` position onto a `Plane` [#6092](https://github.com/AnalyticalGraphicsInc/cesium/pull/6092)
15+
* Added `Cartesian3.projectVector` for projecting one vector to another [#6093](https://github.com/AnalyticalGraphicsInc/cesium/pull/6093)
1516
* Added `Cesium3DTileset.tileFailed` event that will be raised when a tile fails to load. The object passed to the event listener will have a url and message property. If there are no event listeners, error messages will be logged to the console. [#6088](https://github.com/AnalyticalGraphicsInc/cesium/pull/6088)
1617
* Added `AttributeCompression.zigZagDeltaDecode` which will decode delta and ZigZag encoded buffers in place.
1718
* Added `pack` and `unpack` functions to `OrientedBoundingBox` for packing to and unpacking from a flat buffer.
@@ -28,7 +29,7 @@ Change Log
2829
* Only one node is supported.
2930
* Only one mesh per node is supported.
3031
* Only one primitive per mesh is supported.
31-
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.
32+
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.
3233
* Updated 'Viewer.zoomTo' and 'Viewer.flyTo' to take in Cesium3DTilesets as a target and updated sandcastle 3DTileset examples to reflect this change
3334
* Fixed a glTF animation bug that caused certain animations to jitter. [#5740](https://github.com/AnalyticalGraphicsInc/cesium/pull/5740)
3435
* Fixed a bug when creating billboard and model entities without a globe. [#6109](https://github.com/AnalyticalGraphicsInc/cesium/pull/6109)

Source/Core/loadImage.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ define([
7979
}
8080

8181
function makeRequest(resource, allowCrossOrigin) {
82-
var url = resource.url;
8382
var request = resource.request;
84-
request.url = url;
83+
request.url = resource.url;
8584
request.requestFunction = function() {
8685
var crossOrigin;
86+
var url = resource.url;
8787

8888
// data URIs can't have allowCrossOrigin set.
8989
if (isDataUri(url) || isBlobUri(url)) {
@@ -106,16 +106,20 @@ define([
106106

107107
return promise
108108
.otherwise(function(e) {
109+
//Don't retry cancelled or otherwise aborted requests
110+
if (request.state !== RequestState.FAILED) {
111+
return when.reject(e);
112+
}
113+
109114
return resource.retryOnError(e)
110115
.then(function(retry) {
111116
if (retry) {
112117
// Reset request so it can try again
113118
request.state = RequestState.UNISSUED;
114119
request.deferred = undefined;
115120

116-
return makeRequest(resource);
121+
return makeRequest(resource, allowCrossOrigin);
117122
}
118-
119123
return when.reject(e);
120124
});
121125
});

Source/Core/loadJsonp.js

+16-18
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ define([
9797
resource.addQueryParameters(callbackQuery);
9898

9999
var request = resource.request;
100-
var url = resource.url;
101-
request.url = url;
100+
request.url = resource.url;
102101
request.requestFunction = function() {
103102
var deferred = when.defer();
104103

@@ -113,7 +112,7 @@ define([
113112
}
114113
};
115114

116-
loadJsonp.loadAndExecuteScript(url, functionName, deferred);
115+
loadJsonp.loadAndExecuteScript(resource.url, functionName, deferred);
117116
return deferred.promise;
118117
};
119118

@@ -124,22 +123,21 @@ define([
124123

125124
return promise
126125
.otherwise(function(e) {
127-
if (request.state === RequestState.FAILED) {
128-
return resource.retryOnError(e)
129-
.then(function(retry) {
130-
if (retry) {
131-
// Reset request so it can try again
132-
request.state = RequestState.UNISSUED;
133-
request.deferred = undefined;
134-
135-
return makeRequest(resource, callbackParameterName, functionName);
136-
}
137-
138-
return when.reject(e);
139-
});
126+
if (request.state !== RequestState.FAILED) {
127+
return when.reject(e);
140128
}
141-
142-
return when.reject(e);
129+
return resource.retryOnError(e)
130+
.then(function(retry) {
131+
if (retry) {
132+
// Reset request so it can try again
133+
request.state = RequestState.UNISSUED;
134+
request.deferred = undefined;
135+
136+
return makeRequest(resource, callbackParameterName, functionName);
137+
}
138+
139+
return when.reject(e);
140+
});
143141
});
144142
}
145143

Source/Core/loadWithXhr.js

+21-23
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,17 @@ define([
8585
}
8686

8787
function makeRequest(optionsOrResource) {
88-
var url = optionsOrResource.url;
8988
var request = optionsOrResource.request;
90-
request.url = url;
91-
92-
var responseType = optionsOrResource.responseType;
93-
var method = optionsOrResource.method;
94-
var data = optionsOrResource.data;
95-
var headers = optionsOrResource.headers;
96-
var overrideMimeType = optionsOrResource.overrideMimeType;
89+
request.url = optionsOrResource.url;
9790

9891
request.requestFunction = function() {
92+
var responseType = optionsOrResource.responseType;
93+
var method = optionsOrResource.method;
94+
var data = optionsOrResource.data;
95+
var headers = optionsOrResource.headers;
96+
var overrideMimeType = optionsOrResource.overrideMimeType;
9997
var deferred = when.defer();
100-
var xhr = loadWithXhr.load(url, responseType, method, data, headers, deferred, overrideMimeType);
98+
var xhr = loadWithXhr.load(optionsOrResource.url, responseType, method, data, headers, deferred, overrideMimeType);
10199
if (defined(xhr) && defined(xhr.abort)) {
102100
request.cancelFunction = function() {
103101
xhr.abort();
@@ -116,22 +114,22 @@ define([
116114
return data;
117115
})
118116
.otherwise(function(e) {
119-
if ((request.state === RequestState.FAILED) && defined(optionsOrResource.retryOnError)) {
120-
return optionsOrResource.retryOnError(e)
121-
.then(function(retry) {
122-
if (retry) {
123-
// Reset request so it can try again
124-
request.state = RequestState.UNISSUED;
125-
request.deferred = undefined;
126-
127-
return makeRequest(optionsOrResource);
128-
}
129-
130-
return when.reject(e);
131-
});
117+
if ((request.state !== RequestState.FAILED) || !defined(optionsOrResource.retryOnError)) {
118+
return when.reject(e);
132119
}
133120

134-
return when.reject(e);
121+
return optionsOrResource.retryOnError(e)
122+
.then(function(retry) {
123+
if (retry) {
124+
// Reset request so it can try again
125+
request.state = RequestState.UNISSUED;
126+
request.deferred = undefined;
127+
128+
return makeRequest(optionsOrResource);
129+
}
130+
131+
return when.reject(e);
132+
});
135133
});
136134
}
137135

0 commit comments

Comments
 (0)