diff --git a/packages/engine/Source/Scene/Cesium3DTilesVoxelProvider.js b/packages/engine/Source/Scene/Cesium3DTilesVoxelProvider.js index 5a84f8f9d99c..c319710e159a 100644 --- a/packages/engine/Source/Scene/Cesium3DTilesVoxelProvider.js +++ b/packages/engine/Source/Scene/Cesium3DTilesVoxelProvider.js @@ -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} + * @readonly + * @deprecated + */ readyPromise: { get: function () { deprecationWarning( @@ -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( diff --git a/packages/engine/Source/Scene/Composite3DTileContent.js b/packages/engine/Source/Scene/Composite3DTileContent.js index e61d10e819ac..824b01186956 100644 --- a/packages/engine/Source/Scene/Composite3DTileContent.js +++ b/packages/engine/Source/Scene/Composite3DTileContent.js @@ -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"; @@ -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, { @@ -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} + * @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; @@ -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 () { diff --git a/packages/engine/Source/Scene/Empty3DTileContent.js b/packages/engine/Source/Scene/Empty3DTileContent.js index 13f427b0e02b..b9aa4f82144d 100644 --- a/packages/engine/Source/Scene/Empty3DTileContent.js +++ b/packages/engine/Source/Scene/Empty3DTileContent.js @@ -1,3 +1,4 @@ +import deprecationWarning from "../Core/deprecationWarning.js"; import destroyObject from "../Core/destroyObject.js"; import DeveloperError from "../Core/DeveloperError.js"; @@ -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} + * @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; diff --git a/packages/engine/Source/Scene/Geometry3DTileContent.js b/packages/engine/Source/Scene/Geometry3DTileContent.js index f9ea775d9108..4486ffbb8bf2 100644 --- a/packages/engine/Source/Scene/Geometry3DTileContent.js +++ b/packages/engine/Source/Scene/Geometry3DTileContent.js @@ -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"; @@ -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); } @@ -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} + * @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; @@ -291,7 +328,8 @@ function initialize(content, arrayBuffer, byteOffset) { byteOffset += sizeOfUint32; if (byteLength === 0) { - this._ready = true; + content._ready = true; + content._resolveContent(content); return; } @@ -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); } }; diff --git a/packages/engine/Source/Scene/Implicit3DTileContent.js b/packages/engine/Source/Scene/Implicit3DTileContent.js index 8f93e9dc5de3..7f6a8314afb7 100644 --- a/packages/engine/Source/Scene/Implicit3DTileContent.js +++ b/packages/engine/Source/Scene/Implicit3DTileContent.js @@ -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"; @@ -73,6 +74,7 @@ function Implicit3DTileContent(tileset, tile, resource) { this._url = subtreeResource.getUrlComponent(true); this._ready = false; + this._readyPromise = undefined; } Object.defineProperties(Implicit3DTileContent.prototype, { @@ -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} + * @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; @@ -229,6 +260,8 @@ Implicit3DTileContent.fromSubtreeJson = async function ( content._implicitSubtree = subtree; expandSubtree(content, subtree); content._ready = true; + content._readyPromise = Promise.resolve(content); + return content; }; diff --git a/packages/engine/Source/Scene/Model/Model3DTileContent.js b/packages/engine/Source/Scene/Model/Model3DTileContent.js index 52c51879f4b8..cd222a39c47d 100644 --- a/packages/engine/Source/Scene/Model/Model3DTileContent.js +++ b/packages/engine/Source/Scene/Model/Model3DTileContent.js @@ -2,6 +2,7 @@ import Color from "../../Core/Color.js"; import combine from "../../Core/combine.js"; import defined from "../../Core/defined.js"; import destroyObject from "../../Core/destroyObject.js"; +import deprecationWarning from "../../Core/deprecationWarning.js"; import DeveloperError from "../../Core/DeveloperError.js"; import Pass from "../../Renderer/Pass.js"; import ModelAnimationLoop from "../ModelAnimationLoop.js"; @@ -29,6 +30,9 @@ function Model3DTileContent(tileset, tile, resource) { this._metadata = undefined; this._group = undefined; this._ready = false; + + this._resolveContent = undefined; + this._readyPromise = undefined; } Object.defineProperties(Model3DTileContent.prototype, { @@ -85,12 +89,41 @@ Object.defineProperties(Model3DTileContent.prototype, { }, }, + /** + * Returns true when the tile's content is ready to render; otherwise false + * + * @memberof Model3DTileContent.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 Model3DTileContent.prototype + * + * @type {Promise} + * @readonly + * @deprecated + * @private + */ + readyPromise: { + get: function () { + deprecationWarning( + "Model3DTileContent.readyPromise", + "Model3DTileContent.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Wait for Model3DTileContent.ready to return true instead." + ); + return this._readyPromise; + }, + }, + tileset: { get: function () { return this._tileset; @@ -254,6 +287,7 @@ Model3DTileContent.prototype.update = function (tileset, frameState) { }); this._ready = true; + this._resolveContent = this._resolveContent && this._resolveContent(this); } }; @@ -290,6 +324,11 @@ Model3DTileContent.fromGltf = async function (tileset, tile, resource, gltf) { const model = await Model.fromGltfAsync(modelOptions); content._model = model; + // This is for backwards compatibility. It can be removed once readyPromise is removed. + content._readyPromise = new Promise((resolve) => { + content._resolveContent = resolve; + }); + return content; }; @@ -324,6 +363,11 @@ Model3DTileContent.fromB3dm = async function ( const model = await Model.fromB3dm(modelOptions); content._model = model; + // This is for backwards compatibility. It can be removed once readyPromise is removed. + content._readyPromise = new Promise((resolve) => { + content._resolveContent = resolve; + }); + return content; }; @@ -352,6 +396,11 @@ Model3DTileContent.fromI3dm = async function ( const model = await Model.fromI3dm(modelOptions); content._model = model; + // This is for backwards compatibility. It can be removed once readyPromise is removed. + content._readyPromise = new Promise((resolve) => { + content._resolveContent = resolve; + }); + return content; }; @@ -379,6 +428,11 @@ Model3DTileContent.fromPnts = async function ( const model = await Model.fromPnts(modelOptions); content._model = model; + // This is for backwards compatibility. It can be removed once readyPromise is removed. + content._readyPromise = new Promise((resolve) => { + content._resolveContent = resolve; + }); + return content; }; @@ -404,6 +458,11 @@ Model3DTileContent.fromGeoJson = async function ( const model = await Model.fromGeoJson(modelOptions); content._model = model; + // This is for backwards compatibility. It can be removed once readyPromise is removed. + content._readyPromise = new Promise((resolve) => { + content._resolveContent = resolve; + }); + return content; }; diff --git a/packages/engine/Source/Scene/Multiple3DTileContent.js b/packages/engine/Source/Scene/Multiple3DTileContent.js index 65578e434449..10de75a5c2ff 100644 --- a/packages/engine/Source/Scene/Multiple3DTileContent.js +++ b/packages/engine/Source/Scene/Multiple3DTileContent.js @@ -1,4 +1,5 @@ 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 Request from "../Core/Request.js"; @@ -56,6 +57,11 @@ function Multiple3DTileContent(tileset, tile, tilesetResource, contentsJson) { this._requests = new Array(contentCount); this._ready = false; + this._resolveContent = undefined; + this._readyPromise = new Promise((resolve) => { + this._resolveContent = resolve; + }); + this._innerContentResources = new Array(contentCount); this._serverKeys = new Array(contentCount); @@ -211,6 +217,15 @@ Object.defineProperties(Multiple3DTileContent.prototype, { }, }, + /** + * Returns true when the tile's content is ready to render; otherwise false + * + * @memberof Multiple3DTileContent.prototype + * + * @type {boolean} + * @readonly + * @private + */ ready: { get: function () { if (!this._contentsCreated) { @@ -221,6 +236,26 @@ Object.defineProperties(Multiple3DTileContent.prototype, { }, }, + /** + * Gets the promise that will be resolved when the tile's content is ready to render. + * + * @memberof Multiple3DTileContent.prototype + * + * @type {Promise} + * @readonly + * @deprecated + * @private + */ + readyPromise: { + get: function () { + deprecationWarning( + "Multiple3DTileContent.readyPromise", + "Multiple3DTileContent.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Wait for Multiple3DTileContent.ready to return true instead." + ); + return this._readyPromise; + }, + }, + tileset: { get: function () { return this._tileset; @@ -636,7 +671,10 @@ Multiple3DTileContent.prototype.update = function (tileset, frameState) { ready = ready && contents[i].ready; } - this._ready = ready; + if (!this._ready && ready) { + this._ready = true; + this._resolveContent(this); + } }; Multiple3DTileContent.prototype.isDestroyed = function () { diff --git a/packages/engine/Source/Scene/Tileset3DTileContent.js b/packages/engine/Source/Scene/Tileset3DTileContent.js index 9d5ba1172c9a..34559190b62c 100644 --- a/packages/engine/Source/Scene/Tileset3DTileContent.js +++ b/packages/engine/Source/Scene/Tileset3DTileContent.js @@ -1,4 +1,5 @@ import destroyObject from "../Core/destroyObject.js"; +import deprecationWarning from "../Core/deprecationWarning.js"; /** * Represents content for a tile in a @@ -24,6 +25,7 @@ function Tileset3DTileContent(tileset, tile, resource) { this._group = undefined; this._ready = false; + this._readyPromise = Promise.resolve(this); } Object.defineProperties(Tileset3DTileContent.prototype, { @@ -69,12 +71,41 @@ Object.defineProperties(Tileset3DTileContent.prototype, { }, }, + /** + * Returns true when the tile's content is ready to render; otherwise false + * + * @memberof Tileset3DTileContent.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 Tileset3DTileContent.prototype + * + * @type {Promise} + * @readonly + * @deprecated + * @private + */ + readyPromise: { + get: function () { + deprecationWarning( + "Tileset3DTileContent.readyPromise", + "Tileset3DTileContent.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Wait for Tileset3DTileContent.ready to return true instead." + ); + return this._readyPromise; + }, + }, + tileset: { get: function () { return this._tileset; @@ -130,6 +161,7 @@ Tileset3DTileContent.fromJson = function (tileset, tile, resource, json) { const content = new Tileset3DTileContent(tileset, tile, resource); content._tileset.loadTileset(content._resource, json, content._tile); content._ready = true; + return content; }; diff --git a/packages/engine/Source/Scene/Vector3DTileContent.js b/packages/engine/Source/Scene/Vector3DTileContent.js index 396e1a9e52fb..565e8839aaa3 100644 --- a/packages/engine/Source/Scene/Vector3DTileContent.js +++ b/packages/engine/Source/Scene/Vector3DTileContent.js @@ -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 Ellipsoid from "../Core/Ellipsoid.js"; @@ -52,6 +53,13 @@ function Vector3DTileContent(tileset, tile, resource, arrayBuffer, byteOffset) { this._group = undefined; this._ready = false; + + // This is here for backwards compatibility and can be removed when readyPromise is removed. + this._resolveContent = undefined; + this._readyPromise = new Promise((resolve) => { + this._resolveContent = resolve; + }); + initialize(this, arrayBuffer, byteOffset); } @@ -120,12 +128,41 @@ Object.defineProperties(Vector3DTileContent.prototype, { }, }, + /** + * Returns true when the tile's content is ready to render; otherwise false + * + * @memberof Vector3DTileContent.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 Vector3DTileContent.prototype + * + * @type {Promise} + * @readonly + * @deprecated + * @private + */ + readyPromise: { + get: function () { + deprecationWarning( + "Vector3DTileContent.readyPromise", + "Vector3DTileContent.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Wait for Vector3DTileContent.ready to return true instead." + ); + return this._readyPromise; + }, + }, + tileset: { get: function () { return this._tileset; @@ -298,6 +335,7 @@ function initialize(content, arrayBuffer, byteOffset) { if (byteLength === 0) { content._ready = true; + content._resolveContent(content); return; } @@ -714,6 +752,7 @@ Vector3DTileContent.prototype.update = function (tileset, frameState) { } this._batchTable.update(tileset, frameState); this._ready = true; + this._resolveContent(this); } }; diff --git a/packages/engine/Source/Scene/Vector3DTileGeometry.js b/packages/engine/Source/Scene/Vector3DTileGeometry.js index 39ce487b1fc1..c6e4c7688079 100644 --- a/packages/engine/Source/Scene/Vector3DTileGeometry.js +++ b/packages/engine/Source/Scene/Vector3DTileGeometry.js @@ -108,6 +108,7 @@ Object.defineProperties(Vector3DTileGeometry.prototype, { * * @type {number} * @readonly + * @private */ trianglesLength: { get: function () { @@ -125,6 +126,7 @@ Object.defineProperties(Vector3DTileGeometry.prototype, { * * @type {number} * @readonly + * @private */ geometryByteLength: { get: function () { @@ -140,6 +142,7 @@ Object.defineProperties(Vector3DTileGeometry.prototype, { * @memberof Vector3DTileGeometry.prototype * @type {boolean} * @readonly + * @private */ ready: { get: function () { diff --git a/packages/engine/Source/Scene/Vector3DTilePoints.js b/packages/engine/Source/Scene/Vector3DTilePoints.js index 42c65633d7f9..f66fc7901a01 100644 --- a/packages/engine/Source/Scene/Vector3DTilePoints.js +++ b/packages/engine/Source/Scene/Vector3DTilePoints.js @@ -67,6 +67,7 @@ Object.defineProperties(Vector3DTilePoints.prototype, { * * @type {boolean} * @readonly + * @private */ ready: { get: function () { @@ -81,6 +82,7 @@ Object.defineProperties(Vector3DTilePoints.prototype, { * * @type {number} * @readonly + * @private */ pointsLength: { get: function () { @@ -95,6 +97,7 @@ Object.defineProperties(Vector3DTilePoints.prototype, { * * @type {number} * @readonly + * @private */ texturesByteLength: { get: function () { diff --git a/packages/engine/Source/Scene/Vector3DTilePolygons.js b/packages/engine/Source/Scene/Vector3DTilePolygons.js index dfc26848fe2b..06a6d3de907e 100644 --- a/packages/engine/Source/Scene/Vector3DTilePolygons.js +++ b/packages/engine/Source/Scene/Vector3DTilePolygons.js @@ -108,6 +108,7 @@ Object.defineProperties(Vector3DTilePolygons.prototype, { * * @type {number} * @readonly + * @private */ trianglesLength: { get: function () { @@ -125,6 +126,7 @@ Object.defineProperties(Vector3DTilePolygons.prototype, { * * @type {number} * @readonly + * @private */ geometryByteLength: { get: function () { @@ -140,6 +142,7 @@ Object.defineProperties(Vector3DTilePolygons.prototype, { * @memberof Vector3DTilePolygons.prototype * @type {boolean} * @readonly + * @private */ ready: { get: function () { diff --git a/packages/engine/Source/Scene/Vector3DTilePolylines.js b/packages/engine/Source/Scene/Vector3DTilePolylines.js index 70baacb6d69c..781f568b5118 100644 --- a/packages/engine/Source/Scene/Vector3DTilePolylines.js +++ b/packages/engine/Source/Scene/Vector3DTilePolylines.js @@ -99,6 +99,7 @@ Object.defineProperties(Vector3DTilePolylines.prototype, { * * @type {number} * @readonly + * @private */ trianglesLength: { get: function () { @@ -113,6 +114,7 @@ Object.defineProperties(Vector3DTilePolylines.prototype, { * * @type {number} * @readonly + * @private */ geometryByteLength: { get: function () { @@ -125,6 +127,7 @@ Object.defineProperties(Vector3DTilePolylines.prototype, { * @memberof Vector3DTilePolylines.prototype * @type {boolean} * @readonly + * @private */ ready: { get: function () {