From 34512c3003eddf14393cd6cfa64ac5659d797020 Mon Sep 17 00:00:00 2001 From: Gabby Getz Date: Thu, 28 Jul 2022 12:40:48 -0400 Subject: [PATCH] Fix bug where dynamic geometry was not marked as ready --- CHANGES.md | 1 + Source/Scene/ClassificationPrimitive.js | 11 ++++++++++- Source/Scene/GroundPrimitive.js | 11 ++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5435815f101d..6cd1f407b09c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -35,6 +35,7 @@ - Fixed a bug where `Viewer.zoomTo` would continuously throw errors if a `Cesium3DTileset` failed to load.[#10523](https://github.com/CesiumGS/cesium/pull/10523) - Fixed a bug where styles would not apply to tilesets if they were applied while the tileset was hidden. [#10582](https://github.com/CesiumGS/cesium/pull/10582) - Fixed a bug where `.i3dm` models with quantized positions were not being correctly loaded by `ModelExperimental`. [#10598](https://github.com/CesiumGS/cesium/pull/10598) +- Fixed a bug where dynamic geometry was not marked as `ready`. [#10517](https://github.com/CesiumGS/cesium/issues/10517) ##### Deprecated :hourglass_flowing_sand: diff --git a/Source/Scene/ClassificationPrimitive.js b/Source/Scene/ClassificationPrimitive.js index 1390da0ba127..c68c7c4182b4 100644 --- a/Source/Scene/ClassificationPrimitive.js +++ b/Source/Scene/ClassificationPrimitive.js @@ -166,6 +166,10 @@ function ClassificationPrimitive(options) { const classificationPrimitive = this; this._readyPromise = new Promise((resolve, reject) => { classificationPrimitive._completeLoad = () => { + if (this._ready) { + return; + } + this._ready = true; if (this.releaseGeometryInstances) { @@ -1297,7 +1301,6 @@ ClassificationPrimitive.prototype.update = function (frameState) { } this._primitive = new Primitive(primitiveOptions); - this._primitive.readyPromise.then(this._completeLoad); } if ( @@ -1351,6 +1354,12 @@ ClassificationPrimitive.prototype.update = function (frameState) { this._primitive.show = this.show; this._primitive.debugShowBoundingVolume = this.debugShowBoundingVolume; this._primitive.update(frameState); + + frameState.afterRender.push(() => { + if (defined(this._primitive) && this._primitive.ready) { + this._completeLoad(); + } + }); }; /** diff --git a/Source/Scene/GroundPrimitive.js b/Source/Scene/GroundPrimitive.js index 660c8213df6c..61446947227d 100644 --- a/Source/Scene/GroundPrimitive.js +++ b/Source/Scene/GroundPrimitive.js @@ -215,6 +215,10 @@ function GroundPrimitive(options) { const groundPrimitive = this; this._readyPromise = new Promise((resolve, reject) => { groundPrimitive._completeLoad = () => { + if (this._ready) { + return; + } + this._ready = true; if (this.releaseGeometryInstances) { @@ -921,7 +925,6 @@ GroundPrimitive.prototype.update = function (frameState) { }; this._primitive = new ClassificationPrimitive(primitiveOptions); - this._primitive.readyPromise.then(this._completeLoad); } this._primitive.appearance = this.appearance; @@ -929,6 +932,12 @@ GroundPrimitive.prototype.update = function (frameState) { this._primitive.debugShowShadowVolume = this.debugShowShadowVolume; this._primitive.debugShowBoundingVolume = this.debugShowBoundingVolume; this._primitive.update(frameState); + + frameState.afterRender.push(() => { + if (defined(this._primitive) && this._primitive.ready) { + this._completeLoad(); + } + }); }; /**