Skip to content

Commit

Permalink
Deprecation & documentation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ggetz committed Mar 28, 2023
1 parent dee5f0d commit 76defba
Show file tree
Hide file tree
Showing 13 changed files with 340 additions and 5 deletions.
19 changes: 17 additions & 2 deletions packages/engine/Source/Scene/Cesium3DTilesVoxelProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,14 @@ function Cesium3DTilesVoxelProvider(options) {
}

Object.defineProperties(Cesium3DTilesVoxelProvider.prototype, {
/** @inheritdoc */
/**
* Gets the promise that will be resolved when the provider is ready for use.
*
* @memberof Cesium3DTilesVoxelProvider.prototype
* @type {Promise<Cesium3DTilesVoxelProvider>}
* @readonly
* @deprecated
*/
readyPromise: {
get: function () {
deprecationWarning(
Expand All @@ -186,7 +193,15 @@ Object.defineProperties(Cesium3DTilesVoxelProvider.prototype, {
return this._readyPromise;
},
},
/** @inheritdoc */

/**
* Gets a value indicating whether or not the provider is ready for use.
*
* @memberof Cesium3DTilesVoxelProvider.prototype
* @type {boolean}
* @readonly
* @deprecated
*/
ready: {
get: function () {
deprecationWarning(
Expand Down
40 changes: 39 additions & 1 deletion packages/engine/Source/Scene/Composite3DTileContent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import deprecationWarning from "../Core/deprecationWarning.js";
import destroyObject from "../Core/destroyObject.js";
import getMagic from "../Core/getMagic.js";
import RuntimeError from "../Core/RuntimeError.js";
Expand Down Expand Up @@ -30,6 +31,11 @@ function Composite3DTileContent(tileset, tile, resource, contents) {
this._metadata = undefined;
this._group = undefined;
this._ready = false;

this._resolveContent = undefined;
this._readyPromise = new Promise((resolve) => {
this._resolveContent = resolve;
});
}

Object.defineProperties(Composite3DTileContent.prototype, {
Expand Down Expand Up @@ -126,12 +132,41 @@ Object.defineProperties(Composite3DTileContent.prototype, {
},
},

/**
* Returns true when the tile's content is ready to render; otherwise false
*
* @memberof Composite3DTileContent.prototype
*
* @type {boolean}
* @readonly
* @private
*/
ready: {
get: function () {
return this._ready;
},
},

/**
* Gets the promise that will be resolved when the tile's content is ready to render.
*
* @memberof Composite3DTileContent.prototype
*
* @type {Promise<Composite3DTileContent>}
* @readonly
* @deprecated
* @private
*/
readyPromise: {
get: function () {
deprecationWarning(
"Composite3DTileContent.readyPromise",
"Composite3DTileContent.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Wait for Composite3DTileContent.ready to return true instead."
);
return this._readyPromise;
},
},

tileset: {
get: function () {
return this._tileset;
Expand Down Expand Up @@ -333,7 +368,10 @@ Composite3DTileContent.prototype.update = function (tileset, frameState) {
ready = ready && contents[i].ready;
}

this._ready = ready;
if (!this._ready && ready) {
this._ready = true;
this._resolveContent(this);
}
};

Composite3DTileContent.prototype.isDestroyed = function () {
Expand Down
30 changes: 30 additions & 0 deletions packages/engine/Source/Scene/Empty3DTileContent.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import deprecationWarning from "../Core/deprecationWarning.js";
import destroyObject from "../Core/destroyObject.js";
import DeveloperError from "../Core/DeveloperError.js";

Expand Down Expand Up @@ -64,12 +65,41 @@ Object.defineProperties(Empty3DTileContent.prototype, {
},
},

/**
* Returns true when the tile's content is ready to render; otherwise false
*
* @memberof Empty3DTileContent.prototype
*
* @type {boolean}
* @readonly
* @private
*/
ready: {
get: function () {
return true;
},
},

/**
* Gets the promise that will be resolved when the tile's content is ready to render.
*
* @memberof Empty3DTileContent.prototype
*
* @type {Promise<Empty3DTileContent>}
* @readonly
* @deprecated
* @private
*/
readyPromise: {
get: function () {
deprecationWarning(
"Empty3DTileContent.readyPromise",
"Empty3DTileContent.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Wait for Empty3DTileContent.ready to return true instead."
);
return Promise.resolve(this);
},
},

tileset: {
get: function () {
return this._tileset;
Expand Down
41 changes: 40 additions & 1 deletion packages/engine/Source/Scene/Geometry3DTileContent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Cartesian3 from "../Core/Cartesian3.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import deprecationWarning from "../Core/deprecationWarning.js";
import destroyObject from "../Core/destroyObject.js";
import DeveloperError from "../Core/DeveloperError.js";
import getJsonFromTypedArray from "../Core/getJsonFromTypedArray.js";
Expand Down Expand Up @@ -43,6 +44,13 @@ function Geometry3DTileContent(
this._group = undefined;

this._ready = false;

// This is for backwards compatibility. It can be removed once readyPromise is removed.
this._resolveContent = undefined;
this._readyPromise = new Promise((resolve) => {
this._resolveContent = resolve;
});

initialize(this, arrayBuffer, byteOffset);
}

Expand Down Expand Up @@ -97,12 +105,41 @@ Object.defineProperties(Geometry3DTileContent.prototype, {
},
},

/**
* Returns true when the tile's content is ready to render; otherwise false
*
* @memberof Geometry3DTileContent.prototype
*
* @type {boolean}
* @readonly
* @private
*/
ready: {
get: function () {
return this._ready;
},
},

/**
* Gets the promise that will be resolved when the tile's content is ready to render.
*
* @memberof Geometry3DTileContent.prototype
*
* @type {Promise<Geometry3DTileContent>}
* @readonly
* @deprecated
* @private
*/
readyPromise: {
get: function () {
deprecationWarning(
"Geometry3DTileContent.readyPromise",
"Geometry3DTileContent.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Wait for Geometry3DTileContent.ready to return true instead."
);
return this._readyPromise;
},
},

tileset: {
get: function () {
return this._tileset;
Expand Down Expand Up @@ -291,7 +328,8 @@ function initialize(content, arrayBuffer, byteOffset) {
byteOffset += sizeOfUint32;

if (byteLength === 0) {
this._ready = true;
content._ready = true;
content._resolveContent(content);
return;
}

Expand Down Expand Up @@ -512,6 +550,7 @@ Geometry3DTileContent.prototype.update = function (tileset, frameState) {
if (defined(this._batchTable) && this._geometries.ready) {
this._batchTable.update(tileset, frameState);
this._ready = true;
this._resolveContent(this);
}
};

Expand Down
33 changes: 33 additions & 0 deletions packages/engine/Source/Scene/Implicit3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import clone from "../Core/clone.js";
import combine from "../Core/combine.js";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import deprecationWarning from "../Core/deprecationWarning.js";
import destroyObject from "../Core/destroyObject.js";
import DeveloperError from "../Core/DeveloperError.js";
import CesiumMath from "../Core/Math.js";
Expand Down Expand Up @@ -73,6 +74,7 @@ function Implicit3DTileContent(tileset, tile, resource) {
this._url = subtreeResource.getUrlComponent(true);

this._ready = false;
this._readyPromise = undefined;
}

Object.defineProperties(Implicit3DTileContent.prototype, {
Expand Down Expand Up @@ -118,12 +120,41 @@ Object.defineProperties(Implicit3DTileContent.prototype, {
},
},

/**
* Returns true when the tile's content is ready to render; otherwise false
*
* @memberof Implicit3DTileContent.prototype
*
* @type {boolean}
* @readonly
* @private
*/
ready: {
get: function () {
return this._ready;
},
},

/**
* Gets the promise that will be resolved when the tile's content is ready to render.
*
* @memberof Implicit3DTileContent.prototype
*
* @type {Promise<Implicit3DTileContent>}
* @readonly
* @deprecated
* @private
*/
readyPromise: {
get: function () {
deprecationWarning(
"Implicit3DTileContent.readyPromise",
"Implicit3DTileContent.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Wait for Implicit3DTileContent.ready to return true instead."
);
return this._readyPromise;
},
},

tileset: {
get: function () {
return this._tileset;
Expand Down Expand Up @@ -229,6 +260,8 @@ Implicit3DTileContent.fromSubtreeJson = async function (
content._implicitSubtree = subtree;
expandSubtree(content, subtree);
content._ready = true;
content._readyPromise = Promise.resolve(content);

return content;
};

Expand Down
Loading

0 comments on commit 76defba

Please sign in to comment.