Skip to content

Commit

Permalink
Merge branch 'master' into texture-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Apr 7, 2019
2 parents ef534ae + 502f34a commit 4467d23
Show file tree
Hide file tree
Showing 62 changed files with 1,634 additions and 314 deletions.
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/3D Tiles Interior.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
var viewer = new Cesium.Viewer('cesiumContainer');

var tileset = new Cesium.Cesium3DTileset({
url: Cesium.IonResource.fromAssetId(5742)
url: Cesium.IonResource.fromAssetId(19365)
});
viewer.scene.primitives.add(tileset);

Expand Down
Binary file modified Apps/Sandcastle/gallery/3D Tiles Interior.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Apps/Sandcastle/gallery/3D Tiles Point Cloud Shading.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@
destination: new Cesium.Cartesian3(4401744.644145314, 225051.41078911052, 4595420.374784433),
orientation: new Cesium.HeadingPitchRoll(5.646733805039757, -0.276607153839886, 6.281110875400085)
});

tilesetToViewModel(tileset);
}

function checkZero(newValue) {
Expand Down
31 changes: 27 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
Change Log
==========

### 1.57 - 2019-05-01

##### Additions :tada:
* Added support for the `KHR_texture_transform` glTF extension. [#7549](https://github.com/AnalyticalGraphicsInc/cesium/pull/7549)

##### Fixes :wrench:
* Fixed an error where `clampToHeightMostDetailed` or `sampleHeightMostDetailed` would crash if entities were created when the promise resolved. [#7690](https://github.com/AnalyticalGraphicsInc/cesium/pull/7690)

### 1.56.1 - 2019-04-02

##### Additions :tada:
* `Resource.fetchImage` now takes a `preferImageBitmap` option to use `createImageBitmap` when supported to move image decode off the main thread. This option defaults to `false`.

##### Breaking Changes :mega:
* The following breaking changes are relative to 1.56. The `Resource.fetchImage` behavior is now identical to 1.55 and earlier.
* Changed `Resource.fetchImage` back to return an `Image` by default, instead of an `ImageBitmap` when supported. Note that an `ImageBitmap` cannot be flipped during texture upload. Instead, set `flipY : true` during fetch to flip it.
* Changed the default `flipY` option in `Resource.fetchImage` to false. This only has an effect when ImageBitmap is used.

### 1.56 - 2019-04-01

##### Breaking Changes :mega:
* `Resource.fetchImage` now returns an `ImageBitmap` instead of `Image` when supported. This allows for decoding images while fetching using `createImageBitmap` to greatly speed up texture upload and decrease frame drops when loading models with large textures. [#7579](https://github.com/AnalyticalGraphicsInc/cesium/pull/7579)
* `Cesium3DTileStyle.style` now has an empty `Object` as its default value, instead of `undefined`. [#7567](https://github.com/AnalyticalGraphicsInc/cesium/issues/7567)
* `Scene.clampToHeight` now takes an optional `width` argument before the `result` argument. [#7693](https://github.com/AnalyticalGraphicsInc/cesium/pull/7693)
* In the `Resource` class, `addQueryParameters` and `addTemplateValues` have been removed. Please use `setQueryParameters` and `setTemplateValues` instead. [#7695](https://github.com/AnalyticalGraphicsInc/cesium/issues/7695)

##### Deprecated :hourglass_flowing_sand:
* `Resource.fetchImage` now takes an options object. Use `resource.fetchImage({ preferBlob: true })` instead of `resource.fetchImage(true)`. The previous function definition will no longer work in 1.57. [#7579](https://github.com/AnalyticalGraphicsInc/cesium/pull/7579)

##### Additions :tada:
* Added support for touch and hold gesture. The touch and hold delay can be customized by updating `ScreenSpaceEventHandler.touchHoldDelayMilliseconds`. [#7286](https://github.com/AnalyticalGraphicsInc/cesium/pull/7286)
* `Resource.fetchImage` now has a `flipY` option to vertically flip an image during fetch & decode. It is only valid when `ImageBitmapOptions` is supported by the browser. [#7579](https://github.com/AnalyticalGraphicsInc/cesium/pull/7579)
* Added `backFaceCulling` and `normalShading` options to `PointCloudShading`. Both options are only applicable for point clouds containing normals. [#7399](https://github.com/AnalyticalGraphicsInc/cesium/pull/7399)
* Added support for touch and hold gesture. The touch and hold delay can be customized by updating `ScreenSpaceEventHandler.touchHoldDelayMilliseconds`. [#7286](https://github.com/AnalyticalGraphicsInc/cesium/pull/7286)
* Added support for the `KHR_texture_transform` glTF extension. [#7549](https://github.com/AnalyticalGraphicsInc/cesium/pull/7549)
* `Cesium3DTileStyle.style` reacts to updates and represents the current state of the style. [#7567](https://github.com/AnalyticalGraphicsInc/cesium/issues/7567)

##### Fixes :wrench:
* Fixed the value for `BlendFunction.ONE_MINUS_CONSTANT_COLOR`. [#7624](https://github.com/AnalyticalGraphicsInc/cesium/pull/7624)
* Fixed `HeadingPitchRoll.pitch` being `NaN` when using `.fromQuaternion` do to a rounding error
for pitches close to +/- 90°. [#7654](https://github.com/AnalyticalGraphicsInc/cesium/pull/7654)
* Fixed `HeadingPitchRoll.pitch` being `NaN` when using `.fromQuaternion` due to a rounding error for pitches close to +/- 90°. [#7654](https://github.com/AnalyticalGraphicsInc/cesium/pull/7654)
* Fixed a type of crash caused by the camera being rotated through terrain. [#6783](https://github.com/AnalyticalGraphicsInc/cesium/issues/6783)
* Fixed an error in `Resource` when used with template replacements using numeric keys. [#7668](https://github.com/AnalyticalGraphicsInc/cesium/pull/7668)
* Fixed an error in `Cesium3DTilePointFeature` where `anchorLineColor` used the same color instance instead of cloning the color [#7686](https://github.com/AnalyticalGraphicsInc/cesium/pull/7686)

### 1.55 - 2019-03-01

Expand Down
2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_0.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_1.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_10.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_11.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_12.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_13.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_14.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_15.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_16.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_17.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_18.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_19.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_2.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_21.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_22.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_23.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_24.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_25.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_26.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_27.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_3.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_4.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_5.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_6.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_7.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_8.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Assets/IAU2006_XYS/IAU2006_XYS_9.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Core/Ion.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define([
'use strict';

var defaultTokenCredit;
var defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkZDJhY2VhYy0wYzljLTRiNWUtYmNhOC04OTQyZDk1YmZhMDkiLCJpZCI6MjU5LCJzY29wZXMiOlsiYXNyIiwiZ2MiXSwiaWF0IjoxNTUxNDUyMjc4fQ.B5BkE4TUBja1yOnT9sC6t8rrWghvVep21tzBq6r7aHo';
var defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlZTNjZGYzNC0wMzI5LTQ3NGEtOWM1Yy03YzhhOWU4NTI2MGQiLCJpZCI6MjU5LCJzY29wZXMiOlsiYXNyIiwiZ2MiXSwiaWF0IjoxNTU0MTQwMTQxfQ.egqhQs14qStY2dQTESVJz2JnUoXFNz4EFkdl50yqoOw';

/**
* Default settings for accessing the Cesium ion API.
Expand Down
1 change: 1 addition & 0 deletions Source/Core/IonResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ define([
};
if (defined(userOptions)) {
options.flipY = userOptions.flipY;
options.preferImageBitmap = userOptions.preferImageBitmap;
}
}

Expand Down
137 changes: 67 additions & 70 deletions Source/Core/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,17 @@ define([
// objectToQuery escapes the placeholders. Undo that.
var url = uri.toString().replace(/%7B/g, '{').replace(/%7D/g, '}');

var template = this._templateValues;
var keys = Object.keys(template);
if (keys.length > 0) {
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = template[key];
url = url.replace(new RegExp('{' + key + '}', 'g'), encodeURIComponent(value));
var templateValues = this._templateValues;
url = url.replace(/{(.*?)}/g, function(match, key) {
var replacement = templateValues[key];
if (defined(replacement)) {
// use the replacement value from templateValues if there is one...
return encodeURIComponent(replacement);
}
}
// otherwise leave it unchanged
return match;
});

if (proxy && defined(this.proxy)) {
url = this.proxy.getURL(url);
}
Expand All @@ -599,21 +601,6 @@ define([
}
};

/**
* Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
* as opposed to adding them one at a time to the queryParameters property. If a value is already set, it will be replaced with the new value.
*
* @param {Object} params The query parameters
* @param {Boolean} [useAsDefault=false] If true the params will be used as the default values, so they will only be set if they are undefined.
*
* @deprecated
*/
Resource.prototype.addQueryParameters = function(params, useAsDefault) {
deprecationWarning('Resource.addQueryParameters', 'addQueryParameters has been deprecated and will be removed 1.45. Use setQueryParameters or appendQueryParameters instead.');

return this.setQueryParameters(params, useAsDefault);
};

/**
* Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
* as opposed to adding them one at a time to the queryParameters property.
Expand All @@ -639,21 +626,6 @@ define([
}
};

/**
* Combines the specified object and the existing template values. This allows you to add many values at once,
* as opposed to adding them one at a time to the templateValues property. If a value is already set, it will become an array and the new value will be appended.
*
* @param {Object} template The template values
* @param {Boolean} [useAsDefault=false] If true the values will be used as the default values, so they will only be set if they are undefined.
*
* @deprecated
*/
Resource.prototype.addTemplateValues = function(template, useAsDefault) {
deprecationWarning('Resource.addTemplateValues', 'addTemplateValues has been deprecated and will be removed 1.45. Use setTemplateValues.');

return this.setTemplateValues(template, useAsDefault);
};

/**
* Returns a resource relative to the current instance. All properties remain the same as the current instance unless overridden in options.
*
Expand Down Expand Up @@ -870,12 +842,13 @@ define([

/**
* Asynchronously loads the given image resource. Returns a promise that will resolve to
* an {@link https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap|ImageBitmap} if the browser supports `createImageBitmap` or otherwise an
* an {@link https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap|ImageBitmap} if <code>preferImageBitmap</code> is true and the browser supports <code>createImageBitmap</code> or otherwise an
* {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement|Image} once loaded, or reject if the image failed to load.
*
* @param {Object} [options] An object with the following properties.
* @param {Boolean} [options.preferBlob=false] If true, we will load the image via a blob.
* @param {Boolean} [options.flipY=true] If true, image will be vertially flipped during decode. Only applies if the browser supports `createImageBitmap`.
* @param {Boolean} [options.preferImageBitmap=false] If true, image will be decoded during fetch and an <code>ImageBitmap</code> is returned.
* @param {Boolean} [options.flipY=false] If true, image will be vertically flipped during decode. Only applies if the browser supports <code>createImageBitmap</code>.
* @returns {Promise.<ImageBitmap>|Promise.<Image>|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if <code>request.throttle</code> is true and the request does not have high enough priority.
*
*
Expand All @@ -897,14 +870,15 @@ define([
*/
Resource.prototype.fetchImage = function (options) {
if (typeof options === 'boolean') {
deprecationWarning('fetchImage-parameter-change', 'fetchImage now takes an options object in CesiumJS 1.56. Use resource.fetchImage({ preferBlob: true }) instead of resource.fetchImage(true).');
deprecationWarning('fetchImage-parameter-change', 'fetchImage now takes an options object in CesiumJS 1.57. Use resource.fetchImage({ preferBlob: true }) instead of resource.fetchImage(true).');
options = {
preferBlob : options
};
}
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
var preferImageBitmap = defaultValue(options.preferImageBitmap, false);
var preferBlob = defaultValue(options.preferBlob, false);
var flipY = defaultValue(options.flipY, true);
var flipY = defaultValue(options.flipY, false);

checkAndResetRequest(this.request);

Expand All @@ -914,7 +888,11 @@ define([
// 3. It's a blob URI
// 4. It doesn't have request headers and we preferBlob is false
if (!xhrBlobSupported || this.isDataUri || this.isBlobUri || (!this.hasHeaders && !preferBlob)) {
return fetchImage(this, flipY);
return fetchImage({
resource: this,
flipY: flipY,
preferImageBitmap: preferImageBitmap
});
}

var blobPromise = this.fetchBlob();
Expand All @@ -923,40 +901,46 @@ define([
}

var supportsImageBitmap;
var useImageBitmap;
var generatedBlobResource;
var generatedBlob;
return Resource.supportsImageBitmapOptions()
.then(function(result) {
supportsImageBitmap = result;
useImageBitmap = supportsImageBitmap && preferImageBitmap;
return blobPromise;
})
.then(function(blob) {
if (!defined(blob)) {
return;
}
if (supportsImageBitmap) {
generatedBlob = blob;
if (useImageBitmap) {
return Resource._Implementations.createImageBitmapFromBlob(blob, flipY);
}
generatedBlob = blob;
var blobUrl = window.URL.createObjectURL(blob);
generatedBlobResource = new Resource({
url: blobUrl
});

return fetchImage(generatedBlobResource, flipY);
return fetchImage({
resource: generatedBlobResource,
flipY: flipY,
preferImageBitmap: false
});
})
.then(function(image) {
if (!defined(image)) {
return;
}
if (supportsImageBitmap) {
return image;
}
window.URL.revokeObjectURL(generatedBlobResource.url);

// This is because the blob object is needed for DiscardMissingTileImagePolicy
// See https://github.com/AnalyticalGraphicsInc/cesium/issues/1353
image.blob = generatedBlob;
if (useImageBitmap) {
return image;
}

window.URL.revokeObjectURL(generatedBlobResource.url);
return image;
})
.otherwise(function(error) {
Expand All @@ -968,7 +952,21 @@ define([
});
};

function fetchImage(resource, flipY) {
/**
* Fetches an image and returns a promise to it.
*
* @param {Object} [options] An object with the following properties.
* @param {Resource} [options.resource] Resource object that points to an image to fetch.
* @param {Boolean} [options.preferImageBitmap] If true, image will be decoded during fetch and an <code>ImageBitmap</code> is returned.
* @param {Boolean} [options.flipY] If true, image will be vertically flipped during decode. Only applies if the browser supports <code>createImageBitmap</code>.
*
* @private
*/
function fetchImage(options) {
var resource = options.resource;
var flipY = options.flipY;
var preferImageBitmap = options.preferImageBitmap;

var request = resource.request;
request.url = resource.url;
request.requestFunction = function() {
Expand All @@ -982,7 +980,7 @@ define([

var deferred = when.defer();

Resource._Implementations.createImage(url, crossOrigin, deferred, flipY);
Resource._Implementations.createImage(url, crossOrigin, deferred, flipY, preferImageBitmap);

return deferred.promise;
};
Expand All @@ -1006,7 +1004,11 @@ define([
request.state = RequestState.UNISSUED;
request.deferred = undefined;

return fetchImage(resource, flipY);
return fetchImage({
resource: resource,
flipY: flipY,
preferImageBitmap: preferImageBitmap
});
}

return when.reject(e);
Expand All @@ -1023,18 +1025,20 @@ define([
* @param {Object} [options.templateValues] Key/Value pairs that are used to replace template values (eg. {x}).
* @param {Object} [options.headers={}] Additional HTTP headers that will be sent.
* @param {DefaultProxy} [options.proxy] A proxy to be used when loading the resource.
* @param {Boolean} [options.flipY = true] Whether to vertically flip the image during fetch and decode. Only applies when requesting an image and the browser supports createImageBitmap.
* @param {Boolean} [options.flipY=false] Whether to vertically flip the image during fetch and decode. Only applies when requesting an image and the browser supports <code>createImageBitmap</code>.
* @param {Resource~RetryCallback} [options.retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
* @param {Number} [options.retryAttempts=0] The number of times the retryCallback should be called before giving up.
* @param {Request} [options.request] A Request object that will be used. Intended for internal use only.
* @param {Boolean} [options.preferBlob = false] If true, we will load the image via a blob.
* @param {Boolean} [options.preferBlob=false] If true, we will load the image via a blob.
* @param {Boolean} [options.preferImageBitmap=false] If true, image will be decoded during fetch and an <code>ImageBitmap</code> is returned.
* @returns {Promise.<ImageBitmap>|Promise.<Image>|undefined} a promise that will resolve to the requested data when loaded. Returns undefined if <code>request.throttle</code> is true and the request does not have high enough priority.
*/
Resource.fetchImage = function (options) {
var resource = new Resource(options);
return resource.fetchImage({
flipY: options.flipY,
preferBlob: options.preferBlob
preferBlob: options.preferBlob,
preferImageBitmap: options.preferImageBitmap
});
};

Expand Down Expand Up @@ -1846,17 +1850,17 @@ define([
image.src = url;
}

Resource._Implementations.createImage = function(url, crossOrigin, deferred, flipY) {
Resource._Implementations.createImage = function(url, crossOrigin, deferred, flipY, preferImageBitmap) {
// Passing an Image to createImageBitmap will force it to run on the main thread
// since DOM elements don't exist on workers. We convert it to a blob so it's non-blocking.
// See:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1044102#c38
// https://bugs.chromium.org/p/chromium/issues/detail?id=580202#c10
Resource.supportsImageBitmapOptions()
.then(function(result) {
.then(function(supportsImageBitmap) {
// We can only use ImageBitmap if we can flip on decode.
// See: https://github.com/AnalyticalGraphicsInc/cesium/pull/7579#issuecomment-466146898
if (!result) {
if (!(supportsImageBitmap && preferImageBitmap)) {
loadImageElement(url, crossOrigin, deferred);
return;
}
Expand All @@ -1883,16 +1887,9 @@ define([
};

Resource._Implementations.createImageBitmapFromBlob = function(blob, flipY) {
return Resource.supportsImageBitmapOptions()
.then(function(result) {
if (!result) {
return createImageBitmap(blob);
}

return createImageBitmap(blob, {
imageOrientation: flipY ? 'flipY' : 'none'
});
});
return createImageBitmap(blob, {
imageOrientation: flipY ? 'flipY' : 'none'
});
};

function decodeResponse(loadWithHttpResponse, responseType) {
Expand Down
Loading

0 comments on commit 4467d23

Please sign in to comment.