From 018fef4f6184b3fc6887382ebc07bcebeaaf64eb Mon Sep 17 00:00:00 2001 From: hpinkos Date: Fri, 11 Oct 2019 16:12:52 -0400 Subject: [PATCH 1/3] fix dynamic partial ellipsoids --- .../DataSources/EllipsoidGeometryUpdater.js | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/Source/DataSources/EllipsoidGeometryUpdater.js b/Source/DataSources/EllipsoidGeometryUpdater.js index e6d9331a5111..f50938fd4443 100644 --- a/Source/DataSources/EllipsoidGeometryUpdater.js +++ b/Source/DataSources/EllipsoidGeometryUpdater.js @@ -32,6 +32,7 @@ import Property from './Property.js'; var offsetScratch = new Cartesian3(); var radiiScratch = new Cartesian3(); + var innerRadiiScratch = new Cartesian3(); var scratchColor = new Color(); var unitSphere = new Cartesian3(1, 1, 1); @@ -39,7 +40,7 @@ import Property from './Property.js'; this.id = entity; this.vertexFormat = undefined; this.radii = undefined; - this.innerRadii = undefined; + this.innerRadii = undefined; this.minimumClock = undefined; this.maximumClock = undefined; this.minimumCone = undefined; @@ -194,9 +195,14 @@ import Property from './Property.js'; return !entity.position.isConstant || // !Property.isConstant(entity.orientation) || // !ellipsoid.radii.isConstant || // + !Property.isConstant(ellipsoid.innerRadii) || // !Property.isConstant(ellipsoid.stackPartitions) || // !Property.isConstant(ellipsoid.slicePartitions) || // !Property.isConstant(ellipsoid.outlineWidth) || // + !Property.isConstant(ellipsoid.minimumClock) || // + !Property.isConstant(ellipsoid.maximumClock) || // + !Property.isConstant(ellipsoid.minimumCone) || // + !Property.isConstant(ellipsoid.maximumCone) || // !Property.isConstant(ellipsoid.subdivisions); }; @@ -282,6 +288,11 @@ import Property from './Property.js'; var material = MaterialProperty.getValue(time, defaultValue(ellipsoid.material, defaultMaterial), this._material); // Check properties that could trigger a primitive rebuild. + var innerRadii = Property.getValueOrUndefined(ellipsoid.innerRadii, time, innerRadiiScratch); + var minimumClock = Property.getValueOrUndefined(ellipsoid.minimumClock, time); + var maximumClock = Property.getValueOrUndefined(ellipsoid.maximumClock, time); + var minimumCone = Property.getValueOrUndefined(ellipsoid.minimumCone, time); + var maximumCone = Property.getValueOrUndefined(ellipsoid.maximumCone, time); var stackPartitions = Property.getValueOrUndefined(ellipsoid.stackPartitions, time); var slicePartitions = Property.getValueOrUndefined(ellipsoid.slicePartitions, time); var subdivisions = Property.getValueOrUndefined(ellipsoid.subdivisions, time); @@ -307,7 +318,10 @@ import Property from './Property.js'; //For the radii, we use unit sphere and then deform it with a scale matrix. var rebuildPrimitives = !in3D || this._lastSceneMode !== sceneMode || !defined(this._primitive) || // options.stackPartitions !== stackPartitions || options.slicePartitions !== slicePartitions || // - options.subdivisions !== subdivisions || this._lastOutlineWidth !== outlineWidth || options.offsetAttribute !== offsetAttribute; + defined(innerRadii) && !Cartesian3.equals(options.innerRadii !== innerRadii) || options.minimumClock !== minimumClock || // + options.maximumClock !== maximumClock || options.minimumCone !== minimumCone || // + options.maximumCone !== maximumCone || options.subdivisions !== subdivisions || // + this._lastOutlineWidth !== outlineWidth || options.offsetAttribute !== offsetAttribute; if (rebuildPrimitives) { var primitives = this._primitives; @@ -322,19 +336,21 @@ import Property from './Property.js'; options.slicePartitions = slicePartitions; options.subdivisions = subdivisions; options.offsetAttribute = offsetAttribute; - options.radii = in3D ? unitSphere : radii; - var innerRadii = Property.getValueOrDefault(ellipsoid.innerRadii, time, radii, new Cartesian3()); - if (in3D) { - var mag = Cartesian3.magnitude(radii); - var innerRadiiUnit = new Cartesian3(innerRadii.x/mag, innerRadii.y/mag, innerRadii.z/mag); - options.innerRadii = innerRadiiUnit; + options.radii = Cartesian3.clone(in3D ? unitSphere : radii, options.radii); + if (defined(innerRadii)) { + if (in3D) { + var mag = Cartesian3.magnitude(radii); + options.innerRadii = Cartesian3.fromElements(innerRadii.x/mag, innerRadii.y/mag, innerRadii.z/mag, options.innerRadii); + } else { + options.innerRadii = Cartesian3.clone(innerRadii, options.innerRadii); + } } else { - options.innerRadii = innerRadii; + options.innerRadii = undefined; } - options.minimumClock = Property.getValueOrUndefined(ellipsoid.minimumClock, time); - options.maximumClock = Property.getValueOrUndefined(ellipsoid.maximumClock, time); - options.minimumCone = Property.getValueOrUndefined(ellipsoid.minimumCone, time); - options.maximumCone = Property.getValueOrUndefined(ellipsoid.maximumCone, time); + options.minimumClock = minimumClock; + options.maximumClock = maximumClock; + options.minimumCone = minimumCone; + options.maximumCone = maximumCone; var appearance = new MaterialAppearance({ material : material, From 17e89ef2e8c0d13fa501f423969368ff44ef090d Mon Sep 17 00:00:00 2001 From: hpinkos Date: Fri, 11 Oct 2019 16:19:11 -0400 Subject: [PATCH 2/3] CHANGEs and specs --- CHANGES.md | 5 ++ .../EllipsoidGeometryUpdaterSpec.js | 50 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index b3f859d8b2a2..8d068b31228c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,11 @@ Change Log ========== +### 1.63 - 2019-11-01 + +##### Fixes :wrench: +* Fix dynamic ellipsoids using `innerRadii`, `minimumClock`, `maximumClock`, `minimumCone` or `maximumCone`. [#8277](https://github.com/AnalyticalGraphicsInc/cesium/pull/8277) + ### 1.62 - 2019-10-01 ##### Deprecated :hourglass_flowing_sand: diff --git a/Specs/DataSources/EllipsoidGeometryUpdaterSpec.js b/Specs/DataSources/EllipsoidGeometryUpdaterSpec.js index c2cefe767fb6..5415978e98c3 100644 --- a/Specs/DataSources/EllipsoidGeometryUpdaterSpec.js +++ b/Specs/DataSources/EllipsoidGeometryUpdaterSpec.js @@ -111,6 +111,56 @@ describe('DataSources/EllipsoidGeometryUpdater', function() { expect(updater.isDynamic).toBe(true); }); + it('A time-varying innerRadii causes geometry to be dynamic', function() { + var entity = createBasicEllipsoid(); + var updater = new EllipsoidGeometryUpdater(entity, scene); + entity.ellipsoid.innerRadii = new SampledProperty(Cartesian3); + entity.ellipsoid.innerRadii.addSample(time, new Cartesian3(1, 2, 3)); + updater._onEntityPropertyChanged(entity, 'ellipsoid'); + + expect(updater.isDynamic).toBe(true); + }); + + it('A time-varying minimumClock causes geometry to be dynamic', function() { + var entity = createBasicEllipsoid(); + var updater = new EllipsoidGeometryUpdater(entity, scene); + entity.ellipsoid.minimumClock = new SampledProperty(Number); + entity.ellipsoid.minimumClock.addSample(time, 1); + updater._onEntityPropertyChanged(entity, 'ellipsoid'); + + expect(updater.isDynamic).toBe(true); + }); + + it('A time-varying maximumClock causes geometry to be dynamic', function() { + var entity = createBasicEllipsoid(); + var updater = new EllipsoidGeometryUpdater(entity, scene); + entity.ellipsoid.maximumClock = new SampledProperty(Number); + entity.ellipsoid.maximumClock.addSample(time, 1); + updater._onEntityPropertyChanged(entity, 'ellipsoid'); + + expect(updater.isDynamic).toBe(true); + }); + + it('A time-varying minimumCone causes geometry to be dynamic', function() { + var entity = createBasicEllipsoid(); + var updater = new EllipsoidGeometryUpdater(entity, scene); + entity.ellipsoid.minimumCone = new SampledProperty(Number); + entity.ellipsoid.minimumCone.addSample(time, 1); + updater._onEntityPropertyChanged(entity, 'ellipsoid'); + + expect(updater.isDynamic).toBe(true); + }); + + it('A time-varying maximumCone causes geometry to be dynamic', function() { + var entity = createBasicEllipsoid(); + var updater = new EllipsoidGeometryUpdater(entity, scene); + entity.ellipsoid.maximumCone = new SampledProperty(Number); + entity.ellipsoid.maximumCone.addSample(time, 1); + updater._onEntityPropertyChanged(entity, 'ellipsoid'); + + expect(updater.isDynamic).toBe(true); + }); + it('Creates geometry with expected properties', function() { var options = { radii : new Cartesian3(1, 2, 3), From 1215862f04cca3f44957706ecff7fce669f42c0a Mon Sep 17 00:00:00 2001 From: hpinkos Date: Mon, 14 Oct 2019 10:21:13 -0400 Subject: [PATCH 3/3] fix whitespace --- Source/DataSources/EllipsoidGeometryUpdater.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/DataSources/EllipsoidGeometryUpdater.js b/Source/DataSources/EllipsoidGeometryUpdater.js index f50938fd4443..ffcad0a2fece 100644 --- a/Source/DataSources/EllipsoidGeometryUpdater.js +++ b/Source/DataSources/EllipsoidGeometryUpdater.js @@ -40,7 +40,7 @@ import Property from './Property.js'; this.id = entity; this.vertexFormat = undefined; this.radii = undefined; - this.innerRadii = undefined; + this.innerRadii = undefined; this.minimumClock = undefined; this.maximumClock = undefined; this.minimumCone = undefined; @@ -84,8 +84,8 @@ import Property from './Property.js'; * @memberof EllipsoidGeometryUpdater.prototype * @readonly */ - terrainOffsetProperty: { - get: function() { + terrainOffsetProperty : { + get : function() { return this._terrainOffsetProperty; } } @@ -118,7 +118,7 @@ import Property from './Property.js'; show : show, distanceDisplayCondition : distanceDisplayConditionAttribute, color : undefined, - offset: undefined + offset : undefined }; if (this._materialProperty instanceof ColorMaterialProperty) { @@ -340,7 +340,7 @@ import Property from './Property.js'; if (defined(innerRadii)) { if (in3D) { var mag = Cartesian3.magnitude(radii); - options.innerRadii = Cartesian3.fromElements(innerRadii.x/mag, innerRadii.y/mag, innerRadii.z/mag, options.innerRadii); + options.innerRadii = Cartesian3.fromElements(innerRadii.x / mag, innerRadii.y / mag, innerRadii.z / mag, options.innerRadii); } else { options.innerRadii = Cartesian3.clone(innerRadii, options.innerRadii); } @@ -431,7 +431,7 @@ import Property from './Property.js'; if (!Cartesian3.equals(offset, this._lastOffset)) { attributes.offset = OffsetGeometryInstanceAttribute.toValue(offset, attributes.offset); - outlineAttributes.offset = OffsetGeometryInstanceAttribute.toValue(offset, attributes.offset); + outlineAttributes.offset = OffsetGeometryInstanceAttribute.toValue(offset, attributes.offset); Cartesian3.clone(offset, this._lastOffset); } }