Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New utility object for working with the Cesium ion beta API #6136

Merged
merged 5 commits into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Change Log
* 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.
* 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.
* Added `ClippingPlaneCollection.isSupported` function for checking if rendering with clipping planes is supported.
* Added new `CesiumIon` utility class for working with the Cesium ion beta API.
* Improved CZML Custom Properties sandcastle example [#6086](https://github.com/AnalyticalGraphicsInc/cesium/pull/6086)
* Added `Plane.projectPointOntoPlane` for projecting a `Cartesian3` position onto a `Plane` [#6092](https://github.com/AnalyticalGraphicsInc/cesium/pull/6092)
* Added `Cartesian3.projectVector` for projecting one vector to another [#6093](https://github.com/AnalyticalGraphicsInc/cesium/pull/6093)
* Added `Plane.projectPointOntoPlane` for projecting a `Cartesian3` position onto a `Plane` [#6092](https://github.com/AnalyticalGraphicsInc/cesium/pull/6092)
* Added `Cartesian3.projectVector` for projecting one vector to another [#6093](https://github.com/AnalyticalGraphicsInc/cesium/pull/6093)
* 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)
* Added `AttributeCompression.zigZagDeltaDecode` which will decode delta and ZigZag encoded buffers in place.
* Added `pack` and `unpack` functions to `OrientedBoundingBox` for packing to and unpacking from a flat buffer.
Expand All @@ -28,7 +29,7 @@ Change Log
* Only one node is supported.
* Only one mesh per node is supported.
* Only one primitive per mesh is supported.
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.
* Updated 'Viewer.zoomTo' and 'Viewer.flyTo' to take in Cesium3DTilesets as a target and updated sandcastle 3DTileset examples to reflect this change
* Fixed a glTF animation bug that caused certain animations to jitter. [#5740](https://github.com/AnalyticalGraphicsInc/cesium/pull/5740)
* Fixed a bug when creating billboard and model entities without a globe. [#6109](https://github.com/AnalyticalGraphicsInc/cesium/pull/6109)
Expand Down
12 changes: 8 additions & 4 deletions Source/Core/loadImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ define([
}

function makeRequest(resource, allowCrossOrigin) {
var url = resource.url;
var request = resource.request;
request.url = url;
request.url = resource.url;
request.requestFunction = function() {
var crossOrigin;
var url = resource.url;

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

return promise
.otherwise(function(e) {
//Don't retry cancelled or otherwise aborted requests
if (request.state !== RequestState.FAILED) {
return when.reject(e);
}

return resource.retryOnError(e)
.then(function(retry) {
if (retry) {
// Reset request so it can try again
request.state = RequestState.UNISSUED;
request.deferred = undefined;

return makeRequest(resource);
return makeRequest(resource, allowCrossOrigin);
}

return when.reject(e);
});
});
Expand Down
34 changes: 16 additions & 18 deletions Source/Core/loadJsonp.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ define([
resource.addQueryParameters(callbackQuery);

var request = resource.request;
var url = resource.url;
request.url = url;
request.url = resource.url;
request.requestFunction = function() {
var deferred = when.defer();

Expand All @@ -113,7 +112,7 @@ define([
}
};

loadJsonp.loadAndExecuteScript(url, functionName, deferred);
loadJsonp.loadAndExecuteScript(resource.url, functionName, deferred);
return deferred.promise;
};

Expand All @@ -124,22 +123,21 @@ define([

return promise
.otherwise(function(e) {
if (request.state === RequestState.FAILED) {
return resource.retryOnError(e)
.then(function(retry) {
if (retry) {
// Reset request so it can try again
request.state = RequestState.UNISSUED;
request.deferred = undefined;

return makeRequest(resource, callbackParameterName, functionName);
}

return when.reject(e);
});
if (request.state !== RequestState.FAILED) {
return when.reject(e);
}

return when.reject(e);
return resource.retryOnError(e)
.then(function(retry) {
if (retry) {
// Reset request so it can try again
request.state = RequestState.UNISSUED;
request.deferred = undefined;

return makeRequest(resource, callbackParameterName, functionName);
}

return when.reject(e);
});
});
}

Expand Down
44 changes: 21 additions & 23 deletions Source/Core/loadWithXhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,17 @@ define([
}

function makeRequest(optionsOrResource) {
var url = optionsOrResource.url;
var request = optionsOrResource.request;
request.url = url;

var responseType = optionsOrResource.responseType;
var method = optionsOrResource.method;
var data = optionsOrResource.data;
var headers = optionsOrResource.headers;
var overrideMimeType = optionsOrResource.overrideMimeType;
request.url = optionsOrResource.url;

request.requestFunction = function() {
var responseType = optionsOrResource.responseType;
var method = optionsOrResource.method;
var data = optionsOrResource.data;
var headers = optionsOrResource.headers;
var overrideMimeType = optionsOrResource.overrideMimeType;
var deferred = when.defer();
var xhr = loadWithXhr.load(url, responseType, method, data, headers, deferred, overrideMimeType);
var xhr = loadWithXhr.load(optionsOrResource.url, responseType, method, data, headers, deferred, overrideMimeType);
if (defined(xhr) && defined(xhr.abort)) {
request.cancelFunction = function() {
xhr.abort();
Expand All @@ -116,22 +114,22 @@ define([
return data;
})
.otherwise(function(e) {
if ((request.state === RequestState.FAILED) && defined(optionsOrResource.retryOnError)) {
return optionsOrResource.retryOnError(e)
.then(function(retry) {
if (retry) {
// Reset request so it can try again
request.state = RequestState.UNISSUED;
request.deferred = undefined;

return makeRequest(optionsOrResource);
}

return when.reject(e);
});
if ((request.state !== RequestState.FAILED) || !defined(optionsOrResource.retryOnError)) {
return when.reject(e);
}

return when.reject(e);
return optionsOrResource.retryOnError(e)
.then(function(retry) {
if (retry) {
// Reset request so it can try again
request.state = RequestState.UNISSUED;
request.deferred = undefined;

return makeRequest(optionsOrResource);
}

return when.reject(e);
});
});
}

Expand Down
Loading