Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Jun 7, 2017
1 parent da3420d commit a2dae0c
Show file tree
Hide file tree
Showing 18 changed files with 318 additions and 228 deletions.
6 changes: 4 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ Change Log

* Deprecated
* `GoogleEarthImageryProvider` has been deprecated and will be removed in Cesium 1.37, use `GoogleEarthEnterpriseMapsProvider` instead.
* The `throttleRequest` parameter for `TerrainProvider.requestTileGeometry`, `CesiumTerrainProvider.requestTileGeometry`, `VRTheWorldTerrainProvider.requestTileGeometry`, and `EllipsoidTerrainProvider.requestTileGeometry` is deprecated and will be replaced with an optional `Request` object. The `throttleRequests` parameter will be removed in 1.36, instead to throttle requests set the request's `throttle` property to `true`.
* The ability to provide a Promise for the `options.url` parameter of `loadWithXhr` is deprecated. The same applies for the `url` parameter for `loadArrayBuffer`, `loadBlob`, `loadImageViaBlob`, `loadText`, `loadJson`, `loadXML`, `loadImage`, `loadCRN`, `loadKTX`, and `loadCubeMap`. This will be removed in 1.36, instead `url` must be a string.
* The `throttleRequest` parameter for `TerrainProvider.requestTileGeometry`, `CesiumTerrainProvider.requestTileGeometry`, `VRTheWorldTerrainProvider.requestTileGeometry`, and `EllipsoidTerrainProvider.requestTileGeometry` is deprecated and will be replaced with an optional `Request` object. The `throttleRequests` parameter will be removed in 1.37. Instead to throttle requests set the request's `throttle` property to `true`.
* The ability to provide a Promise for the `options.url` parameter of `loadWithXhr` and for the `url` parameter of `loadArrayBuffer`, `loadBlob`, `loadImageViaBlob`, `loadText`, `loadJson`, `loadXML`, `loadImage`, `loadCRN`, `loadKTX`, and `loadCubeMap` is deprecated. This will be removed in 1.37, instead `url` must be a string.

* Added an `options.request` parameter to `loadWithXhr` and a `request` parameter to `loadArrayBuffer`, `loadBlob`, `loadImageViaBlob`, `loadText`, `loadJson`, `loadJsonp`, `loadXML`, `loadImageFromTypedArray`, `loadImage`, `loadCRN`, and `loadKTX`.

### 1.34 - 2017-06-01

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/CesiumTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ define([
}

if (typeof request === 'boolean') {
deprecationWarning('throttleRequests', 'The throttleRequest parameter for requestTileGeometry was deprecated in Cesium 1.35. It will be removed in 1.36.');
deprecationWarning('throttleRequests', 'The throttleRequest parameter for requestTileGeometry was deprecated in Cesium 1.35. It will be removed in 1.37.');
request = new Request({
throttle : request,
throttleByServer : request,
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/GoogleEarthEnterpriseTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ define([
sharedRequest = terrainRequests[q];
} else { // Create new request for terrain
if (typeof request === 'boolean') {
deprecationWarning('throttleRequests', 'The throttleRequest parameter for requestTileGeometry was deprecated in Cesium 1.35. It will be removed in 1.36.');
deprecationWarning('throttleRequests', 'The throttleRequest parameter for requestTileGeometry was deprecated in Cesium 1.35. It will be removed in 1.37.');
request = new Request({
throttle : request,
throttleByServer : request,
Expand Down
30 changes: 23 additions & 7 deletions Source/Core/Heap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ define([
* @constructor
* @private
*
* @param {Function} comparator The comparator to use for the heap. If comparator(a, b) is less than 0, sort a to a lower index than b, otherwise sort to a higher index.
* @param {Object} options Object with the following properties:
* @param {Function} options.comparator The comparator to use for the heap. If comparator(a, b) is less than 0, sort a to a lower index than b, otherwise sort to a higher index.
*/
function Heap(comparator) {
function Heap(options) {
//>>includeStart('debug', pragmas.debug);
Check.defined('comparator', comparator);
Check.typeOf.object('options', options);
Check.defined('options.comparator', options.comparator);
//>>includeEnd('debug');

this._comparator = comparator;
this._comparator = options.comparator;
this._array = [];
this._length = 0;
this._maximumLength = undefined;
Expand Down Expand Up @@ -78,6 +80,19 @@ define([
this._array.length = value;
}
}
},

/**
* The comparator to use for the heap. If comparator(a, b) is less than 0, sort a to a lower index than b, otherwise sort to a higher index.
*
* @memberof Heap.prototype
*
* @type (Function}
*/
comparator : {
get : function() {
return this._comparator;
}
}
});

Expand Down Expand Up @@ -156,6 +171,7 @@ define([

var array = this._array;
var comparator = this._comparator;
var maximumLength = this._maximumLength;

var index = this._length++;
if (index < array.length) {
Expand All @@ -176,9 +192,9 @@ define([

var removedElement;

if (defined(this._maximumLength) && (this._length > this._maximumLength)) {
removedElement = array[this.maximumLength];
this._length = this._maximumLength;
if (defined(maximumLength) && (this._length > maximumLength)) {
removedElement = array[maximumLength];
this._length = maximumLength;
}

return removedElement;
Expand Down
69 changes: 32 additions & 37 deletions Source/Core/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ define([
* @param {Object} [options] An object with the following properties:
* @param {Boolean} [options.url] The url to request.
* @param {Function} [options.requestFunction] The actual function that makes the request. The function takes no arguments and returns a promise for the requested data.
* @param {Function} [options.cancelFunction] Function to call when a request is cancelled. The function takes no arguments.
* @param {Function} [options.priorityFunction] Function that is called when the request is updated. The function takes no arguments and returns the updated priority value.
* @param {Number} [options.priority=0.0] The initial priority of the request.
* @param {Boolean} [options.throttle=false] Whether to throttle and prioritize the request. If false, the request will be sent immediately. If true, the request will be throttled and sent based on priority.
* @param {Boolean} [options.throttleByServer=false] Whether to throttle the request by server.
* @param {RequestType} [options.type=RequestType.OTHER] The type of request.
* @param {Number} [options.distance=0.0] The distance from the camera, used to prioritize requests.
* @param {Number} [options.screenSpaceError=0.0] The screen space error, used to prioritize requests.
*/
function Request(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
Expand All @@ -45,11 +46,35 @@ define([
* The actual function that makes the request. The function takes no arguments and returns a promise for the requested data.
*
* @type {Function}
*
* @private
*/
this.requestFunction = options.requestFunction;

/**
* Function to call when a request is cancelled. The function takes no arguments.
*
* @type {Function}
*/
this.cancelFunction = options.cancelFunction;

/**
* Function that is called when the request is updated. The function takes no arguments and returns the updated priority value.
*
* @type {Function}
*/
this.priorityFunction = options.priorityFunction;

/**
* Priority is a unit-less value where lower values represent higher priority.
* For world-based objects, this is usually the distance from the camera.
* A request that does not have a priority function defaults to a priority of 0.
*
* This value is updated every frame with the result of priorityFunction, if defined.
*
* @type {Number}
* @default 0.0
*/
this.priority = defaultValue(options.priority, 0.0);

/**
* Whether to throttle and prioritize the request. If false, the request will be sent immediately. If true, the
* request will be throttled and sent based on priority.
Expand Down Expand Up @@ -84,52 +109,22 @@ define([
this.type = defaultValue(options.type, RequestType.OTHER);

/**
* The distance from the camera, used to prioritize requests. This value may be edited continually to update
* the request's priority.
*
* @type {Number}
*
* @default 0.0
*/
this.distance = defaultValue(options.distance, 0.0);

/**
* The screen space error, used to prioritize requests. This value may be edited continually to update
* the request's priority.
*
* @type {Number}
*
* @default 0.0
*/
this.screenSpaceError = defaultValue(options.screenSpaceError, 0.0);

/**
* The request server, derived from the url.
* The server key which contains the authority and scheme from the url.
*
* @type {String}
*
* @private
*/
this.server = undefined;
this.serverKey = undefined;

/**
* The current state of the request.
*
* @type {RequestState}
*
* @private
* @readonly
*/
this.state = RequestState.UNISSUED;

/**
* Reference to the underlying XMLHttpRequest so that it may be aborted in RequestScheduler.
*
* @type {Object}
*
* @private
*/
this.xhr = undefined;

/**
* The requests's deferred promise.
*
Expand Down
Loading

0 comments on commit a2dae0c

Please sign in to comment.