Skip to content

Commit

Permalink
Merge pull request #10607 from CesiumGS/primitive-ready
Browse files Browse the repository at this point in the history
Fix bug where dynamic geometry was not marked as ready
  • Loading branch information
sanjeetsuhag authored Jul 28, 2022
2 parents 098ac6c + 34512c3 commit af7ba8c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
11 changes: 10 additions & 1 deletion Source/Scene/ClassificationPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1297,7 +1301,6 @@ ClassificationPrimitive.prototype.update = function (frameState) {
}

this._primitive = new Primitive(primitiveOptions);
this._primitive.readyPromise.then(this._completeLoad);
}

if (
Expand Down Expand Up @@ -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();
}
});
};

/**
Expand Down
11 changes: 10 additions & 1 deletion Source/Scene/GroundPrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -921,14 +925,19 @@ GroundPrimitive.prototype.update = function (frameState) {
};

this._primitive = new ClassificationPrimitive(primitiveOptions);
this._primitive.readyPromise.then(this._completeLoad);
}

this._primitive.appearance = this.appearance;
this._primitive.show = this.show;
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();
}
});
};

/**
Expand Down

0 comments on commit af7ba8c

Please sign in to comment.