Skip to content

Commit

Permalink
Merge branch 'master' into emissive-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Apr 27, 2018
2 parents e0197db + 125c398 commit 1b28b58
Show file tree
Hide file tree
Showing 25 changed files with 276 additions and 160 deletions.
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@ Change Log

### 1.45 - 2018-05-01

##### Major Announcements :loudspeaker:

* We've launched Cesium ion, read all about it in our [blog post](https://cesium.com/TBD).
* Cesium now uses ion services by default for base imagery, terrain, and geocoding. [Sign up](https://cesium.com/TBD) for a free ion account to get your own access token.

##### Breaking Changes :mega:
* `BingMapsImageryProvider` is no longer the default base imagery layer.
* `BingMapsGeocoderService` is no longer the default geocoder service.
* Cesium no longer ships with a demo Bing Maps API key.

##### Additions :tada:
* Added `IonGeocoderService` and made it the default geocoding service for the `Geocoder` widget.
* Added `createWorldImagery` which provides Bing Maps imagery via a Cesium ion account.
* Added option `logarithmicDepthBuffer` to `Scene`. With this option there is typically a single frustum using logarithmic depth rendered. This increases performance by issuing less draw calls to the GPU and helps to avoid artifacts on the connection of two frustums. [#5851](https://github.com/AnalyticalGraphicsInc/cesium/pull/5851)
* When a log depth buffer is supported, the frustum near and far planes default to `0.1` and `1e10` respectively.
* Added `Math.log2` to compute the base 2 logarithm of a number.
Expand All @@ -19,6 +30,7 @@ Change Log
* Fixed bugs in `TimeIntervalCollection.removeInterval`. [#6418](https://github.com/AnalyticalGraphicsInc/cesium/pull/6418).
* Fixed glTF support to handle meshes with and without tangent vectors, and with/without morph targets, sharing one material. [#6421](https://github.com/AnalyticalGraphicsInc/cesium/pull/6421)
* Fixed glTF support to handle skinned meshes when no skin is supplied. [#6061](https://github.com/AnalyticalGraphicsInc/cesium/issues/6061)
* Updated glTF 2.0 PBR shader to have brighter lighting. [#6430](https://github.com/AnalyticalGraphicsInc/cesium/pull/6430)
* Allow loadWithXhr to work with string URLs in a web worker.
* Updated to Draco 1.3.0 and implemented faster loading of Draco compressed glTF assets in browsers that support Web Assembly. [#6420](https://github.com/AnalyticalGraphicsInc/cesium/pull/6420)
* `GroundPrimitive`s and `ClassificationPrimitive`s will become ready when `show` is `false`. [#6428](https://github.com/AnalyticalGraphicsInc/cesium/pull/6428)
Expand Down
Binary file added Source/Assets/Images/ion-credit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 6 additions & 33 deletions Source/Core/BingMapsApi.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,35 @@
define([
'./Credit',
'./defined'
], function(
Credit,
defined) {
'use strict';

/**
* Object for setting and retrieving the default BingMaps API key.
* Object for setting and retrieving the default Bing Maps API key.
*
* A Bing API key is only required if you are using {@link BingMapsImageryProvider}
* or {@link BingMapsGeocoderService}. You can create your own key at
* {@link https://www.bingmapsportal.com/}.
*
* @exports BingMapsApi
*/
var BingMapsApi = {};

/**
* The default Bing Maps API key to use if one is not provided to the
* constructor of an object that uses the Bing Maps API. If this property is undefined,
* Cesium's default key is used, which is only suitable for use early in development.
* Please generate your own key by visiting
* {@link https://www.bingmapsportal.com/}
* as soon as possible and prior to deployment. When Cesium's default key is used,
* a message is printed to the console the first time the Bing Maps API is used.
* constructor of an object that uses the Bing Maps API.
*
* @type {String}
*/
BingMapsApi.defaultKey = undefined;

var printedBingWarning = false;
var errorCredit;
var errorString = '<b>This application is using Cesium\'s default Bing Maps key. Please create a new key for the application as soon as possible and prior to deployment by visiting <a href="https://www.bingmapsportal.com/">https://www.bingmapsportal.com/</a>, and provide your key to Cesium by setting the Cesium.BingMapsApi.defaultKey property before constructing the CesiumWidget or any other object that uses the Bing Maps API.</b>';

BingMapsApi.getKey = function(providedKey) {
if (defined(providedKey)) {
return providedKey;
}

if (!defined(BingMapsApi.defaultKey)) {
if (!printedBingWarning) {
console.log(errorString);
printedBingWarning = true;
}
return 'Ar9n20kTp-N8tEg3Dpx-Pgocmx3W0-GUnD_Bgt3h8g6pSeDL8yxByTVGHyMyjI2p';
}

return BingMapsApi.defaultKey;
};

BingMapsApi.getErrorCredit = function(providedKey) {
if (defined(providedKey) || defined(BingMapsApi.defaultKey)) {
return undefined;
}

if (!defined(errorCredit)) {
errorCredit = new Credit(errorString, true);
}

return errorCredit;
};

return BingMapsApi;
});
11 changes: 0 additions & 11 deletions Source/Core/BingMapsGeocoderService.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,14 @@ define([
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Scene} options.scene The scene
* @param {String} [options.key] A key to use with the Bing Maps geocoding service
*/
function BingMapsGeocoderService(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object('options.scene', options.scene);
//>>includeEnd('debug');

var key = options.key;
this._key = BingMapsApi.getKey(key);

if (defined(key)) {
var errorCredit = BingMapsApi.getErrorCredit(key);
if (defined(errorCredit)) {
options.scene._frameState.creditDisplay.addDefaultCredit(errorCredit);
}
}

this._resource = new Resource({
url: url,
queryParameters: {
Expand Down
36 changes: 33 additions & 3 deletions Source/Core/Ion.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
define([
'./Credit',
'./defined',
'./Resource'
], function(
Credit,
defined,
Resource) {
'use strict';

var defaultTokenCredit;
var defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0NDViM2NkNi0xYTE2LTRlZTUtODBlNy05M2Q4ODg4M2NmMTQiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTc4MDh9.sld5jPORDf_lWavMEsugh6vHPnjR6j3qd1aBkQTswNM';

/**
* Default settings for accessing the Cesium Ion API.
* Default settings for accessing the Cesium ion API.
* @exports Ion
*
* An ion access token is only required if you are using any ion related APIs.
* A default access token is provided for evaluation purposes only.
* Sign up for a free ion account and get your own access token at {@link https://cesium.com}
*
* @see IonResource
* @see IonImageryProvider
* @see IonGeocoderService
* @see createWorldImagery
* @see createWorldTerrain
* @see https://cesium.com
*/
var Ion = {};

Expand All @@ -20,7 +32,7 @@ define([
*
* @type {String}
*/
Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0NDViM2NkNi0xYTE2LTRlZTUtODBlNy05M2Q4ODg4M2NmMTQiLCJpZCI6MjU5LCJpYXQiOjE1MTgxOTc4MDh9.sld5jPORDf_lWavMEsugh6vHPnjR6j3qd1aBkQTswNM';
Ion.defaultAccessToken = defaultAccessToken;

/**
* Gets or sets the default Cesium ion server.
Expand All @@ -30,5 +42,23 @@ define([
*/
Ion.defaultServer = new Resource({ url: 'https://api.cesium.com/' });

Ion.getDefaultTokenCredit = function(providedKey) {
if (providedKey !== defaultAccessToken) {
return undefined;
}

if (!defined(defaultTokenCredit)) {
var defaultTokenMessage = '<b> \
This application is using Cesium\'s default ion access token. Please assign <i>Cesium.Ion.defaultAccessToken</i> \
with an access token from your ion account before making any Cesium API calls. \
You can sign up for a free ion account at <a href="https://cesium.com">https://cesium.com</a>.</b>';

defaultTokenCredit = new Credit(defaultTokenMessage, true);
console.log(defaultTokenMessage);
}

return defaultTokenCredit;
};

return Ion;
});
13 changes: 12 additions & 1 deletion Source/Core/IonGeocoderService.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ define([
* @alias IonGeocoderService
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {Object} options Object with the following properties:
* @param {Scene} options.scene The scene
* @param {String} [options.accessToken=Ion.defaultAccessToken] The access token to use.
* @param {String} [options.accessToken=Ion.defaultAccessToken] The access token to use.
* @param {String|Resource} [options.server=Ion.defaultServer] The resource to the Cesium ion API server.
*
Expand All @@ -32,10 +34,19 @@ define([
function IonGeocoderService(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);

//>>includeStart('debug', pragmas.debug);
Check.typeOf.object('options.scene', options.scene);
//>>includeEnd('debug');

var accessToken = defaultValue(options.accessToken, Ion.defaultAccessToken);
var server = Resource.createIfNeeded(defaultValue(options.server, Ion.defaultServer));
server.appendForwardSlash();

var defaultTokenCredit = Ion.getDefaultTokenCredit(accessToken);
if (defined(defaultTokenCredit)) {
options.scene._frameState.creditDisplay.addDefaultCredit(defaultTokenCredit);
}

var searchEndpoint = server.getDerivedResource({
url: 'v1/geocode'
});
Expand Down
12 changes: 11 additions & 1 deletion Source/Core/IonResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,23 @@ define([
return this._credits;
}

this._credits = this._ionEndpoint.attributions.map(Credit.getIonCredit);
this._credits = IonResource.getCreditsFromEndpoint(this._ionEndpoint, this._ionEndpointResource);

return this._credits;
}
}
});

/** @private */
IonResource.getCreditsFromEndpoint = function(endpoint, endpointResource) {
var credits = endpoint.attributions.map(Credit.getIonCredit);
var defaultTokenCredit = Ion.getDefaultTokenCredit(endpointResource.queryParameters.access_token);
if (defined(defaultTokenCredit)) {
credits.push(defaultTokenCredit);
}
return credits;
};

/** @inheritdoc */
IonResource.prototype.clone = function(result) {
// We always want to use the root's information because it's the most up-to-date
Expand Down
1 change: 1 addition & 0 deletions Source/Core/createWorldTerrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define([
*
* @exports createWorldTerrain
*
* @param {Object} [options] Object with the following properties:
* @param {Boolean} [options.requestVertexNormals=false] Flag that indicates if the client should request additional lighting information from the server if available.
* @param {Boolean} [options.requestWaterMask=false] Flag that indicates if the client should request per tile water masks from the server if available.
* @returns {CesiumTerrainProvider}
Expand Down
5 changes: 0 additions & 5 deletions Source/Scene/BingMapsImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ define([
//>>includeEnd('debug');

this._key = BingMapsApi.getKey(options.key);
this._keyErrorCredit = BingMapsApi.getErrorCredit(options.key);
this._resource = Resource.createIfNeeded(options.url);
this._tileProtocol = options.tileProtocol;
this._mapStyle = defaultValue(options.mapStyle, BingMapsStyle.AERIAL);
Expand Down Expand Up @@ -512,10 +511,6 @@ define([
var rectangle = this._tilingScheme.tileXYToRectangle(x, y, level, rectangleScratch);
var result = getRectangleAttribution(this._attributionList, level, rectangle);

if (defined(this._keyErrorCredit)) {
result.push(this._keyErrorCredit);
}

return result;
};

Expand Down
30 changes: 22 additions & 8 deletions Source/Scene/CreditDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,13 @@ define([
var screenCredits = this._currentFrameCredits.screenCredits;

if (credit._isIon) {
this._currentCesiumCredit = credit;
} else if (!credit.showOnScreen) {
// If this is the an ion logo credit from the ion server
// Juse use the default credit (which is identical) to avoid blinking
this._currentCesiumCredit = getDefaultCredit();
return;
}

if (!credit.showOnScreen) {
this._currentFrameCredits.lightboxCredits[credit.id] = credit;
} else {
screenCredits[credit.id] = credit;
Expand Down Expand Up @@ -518,6 +523,20 @@ define([
CreditDisplay._cesiumCredit = undefined;
CreditDisplay._cesiumCreditInitialized = false;

var defaultCredit;
function getDefaultCredit() {
if (!defined(defaultCredit)) {
var logo = buildModuleUrl('Assets/Images/ion-credit.png');
defaultCredit = new Credit('<a href="https://cesium.com/" target="_blank"><img src="' + logo + '" title="Cesium ion"/></a>', true);
}

if (!CreditDisplay._cesiumCreditInitialized) {
CreditDisplay._cesiumCredit = defaultCredit;
CreditDisplay._cesiumCreditInitialized = true;
}
return defaultCredit;
}

defineProperties(CreditDisplay, {
/**
* Gets or sets the Cesium logo credit.
Expand All @@ -526,12 +545,7 @@ define([
*/
cesiumCredit: {
get: function() {
if (!CreditDisplay._cesiumCreditInitialized) {
var cesiumLogo = buildModuleUrl('Assets/Images/cesium_credit.png');
CreditDisplay._cesiumCredit = new Credit('<a href="https://cesiumjs.org/" target="_blank"><img src="' + cesiumLogo + '" title="CesiumJS"/></a>', true);
CreditDisplay._cesiumCreditInitialized = true;
}

getDefaultCredit();
return CreditDisplay._cesiumCredit;
},
set: function(value) {
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/IonImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ define([
imageryProvider = factory(endpoint.options);
}

that._tileCredits = endpoint.attributions.map(Credit.getIonCredit);
that._tileCredits = IonResource.getCreditsFromEndpoint(endpoint, endpointResource);

imageryProvider.errorEvent.addEventListener(function(tileProviderError) {
//Propagate the errorEvent but set the provider to this instance instead
Expand Down
41 changes: 41 additions & 0 deletions Source/Scene/IonWorldImageryStyle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
define([
'../Core/freezeObject'
], function(
freezeObject) {
'use strict';

// Note, these values map directly to ion asset ids.

/**
* The types of imagery provided by {@link createWorldImagery}.
*
* @exports IonWorldImageryStyle
*/
var IonWorldImageryStyle = {
/**
* Aerial imagery.
*
* @type {String}
* @constant
*/
AERIAL : 2,

/**
* Aerial imagery with a road overlay.
*
* @type {String}
* @constant
*/
AERIAL_WITH_LABELS : 3,

/**
* Roads without additional imagery.
*
* @type {String}
* @constant
*/
ROAD : 4
};

return freezeObject(IonWorldImageryStyle);
});

0 comments on commit 1b28b58

Please sign in to comment.