Skip to content

Commit

Permalink
Add when promise library and switch some APIs to use them.
Browse files Browse the repository at this point in the history
Replace Jobs.downloadImage and getImageFromUrl with promise-based loadImage.
Change jsonp to work in a promise-based way.  Fix some other random documentation
problems I noticed along the way.
  • Loading branch information
shunter committed Jul 20, 2012
1 parent c22d90d commit 9ded81c
Show file tree
Hide file tree
Showing 24 changed files with 1,358 additions and 320 deletions.
2 changes: 1 addition & 1 deletion .settings/.jsdtscope
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="ThirdParty/" kind="src" path=""/>
<classpathentry excluding="Source/ThirdParty/when.js|ThirdParty/" kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary/StandardBrowser/html5"/>
<classpathentry kind="output" path=""/>
Expand Down
2 changes: 1 addition & 1 deletion .settings/com.eclipsesource.jshint.ui.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
eclipse.preferences.version=1
excluded=Source/ThirdParty/Chain.js\:Source/ThirdParty/Tween.js\:ThirdParty//*
excluded=Source/ThirdParty/Chain.js\:Source/ThirdParty/Tween.js\:Source/ThirdParty/when.js\:ThirdParty//*
included=//*.js
options=bitwise \: false,\r\ncurly \: true,\r\neqeqeq \: true,\r\nforin \: true,\r\nimmed \: false,\r\nlatedef \: true,\r\nnewcap \: true,\r\nnoarg \: true,\r\nnoempty \: false,\r\nnonew \: true,\r\nplusplus \: false,\r\nregexp \: false,\r\nundef \: true,\r\nstrict \: true,\r\ntrailing \: false,\r\nasi \: false,\r\nboss \: false,\r\ndebug \: false,\r\neqnull \: false,\r\nes5 \: false,\r\nesnext \: false,\r\nevil \: false,\r\nexpr \: false,\r\nfuncscope \: false,\r\nglobalstrict \: false,\r\niterator \: false,\r\nlastsemic \: false,\r\nlaxbreak \: false,\r\nlaxcomma \: false,\r\nloopfunc \: false,\r\nmultistr \: false,\r\nonecase \: false,\r\nproto \: false,\r\nregexdash \: false,\r\nscripturl \: false,\r\nsmarttabs \: false,\r\nshadow \: false,\r\nsub \: false,\r\nsupernew \: false,\r\nvalidthis \: false,\r\nbrowser \: true
projectSpecificOptions=true
2 changes: 1 addition & 1 deletion .settings/org.eclipse.wst.jsdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ org.eclipse.wst.jsdt.core.formatter.keep_empty_array_initializer_on_one_line=fal
org.eclipse.wst.jsdt.core.formatter.keep_empty_objlit_initializer_on_one_line=false
org.eclipse.wst.jsdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.wst.jsdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.wst.jsdt.core.formatter.lineSplit=200
org.eclipse.wst.jsdt.core.formatter.lineSplit=9999
org.eclipse.wst.jsdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.wst.jsdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.wst.jsdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Beta Releases

* The free look feature has been removed from `CameraColumbusViewController` in favor of rotating about the point clicked on the map with the middle mouse button.
* The `Camera2DController` constructor and `CameraControllerCollection.add2D` now require a projection instead of an ellipsoid.
* `Chain` has been removed. `when` is now included as a more complete CommonJS Promises/A implementation.
* `Jobs.downloadImage` has removed, replaced with `loadImage` to provide a promise that will asynchronously load an image.
* `jsonp` now returns a promise for the requested data, removing the need for a callback parameter.
* JulianDate.getTimeStandard() has been removed, dates are now always stored internally as TAI.
* LeapSeconds.setLeapSeconds now takes an array of LeapSecond instances instead of JSON.
* TimeStandard.convertUtcToTai and TimeStandard.convertTaiToUtc have been removed as they are no longer needed.
Expand Down
27 changes: 14 additions & 13 deletions Examples/Sandbox/CodeSnippets/Billboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,37 @@
};
};

Sandbox.SeveralBillboards = function (scene, ellipsoid, primitives) {
this.code = function () {
Cesium.Chain.run(
Cesium.Jobs.downloadImage('Images/Cesium_Logo_overlay.png'),
Cesium.Jobs.downloadImage('Images/facility.gif')).thenRun(
function () {
Sandbox.SeveralBillboards = function(scene, ellipsoid, primitives) {
this.code = function() {
Cesium.when.all([
Cesium.loadImage('Images/Cesium_Logo_overlay.png'),
Cesium.loadImage('Images/facility.gif')
])
.then(function(images) {
// Once both images are downloaded, they are combined into one image,
// called a texture atlas, which is assigned to a billboard-collection.
// Several billboards can be added to the same collection; each billboard
// references an image in the texture atlas.

var billboards = new Cesium.BillboardCollection(undefined);
var images = [this.images['Images/Cesium_Logo_overlay.png'],
this.images['Images/facility.gif']];
var textureAtlas = scene.getContext().createTextureAtlas({images : images});
var billboards = new Cesium.BillboardCollection();
var textureAtlas = scene.getContext().createTextureAtlas({
images : images
});
billboards.setTextureAtlas(textureAtlas);

billboards.add({
position : ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-75.59777, 40.03883)),
imageIndex : 0 // Logo
imageIndex : 0 // Logo
});

billboards.add({
position : ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-80.50, 35.14)),
imageIndex : 1 // Facility
imageIndex : 1 // Facility
});

billboards.add({
position : ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-80.12, 25.46)),
imageIndex : 1 // Facility
imageIndex : 1 // Facility
});

primitives.add(billboards);
Expand Down
10 changes: 7 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ http://sponeil.net/
>
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
### chain.js
### when

https://github.com/chriso/chain.js
https://github.com/cujojs/when

> Copyright (c) 2010 Chris O'Hara <[email protected]>
> Open Source Initiative OSI - The MIT License
>
> http://www.opensource.org/licenses/mit-license.php
>
> Copyright (c) 2011 Brian Cavalier
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ define([
* evt.raiseEvent('1', '2');
* evt.removeEventListener(MyObject.prototype.myListener);
*/
function Event() {
var Event = function() {
this._listeners = [];
this._scopes = [];
}
};

/**
* Registers a callback function to be executed whenever the event is raised.
Expand Down
61 changes: 0 additions & 61 deletions Source/Core/Jobs.js

This file was deleted.

4 changes: 2 additions & 2 deletions Source/Core/combine.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define([
*
* @exception {DeveloperError} Duplicate member.
*/
function combine() {
var combine = function() {
var composite = {};

for ( var i = 0, length = arguments.length; i < length; ++i) {
Expand All @@ -32,7 +32,7 @@ define([
}

return composite;
}
};

return combine;
});
6 changes: 4 additions & 2 deletions Source/Core/defaultValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ define(function() {
* Returns the first parameter if not undefined, otherwise the second parameter.
* Useful for setting a default value for a parameter.
*
* @exports defaultValue
*
* @example
* param = defaultValue(param, 'default');
*/
function defaultValue(a, b) {
var defaultValue = function(a, b) {
if (typeof a !== 'undefined') {
return a;
}
return b;
}
};

return defaultValue;
});
4 changes: 2 additions & 2 deletions Source/Core/destroyObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ define([
* return destroyObject(this);
* };
*/
function destroyObject(object, message) {
var destroyObject = function(object, message) {
message = defaultValue(message, 'This object was destroyed, i.e., destroy() was called.');

function throwOnDestroyed() {
Expand All @@ -55,7 +55,7 @@ define([
object.isDestroyed = returnTrue;

return undefined;
}
};

return destroyObject;
});
72 changes: 0 additions & 72 deletions Source/Core/getImageFromUrl.js

This file was deleted.

Loading

0 comments on commit 9ded81c

Please sign in to comment.