From 379362d5445d2f999eb72600eb2f9d276fbcd563 Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Fri, 9 Aug 2024 10:29:28 -0400 Subject: [PATCH 01/12] allow models to participate in scene vertical exaggeration or not --- .husky/pre-commit | 4 --- .../Source/DataSources/ModelGraphics.js | 17 ++++++++++ .../Source/DataSources/ModelVisualizer.js | 8 +++++ packages/engine/Source/Scene/Model/Model.js | 34 +++++++++++++++++-- .../engine/Specs/Scene/Model/ModelSpec.js | 2 ++ 5 files changed, 59 insertions(+), 6 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index c37466e2b30..e69de29bb2d 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx lint-staged \ No newline at end of file diff --git a/packages/engine/Source/DataSources/ModelGraphics.js b/packages/engine/Source/DataSources/ModelGraphics.js index 2c4f3379246..fd9689aabbe 100644 --- a/packages/engine/Source/DataSources/ModelGraphics.js +++ b/packages/engine/Source/DataSources/ModelGraphics.js @@ -26,6 +26,7 @@ function createArticulationStagePropertyBag(value) { * @property {Property | boolean} [show=true] A boolean Property specifying the visibility of the model. * @property {Property | string | Resource} [uri] A string or Resource Property specifying the URI of the glTF asset. * @property {Property | number} [scale=1.0] A numeric Property specifying a uniform linear scale. + * @property {Property | boolean} [allowVerticalExaggeration=false] A boolean Property specifying to allow participation in scene Vertical Exaggeration. * @property {Property | number} [minimumPixelSize=0.0] A numeric Property specifying the approximate minimum pixel size of the model regardless of zoom. * @property {Property | number} [maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @property {Property | boolean} [incrementallyLoadTextures=true] Determine if textures may continue to stream in after the model is loaded. @@ -70,6 +71,8 @@ function ModelGraphics(options) { this._uriSubscription = undefined; this._scale = undefined; this._scaleSubscription = undefined; + this._allowVerticalExaggeration = undefined; + this._allowVerticalExaggerationSubscription = undefined; this._minimumPixelSize = undefined; this._minimumPixelSizeSubscription = undefined; this._maximumScale = undefined; @@ -150,6 +153,15 @@ Object.defineProperties(ModelGraphics.prototype, { */ scale: createPropertyDescriptor("scale"), + /** + * Gets or sets the boolean Property specifying the model to + * participate in scene Vertical Exaggeration. + * @memberof ModelGraphics.prototype + * @type {Property|undefined} + * @default false + */ + allowVerticalExaggeration: createPropertyDescriptor("allowVerticalExaggeration"), + /** * Gets or sets the numeric Property specifying the approximate minimum * pixel size of the model regardless of zoom. This can be used to ensure that @@ -333,6 +345,7 @@ ModelGraphics.prototype.clone = function (result) { result.show = this.show; result.uri = this.uri; result.scale = this.scale; + result.allowVerticalExaggeration = this.allowVerticalExaggeration; result.minimumPixelSize = this.minimumPixelSize; result.maximumScale = this.maximumScale; result.incrementallyLoadTextures = this.incrementallyLoadTextures; @@ -370,6 +383,10 @@ ModelGraphics.prototype.merge = function (source) { this.show = defaultValue(this.show, source.show); this.uri = defaultValue(this.uri, source.uri); this.scale = defaultValue(this.scale, source.scale); + this.allowVerticalExaggeration = defaultValue( + this.allowVerticalExaggeration, + source.allowVerticalExaggeration + ); this.minimumPixelSize = defaultValue( this.minimumPixelSize, source.minimumPixelSize diff --git a/packages/engine/Source/DataSources/ModelVisualizer.js b/packages/engine/Source/DataSources/ModelVisualizer.js index 393345358ae..39585396400 100644 --- a/packages/engine/Source/DataSources/ModelVisualizer.js +++ b/packages/engine/Source/DataSources/ModelVisualizer.js @@ -23,6 +23,7 @@ import Property from "./Property.js"; import Cartographic from "../Core/Cartographic.js"; const defaultScale = 1.0; +const defaultAllowVerticalexaggeration = false; const defaultMinimumPixelSize = 0.0; const defaultIncrementallyLoadTextures = true; const defaultClampAnimations = true; @@ -198,6 +199,13 @@ ModelVisualizer.prototype.update = function (time) { time, defaultScale ); + + model.allowVerticalExaggeration = Property.getValueOrDefault( + modelGraphics._allowVerticalExaggeration, + time, + defaultAllowVerticalexaggeration + ); + model.minimumPixelSize = Property.getValueOrDefault( modelGraphics._minimumPixelSize, time, diff --git a/packages/engine/Source/Scene/Model/Model.js b/packages/engine/Source/Scene/Model/Model.js index 3da886945f3..ecf205a2bf8 100644 --- a/packages/engine/Source/Scene/Model/Model.js +++ b/packages/engine/Source/Scene/Model/Model.js @@ -123,6 +123,7 @@ import pickModel from "./pickModel.js"; * @privateParam {boolean} [options.show=true] Whether or not to render the model. * @privateParam {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the model from model to world coordinates. * @privateParam {number} [options.scale=1.0] A uniform scale applied to this model. + * @privateParam {boolean} [options.allowVerticalExaggeration] Allows the model to participate in vertical exaggeration. * @privateParam {number} [options.minimumPixelSize=0.0] The approximate minimum pixel size of the model regardless of zoom. * @privateParam {number} [options.maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @privateParam {object} [options.id] A user-defined object to return when the model is picked with {@link Scene#pick}. @@ -161,7 +162,7 @@ import pickModel from "./pickModel.js"; * @privateParam {string|number} [options.instanceFeatureIdLabel="instanceFeatureId_0"] Label of the instance feature ID set used for picking and styling. If instanceFeatureIdLabel is set to an integer N, it is converted to the string "instanceFeatureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority. * @privateParam {object} [options.pointCloudShading] Options for constructing a {@link PointCloudShading} object to control point attenuation based on geometric error and lighting. * @privateParam {ClassificationType} [options.classificationType] Determines whether terrain, 3D Tiles or both will be classified by this model. This cannot be set after the model has loaded. - + * * * @see Model.fromGltfAsync * @@ -340,6 +341,7 @@ function Model(options) { this._heightDirty = this._heightReference !== HeightReference.NONE; this._removeUpdateHeightCallback = undefined; + this._allowVerticalExaggeration = defaultValue(options.allowVerticalExaggeration, false); this._verticalExaggerationOn = false; this._clampedModelMatrix = undefined; // For use with height reference @@ -1339,6 +1341,27 @@ Object.defineProperties(Model.prototype, { }, }, + /** + * Enable Models to participate in scene verticalExaggeration. + * + * @memberof Model.prototype + * + * @type {boolean} + */ + allowVerticalExaggeration: { + get: function () { + return this._allowVerticalExaggeration; + }, + set: function (value) { + if (value !== this._allowVerticalExaggeration) { + this.resetDrawCommands(); + } + this._allowVerticalExaggeration = value; + }, + }, + + + /** * The light color when shading the model. When undefined the scene's light color is used instead. *

@@ -2062,7 +2085,12 @@ function updateFog(model, frameState) { } function updateVerticalExaggeration(model, frameState) { - const verticalExaggerationNeeded = frameState.verticalExaggeration !== 1.0; + let shouldExaggerate = false; + if(model._allowVerticalExaggeration) { + shouldExaggerate = frameState.verticalExaggeration !== 1.0; + } + + const verticalExaggerationNeeded = shouldExaggerate; if (model._verticalExaggerationOn !== verticalExaggerationNeeded) { model.resetDrawCommands(); model._verticalExaggerationOn = verticalExaggerationNeeded; @@ -2748,6 +2776,7 @@ Model.prototype.destroyModelResources = function () { * @param {boolean} [options.show=true] Whether or not to render the model. * @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the model from model to world coordinates. * @param {number} [options.scale=1.0] A uniform scale applied to this model. + * @param {boolean} [options.allowVerticalExaggeration=false] Allows the model to participate in Vertical Exaggeration * @param {number} [options.minimumPixelSize=0.0] The approximate minimum pixel size of the model regardless of zoom. * @param {number} [options.maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @param {object} [options.id] A user-defined object to return when the model is picked with {@link Scene#pick}. @@ -3116,6 +3145,7 @@ function makeModelOptions(loader, modelType, options) { show: options.show, modelMatrix: options.modelMatrix, scale: options.scale, + allowVerticalExaggeration: options.allowVerticalExaggeration, minimumPixelSize: options.minimumPixelSize, maximumScale: options.maximumScale, id: options.id, diff --git a/packages/engine/Specs/Scene/Model/ModelSpec.js b/packages/engine/Specs/Scene/Model/ModelSpec.js index f91aab5bd9a..52fde5b5587 100644 --- a/packages/engine/Specs/Scene/Model/ModelSpec.js +++ b/packages/engine/Specs/Scene/Model/ModelSpec.js @@ -517,6 +517,8 @@ describe( expect(model.id).toBeUndefined(); expect(model.allowPicking).toEqual(true); + expect(model.allowVerticalExaggeration).toEqual(false); + expect(model.activeAnimations).toBeDefined(); expect(model.clampAnimations).toEqual(true); From 94ee958e585d88a2ba16d4b681ee85feeea11032 Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Fri, 9 Aug 2024 10:34:08 -0400 Subject: [PATCH 02/12] dont update husky --- .husky/pre-commit | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.husky/pre-commit b/.husky/pre-commit index e69de29bb2d..c37466e2b30 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged \ No newline at end of file From 91ff9c3df59e0ee11818e6ce4ae515cd986dcff0 Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Sun, 11 Aug 2024 10:24:35 -0400 Subject: [PATCH 03/12] Fixes #11940 : Fix Logic. Animation - if a model had not yet been rendered on the map, verticalExaggeration != 1.0 and allowVerticalExaggeration was set to false, it would still exaggerate. Capture state and reset model. --- .../Source/DataSources/ModelVisualizer.js | 4 +- packages/engine/Source/Scene/Model/Model.js | 52 ++++++++++++++----- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/packages/engine/Source/DataSources/ModelVisualizer.js b/packages/engine/Source/DataSources/ModelVisualizer.js index 39585396400..4c4399eee9c 100644 --- a/packages/engine/Source/DataSources/ModelVisualizer.js +++ b/packages/engine/Source/DataSources/ModelVisualizer.js @@ -23,7 +23,7 @@ import Property from "./Property.js"; import Cartographic from "../Core/Cartographic.js"; const defaultScale = 1.0; -const defaultAllowVerticalexaggeration = false; +const defaultAllowVerticalExaggeration = false; const defaultMinimumPixelSize = 0.0; const defaultIncrementallyLoadTextures = true; const defaultClampAnimations = true; @@ -203,7 +203,7 @@ ModelVisualizer.prototype.update = function (time) { model.allowVerticalExaggeration = Property.getValueOrDefault( modelGraphics._allowVerticalExaggeration, time, - defaultAllowVerticalexaggeration + defaultAllowVerticalExaggeration ); model.minimumPixelSize = Property.getValueOrDefault( diff --git a/packages/engine/Source/Scene/Model/Model.js b/packages/engine/Source/Scene/Model/Model.js index ecf205a2bf8..7b312bfda7c 100644 --- a/packages/engine/Source/Scene/Model/Model.js +++ b/packages/engine/Source/Scene/Model/Model.js @@ -123,7 +123,7 @@ import pickModel from "./pickModel.js"; * @privateParam {boolean} [options.show=true] Whether or not to render the model. * @privateParam {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the model from model to world coordinates. * @privateParam {number} [options.scale=1.0] A uniform scale applied to this model. - * @privateParam {boolean} [options.allowVerticalExaggeration] Allows the model to participate in vertical exaggeration. + * @privateParam {boolean} [options.allowVerticalExaggeration=false] Allows the model to participate in vertical exaggeration. * @privateParam {number} [options.minimumPixelSize=0.0] The approximate minimum pixel size of the model regardless of zoom. * @privateParam {number} [options.maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @privateParam {object} [options.id] A user-defined object to return when the model is picked with {@link Scene#pick}. @@ -341,8 +341,12 @@ function Model(options) { this._heightDirty = this._heightReference !== HeightReference.NONE; this._removeUpdateHeightCallback = undefined; - this._allowVerticalExaggeration = defaultValue(options.allowVerticalExaggeration, false); + this._allowVerticalExaggeration = defaultValue( + options.allowVerticalExaggeration, + false + ); this._verticalExaggerationOn = false; + this._modelInitialExaggerationSet = false; this._clampedModelMatrix = undefined; // For use with height reference @@ -1355,13 +1359,12 @@ Object.defineProperties(Model.prototype, { set: function (value) { if (value !== this._allowVerticalExaggeration) { this.resetDrawCommands(); + //this._verticalExaggerationDirty = true; } this._allowVerticalExaggeration = value; }, }, - - /** * The light color when shading the model. When undefined the scene's light color is used instead. *

@@ -1783,6 +1786,20 @@ const scratchClippingPlanesMatrix = new Matrix4(); * @exception {RuntimeError} Failed to load external reference. */ Model.prototype.update = function (frameState) { + //if VerticalExaggeration is not 1.0 when the model is built, it must be reset and rebuilt. + if (!this._modelVerticalExaggerationSet) { + if (!this._allowVerticalExaggeration) { + if (frameState.verticalExaggeration !== 1.0) { + //capture previous state and persist. + this._prevVerticalExaggerationSet = true; + this._prevVerticalExaggeration = frameState.verticalExaggeration; + frameState.verticalExaggeration = 1.0; + } else { + this._modelVerticalExaggerationSet = true; + } + } + } + let finishedProcessing = false; try { // Keep processing the model every frame until the main resources @@ -1906,6 +1923,12 @@ Model.prototype.update = function (frameState) { updatePickIds(this); + //reset previous state if required + if (this._prevVerticalExaggerationSet) { + frameState.verticalExaggeration = this._prevVerticalExaggeration; + this._prevVerticalExaggerationSet = false; + } + // Update the scene graph and draw commands for any changes in model's properties // (e.g. model matrix, back-face culling) updateSceneGraph(this, frameState); @@ -2085,15 +2108,18 @@ function updateFog(model, frameState) { } function updateVerticalExaggeration(model, frameState) { - let shouldExaggerate = false; - if(model._allowVerticalExaggeration) { - shouldExaggerate = frameState.verticalExaggeration !== 1.0; - } - - const verticalExaggerationNeeded = shouldExaggerate; - if (model._verticalExaggerationOn !== verticalExaggerationNeeded) { - model.resetDrawCommands(); - model._verticalExaggerationOn = verticalExaggerationNeeded; + if (model._allowVerticalExaggeration) { + const verticalExaggerationNeeded = frameState.verticalExaggeration !== 1.0; + if (model._verticalExaggerationOn !== verticalExaggerationNeeded) { + model.resetDrawCommands(); + model._verticalExaggerationOn = verticalExaggerationNeeded; + } + if (model._verticalExaggerationOn && verticalExaggerationNeeded) { + model._modelInitialExaggerationSet = false; + } + } else if (model._verticalExaggerationOn) { + model.resetDrawCommands(); //if verticalExaggeration was on, reset. + model._verticalExaggerationOn = false; } } From 04eabed9b379c582015e1ef72e8e51c1d3eceef7 Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Sun, 11 Aug 2024 14:31:39 -0400 Subject: [PATCH 04/12] Fixes #11940 : Fix Logic. Found where the exaggeration is actually implemented. Fixed accordingly. --- .../Source/DataSources/ModelGraphics.js | 6 ++- packages/engine/Source/Scene/Model/Model.js | 43 +++++++------------ .../Scene/Model/ModelRuntimePrimitive.js | 3 +- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/packages/engine/Source/DataSources/ModelGraphics.js b/packages/engine/Source/DataSources/ModelGraphics.js index fd9689aabbe..bb2d2c47e33 100644 --- a/packages/engine/Source/DataSources/ModelGraphics.js +++ b/packages/engine/Source/DataSources/ModelGraphics.js @@ -71,6 +71,8 @@ function ModelGraphics(options) { this._uriSubscription = undefined; this._scale = undefined; this._scaleSubscription = undefined; + this._verticalExaggerationOn = undefined; + this.__verticalExaggerationOnSubscription = undefined; this._allowVerticalExaggeration = undefined; this._allowVerticalExaggerationSubscription = undefined; this._minimumPixelSize = undefined; @@ -160,7 +162,9 @@ Object.defineProperties(ModelGraphics.prototype, { * @type {Property|undefined} * @default false */ - allowVerticalExaggeration: createPropertyDescriptor("allowVerticalExaggeration"), + allowVerticalExaggeration: createPropertyDescriptor( + "allowVerticalExaggeration" + ), /** * Gets or sets the numeric Property specifying the approximate minimum diff --git a/packages/engine/Source/Scene/Model/Model.js b/packages/engine/Source/Scene/Model/Model.js index 7b312bfda7c..3d8931d89ed 100644 --- a/packages/engine/Source/Scene/Model/Model.js +++ b/packages/engine/Source/Scene/Model/Model.js @@ -346,7 +346,6 @@ function Model(options) { false ); this._verticalExaggerationOn = false; - this._modelInitialExaggerationSet = false; this._clampedModelMatrix = undefined; // For use with height reference @@ -1365,6 +1364,19 @@ Object.defineProperties(Model.prototype, { }, }, + /** + * State of VerticalExaggeration (true = enabled, false = disabled). + * + * @memberof Model.prototype + * + * @type {boolean} + */ + verticalExaggerationOn: { + get: function () { + return this._verticalExaggerationOn; + }, + }, + /** * The light color when shading the model. When undefined the scene's light color is used instead. *

@@ -1786,20 +1798,6 @@ const scratchClippingPlanesMatrix = new Matrix4(); * @exception {RuntimeError} Failed to load external reference. */ Model.prototype.update = function (frameState) { - //if VerticalExaggeration is not 1.0 when the model is built, it must be reset and rebuilt. - if (!this._modelVerticalExaggerationSet) { - if (!this._allowVerticalExaggeration) { - if (frameState.verticalExaggeration !== 1.0) { - //capture previous state and persist. - this._prevVerticalExaggerationSet = true; - this._prevVerticalExaggeration = frameState.verticalExaggeration; - frameState.verticalExaggeration = 1.0; - } else { - this._modelVerticalExaggerationSet = true; - } - } - } - let finishedProcessing = false; try { // Keep processing the model every frame until the main resources @@ -1923,12 +1921,6 @@ Model.prototype.update = function (frameState) { updatePickIds(this); - //reset previous state if required - if (this._prevVerticalExaggerationSet) { - frameState.verticalExaggeration = this._prevVerticalExaggeration; - this._prevVerticalExaggerationSet = false; - } - // Update the scene graph and draw commands for any changes in model's properties // (e.g. model matrix, back-face culling) updateSceneGraph(this, frameState); @@ -2108,16 +2100,13 @@ function updateFog(model, frameState) { } function updateVerticalExaggeration(model, frameState) { - if (model._allowVerticalExaggeration) { + if (model.allowVerticalExaggeration) { const verticalExaggerationNeeded = frameState.verticalExaggeration !== 1.0; - if (model._verticalExaggerationOn !== verticalExaggerationNeeded) { + if (model.verticalExaggerationOn !== verticalExaggerationNeeded) { model.resetDrawCommands(); model._verticalExaggerationOn = verticalExaggerationNeeded; } - if (model._verticalExaggerationOn && verticalExaggerationNeeded) { - model._modelInitialExaggerationSet = false; - } - } else if (model._verticalExaggerationOn) { + } else if (model.verticalExaggerationOn) { model.resetDrawCommands(); //if verticalExaggeration was on, reset. model._verticalExaggerationOn = false; } diff --git a/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js b/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js index ed82ca255cf..c7dc1dacc08 100644 --- a/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js +++ b/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js @@ -199,7 +199,8 @@ ModelRuntimePrimitive.prototype.configurePipeline = function (frameState) { const mode = frameState.mode; const use2D = mode !== SceneMode.SCENE3D && !frameState.scene3DOnly && model._projectTo2D; - const exaggerateTerrain = frameState.verticalExaggeration !== 1.0; + const exaggerateTerrain = + frameState.verticalExaggeration !== 1.0 && model.verticalExaggerationOn; const hasMorphTargets = defined(primitive.morphTargets) && primitive.morphTargets.length > 0; From 7419df47421810d99c227bdc3a3e5dd036dab28d Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Tue, 20 Aug 2024 13:58:51 -0400 Subject: [PATCH 05/12] Fixes #11940 : adding changes and contributors --- CHANGES.md | 1 + CONTRIBUTORS.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 76fdfb03e6c..60c5a57429a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ ##### Additions :tada: +- added allowVerticalExaggeration configuration to models [#12141](https://github.com/CesiumGS/cesium/pull/12141) - Made the `time` parameter optional for `Property`, using `JulianDate.now()` as default. [#12099](https://github.com/CesiumGS/cesium/pull/12099) ### 1.120 - 2024-08-01 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 3596f223f9d..4ea8d8c7589 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -392,3 +392,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu - [Zhongxiang Wang](https://github.com/plainheart) - [Tim Schneider](https://github.com/Tim-S) - [Vladislav Yunev](https://github.com/YunVlad) +- [Timothy Eichfeld](https://github.com/timeichfeld-msa) From 8e6adc9f0d6006fa4ee82d0d517b94d55f5701e0 Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Tue, 20 Aug 2024 14:01:38 -0400 Subject: [PATCH 06/12] Fixes #11940 : adding changes and contributors --- CONTRIBUTORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4ea8d8c7589..636d9ef05bd 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -196,6 +196,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu - [T2 Software](http://t2.com.tr/) - [Hüseyin ATEŞ](https://github.com/ateshuseyin) - [İbrahim Furkan Aygar](https://github.com/furkanaygar) + - [Timothy Eichfeld](https://github.com/timeichfeld-msa) ## [Individual CLA](Documentation/Contributors/CLAs/individual-contributor-license-agreement-v1.0.pdf) @@ -392,4 +393,3 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu - [Zhongxiang Wang](https://github.com/plainheart) - [Tim Schneider](https://github.com/Tim-S) - [Vladislav Yunev](https://github.com/YunVlad) -- [Timothy Eichfeld](https://github.com/timeichfeld-msa) From 77bfabd4020a7892de7477125e63b89d0b9f38f4 Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Tue, 20 Aug 2024 14:04:13 -0400 Subject: [PATCH 07/12] Fixes #11940 : adding changes and contributors --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 636d9ef05bd..96f528d3f9c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -196,6 +196,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu - [T2 Software](http://t2.com.tr/) - [Hüseyin ATEŞ](https://github.com/ateshuseyin) - [İbrahim Furkan Aygar](https://github.com/furkanaygar) +- [MSA] - [Timothy Eichfeld](https://github.com/timeichfeld-msa) ## [Individual CLA](Documentation/Contributors/CLAs/individual-contributor-license-agreement-v1.0.pdf) From 85523e7cde7a0b1bb6823fcb581f65959bc606e6 Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Thu, 22 Aug 2024 16:15:36 -0400 Subject: [PATCH 08/12] Fixes #11940 : PR Update - default to true for allowVerticalExaggeration --- packages/engine/Source/DataSources/ModelGraphics.js | 4 ++-- packages/engine/Source/DataSources/ModelVisualizer.js | 2 +- packages/engine/Specs/Scene/Model/ModelSpec.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/engine/Source/DataSources/ModelGraphics.js b/packages/engine/Source/DataSources/ModelGraphics.js index bb2d2c47e33..f6c6cc52ec8 100644 --- a/packages/engine/Source/DataSources/ModelGraphics.js +++ b/packages/engine/Source/DataSources/ModelGraphics.js @@ -26,7 +26,7 @@ function createArticulationStagePropertyBag(value) { * @property {Property | boolean} [show=true] A boolean Property specifying the visibility of the model. * @property {Property | string | Resource} [uri] A string or Resource Property specifying the URI of the glTF asset. * @property {Property | number} [scale=1.0] A numeric Property specifying a uniform linear scale. - * @property {Property | boolean} [allowVerticalExaggeration=false] A boolean Property specifying to allow participation in scene Vertical Exaggeration. + * @property {Property | boolean} [allowVerticalExaggeration=true] A boolean Property specifying to allow participation in scene Vertical Exaggeration. * @property {Property | number} [minimumPixelSize=0.0] A numeric Property specifying the approximate minimum pixel size of the model regardless of zoom. * @property {Property | number} [maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @property {Property | boolean} [incrementallyLoadTextures=true] Determine if textures may continue to stream in after the model is loaded. @@ -72,7 +72,7 @@ function ModelGraphics(options) { this._scale = undefined; this._scaleSubscription = undefined; this._verticalExaggerationOn = undefined; - this.__verticalExaggerationOnSubscription = undefined; + this._verticalExaggerationOnSubscription = undefined; this._allowVerticalExaggeration = undefined; this._allowVerticalExaggerationSubscription = undefined; this._minimumPixelSize = undefined; diff --git a/packages/engine/Source/DataSources/ModelVisualizer.js b/packages/engine/Source/DataSources/ModelVisualizer.js index 4c4399eee9c..b2647f80b94 100644 --- a/packages/engine/Source/DataSources/ModelVisualizer.js +++ b/packages/engine/Source/DataSources/ModelVisualizer.js @@ -23,7 +23,7 @@ import Property from "./Property.js"; import Cartographic from "../Core/Cartographic.js"; const defaultScale = 1.0; -const defaultAllowVerticalExaggeration = false; +const defaultAllowVerticalExaggeration = true; const defaultMinimumPixelSize = 0.0; const defaultIncrementallyLoadTextures = true; const defaultClampAnimations = true; diff --git a/packages/engine/Specs/Scene/Model/ModelSpec.js b/packages/engine/Specs/Scene/Model/ModelSpec.js index 395feb8132f..fe6dd71c6e6 100644 --- a/packages/engine/Specs/Scene/Model/ModelSpec.js +++ b/packages/engine/Specs/Scene/Model/ModelSpec.js @@ -517,7 +517,7 @@ describe( expect(model.id).toBeUndefined(); expect(model.allowPicking).toEqual(true); - expect(model.allowVerticalExaggeration).toEqual(false); + expect(model.allowVerticalExaggeration).toEqual(true); expect(model.activeAnimations).toBeDefined(); expect(model.clampAnimations).toEqual(true); From 76f1cad7b59e8b3a6df5b16c1bddcf4d81228e83 Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Thu, 29 Aug 2024 17:13:23 -0400 Subject: [PATCH 09/12] Fixes #11940 : missed a couple defaults + code cleanup. --- CHANGES.md | 1 - CONTRIBUTORS.md | 2 +- packages/engine/Source/Scene/Model/Model.js | 5 ++--- packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 90edca2c8d5..4347ec374d3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,7 +6,6 @@ ##### Additions :tada: - - added allowVerticalExaggeration configuration to models [#12141](https://github.com/CesiumGS/cesium/pull/12141) - Enable MSAA by default with 4 samples. To turn MSAA off set `scene.msaaSamples = 1` [#12158](https://github.com/CesiumGS/cesium/pull/12158) - Made the `time` parameter optional for `Property`, using `JulianDate.now()` as default. [#12099](https://github.com/CesiumGS/cesium/pull/12099) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1b1c8756dc7..1d5507f98f8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -196,7 +196,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu - [T2 Software](http://t2.com.tr/) - [Hüseyin ATEŞ](https://github.com/ateshuseyin) - [İbrahim Furkan Aygar](https://github.com/furkanaygar) -- [MSA] +- MSA - [Timothy Eichfeld](https://github.com/timeichfeld-msa) - [EMapGis](http://emapgis.com) - [IKangXu](https://github.com/IKangXu) diff --git a/packages/engine/Source/Scene/Model/Model.js b/packages/engine/Source/Scene/Model/Model.js index 3d8931d89ed..e17ea61a4c9 100644 --- a/packages/engine/Source/Scene/Model/Model.js +++ b/packages/engine/Source/Scene/Model/Model.js @@ -123,7 +123,7 @@ import pickModel from "./pickModel.js"; * @privateParam {boolean} [options.show=true] Whether or not to render the model. * @privateParam {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the model from model to world coordinates. * @privateParam {number} [options.scale=1.0] A uniform scale applied to this model. - * @privateParam {boolean} [options.allowVerticalExaggeration=false] Allows the model to participate in vertical exaggeration. + * @privateParam {boolean} [options.allowVerticalExaggeration=true] Allows the model to participate in vertical exaggeration. * @privateParam {number} [options.minimumPixelSize=0.0] The approximate minimum pixel size of the model regardless of zoom. * @privateParam {number} [options.maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @privateParam {object} [options.id] A user-defined object to return when the model is picked with {@link Scene#pick}. @@ -1358,7 +1358,6 @@ Object.defineProperties(Model.prototype, { set: function (value) { if (value !== this._allowVerticalExaggeration) { this.resetDrawCommands(); - //this._verticalExaggerationDirty = true; } this._allowVerticalExaggeration = value; }, @@ -2791,7 +2790,7 @@ Model.prototype.destroyModelResources = function () { * @param {boolean} [options.show=true] Whether or not to render the model. * @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the model from model to world coordinates. * @param {number} [options.scale=1.0] A uniform scale applied to this model. - * @param {boolean} [options.allowVerticalExaggeration=false] Allows the model to participate in Vertical Exaggeration + * @param {boolean} [options.allowVerticalExaggeration=true] Allows the model to participate in Vertical Exaggeration * @param {number} [options.minimumPixelSize=0.0] The approximate minimum pixel size of the model regardless of zoom. * @param {number} [options.maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @param {object} [options.id] A user-defined object to return when the model is picked with {@link Scene#pick}. diff --git a/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js b/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js index c7dc1dacc08..1101a6c1d70 100644 --- a/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js +++ b/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js @@ -199,7 +199,7 @@ ModelRuntimePrimitive.prototype.configurePipeline = function (frameState) { const mode = frameState.mode; const use2D = mode !== SceneMode.SCENE3D && !frameState.scene3DOnly && model._projectTo2D; - const exaggerateTerrain = + const exaggerationOn = frameState.verticalExaggeration !== 1.0 && model.verticalExaggerationOn; const hasMorphTargets = @@ -284,7 +284,7 @@ ModelRuntimePrimitive.prototype.configurePipeline = function (frameState) { pipelineStages.push(CPUStylingPipelineStage); } - if (exaggerateTerrain) { + if (exaggerationOn) { pipelineStages.push(VerticalExaggerationPipelineStage); } From d09ceb8d0a196e846872b01dc6ab810eea3448b1 Mon Sep 17 00:00:00 2001 From: timeichfeld-msa Date: Thu, 29 Aug 2024 18:18:50 -0400 Subject: [PATCH 10/12] Fixes #11940 : missed a couple defaults + code cleanup - verticalExaggeration tests.. --- packages/engine/Source/Scene/Model/Model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/engine/Source/Scene/Model/Model.js b/packages/engine/Source/Scene/Model/Model.js index e17ea61a4c9..149173cabe0 100644 --- a/packages/engine/Source/Scene/Model/Model.js +++ b/packages/engine/Source/Scene/Model/Model.js @@ -343,7 +343,7 @@ function Model(options) { this._allowVerticalExaggeration = defaultValue( options.allowVerticalExaggeration, - false + true ); this._verticalExaggerationOn = false; From 3ddfaa0b12792a4ea8907d4216a0a7dce808e8ce Mon Sep 17 00:00:00 2001 From: ggetz Date: Tue, 3 Sep 2024 10:23:18 -0400 Subject: [PATCH 11/12] Update property naming and documentation --- CHANGES.md | 2 +- .../Source/DataSources/ModelGraphics.js | 23 +++++---- .../Source/DataSources/ModelVisualizer.js | 8 +-- packages/engine/Source/Scene/Model/Model.js | 49 +++++++++++-------- .../Scene/Model/ModelRuntimePrimitive.js | 6 +-- .../engine/Specs/Scene/Model/ModelSpec.js | 2 +- 6 files changed, 48 insertions(+), 42 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4347ec374d3..d8ab8e6b3f0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,7 +6,7 @@ ##### Additions :tada: -- added allowVerticalExaggeration configuration to models [#12141](https://github.com/CesiumGS/cesium/pull/12141) +- Added `enableVerticalExaggeration` option to models. Set this value to `false` to prevent model exaggeration when `Scene.verticalExaggeration` is set to a value other than `1.0`. [#12141](https://github.com/CesiumGS/cesium/pull/12141) - Enable MSAA by default with 4 samples. To turn MSAA off set `scene.msaaSamples = 1` [#12158](https://github.com/CesiumGS/cesium/pull/12158) - Made the `time` parameter optional for `Property`, using `JulianDate.now()` as default. [#12099](https://github.com/CesiumGS/cesium/pull/12099) - Exposes `ScreenSpaceCameraController.zoomFactor` to allow adjusting the zoom factor (speed). [#9145](https://github.com/CesiumGS/cesium/pull/9145) diff --git a/packages/engine/Source/DataSources/ModelGraphics.js b/packages/engine/Source/DataSources/ModelGraphics.js index f6c6cc52ec8..480028cc15f 100644 --- a/packages/engine/Source/DataSources/ModelGraphics.js +++ b/packages/engine/Source/DataSources/ModelGraphics.js @@ -26,7 +26,7 @@ function createArticulationStagePropertyBag(value) { * @property {Property | boolean} [show=true] A boolean Property specifying the visibility of the model. * @property {Property | string | Resource} [uri] A string or Resource Property specifying the URI of the glTF asset. * @property {Property | number} [scale=1.0] A numeric Property specifying a uniform linear scale. - * @property {Property | boolean} [allowVerticalExaggeration=true] A boolean Property specifying to allow participation in scene Vertical Exaggeration. + * @property {Property | boolean} [enableVerticalExaggeration=true] A boolean Property specifying if the model is exaggerated along the ellipsoid normal when {@link Scene.verticalExaggeration} is set to a value other than 1.0. * @property {Property | number} [minimumPixelSize=0.0] A numeric Property specifying the approximate minimum pixel size of the model regardless of zoom. * @property {Property | number} [maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @property {Property | boolean} [incrementallyLoadTextures=true] Determine if textures may continue to stream in after the model is loaded. @@ -73,8 +73,8 @@ function ModelGraphics(options) { this._scaleSubscription = undefined; this._verticalExaggerationOn = undefined; this._verticalExaggerationOnSubscription = undefined; - this._allowVerticalExaggeration = undefined; - this._allowVerticalExaggerationSubscription = undefined; + this._enableVerticalExaggeration = undefined; + this._enableVerticalExaggerationSubscription = undefined; this._minimumPixelSize = undefined; this._minimumPixelSizeSubscription = undefined; this._maximumScale = undefined; @@ -156,14 +156,13 @@ Object.defineProperties(ModelGraphics.prototype, { scale: createPropertyDescriptor("scale"), /** - * Gets or sets the boolean Property specifying the model to - * participate in scene Vertical Exaggeration. + * Gets or sets the boolean Property specifying if the model is exaggerated along the ellipsoid normal when {@link Scene.verticalExaggeration} is set to a value other than 1.0. * @memberof ModelGraphics.prototype * @type {Property|undefined} - * @default false + * @default true */ - allowVerticalExaggeration: createPropertyDescriptor( - "allowVerticalExaggeration" + enableVerticalExaggeration: createPropertyDescriptor( + "enableVerticalExaggeration" ), /** @@ -349,7 +348,7 @@ ModelGraphics.prototype.clone = function (result) { result.show = this.show; result.uri = this.uri; result.scale = this.scale; - result.allowVerticalExaggeration = this.allowVerticalExaggeration; + result.enableVerticalExaggeration = this.enableVerticalExaggeration; result.minimumPixelSize = this.minimumPixelSize; result.maximumScale = this.maximumScale; result.incrementallyLoadTextures = this.incrementallyLoadTextures; @@ -387,9 +386,9 @@ ModelGraphics.prototype.merge = function (source) { this.show = defaultValue(this.show, source.show); this.uri = defaultValue(this.uri, source.uri); this.scale = defaultValue(this.scale, source.scale); - this.allowVerticalExaggeration = defaultValue( - this.allowVerticalExaggeration, - source.allowVerticalExaggeration + this.enableVerticalExaggeration = defaultValue( + this.enableVerticalExaggeration, + source.enableVerticalExaggeration ); this.minimumPixelSize = defaultValue( this.minimumPixelSize, diff --git a/packages/engine/Source/DataSources/ModelVisualizer.js b/packages/engine/Source/DataSources/ModelVisualizer.js index b2647f80b94..ab326dbc44c 100644 --- a/packages/engine/Source/DataSources/ModelVisualizer.js +++ b/packages/engine/Source/DataSources/ModelVisualizer.js @@ -23,7 +23,7 @@ import Property from "./Property.js"; import Cartographic from "../Core/Cartographic.js"; const defaultScale = 1.0; -const defaultAllowVerticalExaggeration = true; +const defaultEnableVerticalExaggeration = true; const defaultMinimumPixelSize = 0.0; const defaultIncrementallyLoadTextures = true; const defaultClampAnimations = true; @@ -200,10 +200,10 @@ ModelVisualizer.prototype.update = function (time) { defaultScale ); - model.allowVerticalExaggeration = Property.getValueOrDefault( - modelGraphics._allowVerticalExaggeration, + model.enableVerticalExaggeration = Property.getValueOrDefault( + modelGraphics._enableVerticalExaggeration, time, - defaultAllowVerticalExaggeration + defaultEnableVerticalExaggeration ); model.minimumPixelSize = Property.getValueOrDefault( diff --git a/packages/engine/Source/Scene/Model/Model.js b/packages/engine/Source/Scene/Model/Model.js index 149173cabe0..e5415a11587 100644 --- a/packages/engine/Source/Scene/Model/Model.js +++ b/packages/engine/Source/Scene/Model/Model.js @@ -123,7 +123,7 @@ import pickModel from "./pickModel.js"; * @privateParam {boolean} [options.show=true] Whether or not to render the model. * @privateParam {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the model from model to world coordinates. * @privateParam {number} [options.scale=1.0] A uniform scale applied to this model. - * @privateParam {boolean} [options.allowVerticalExaggeration=true] Allows the model to participate in vertical exaggeration. + * @privateParam {boolean} [options.enableVerticalExaggeration=true] If true, the model is exaggerated along the ellipsoid normal when {@link Scene.verticalExaggeration} is set to a value other than 1.0. * @privateParam {number} [options.minimumPixelSize=0.0] The approximate minimum pixel size of the model regardless of zoom. * @privateParam {number} [options.maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @privateParam {object} [options.id] A user-defined object to return when the model is picked with {@link Scene#pick}. @@ -341,11 +341,11 @@ function Model(options) { this._heightDirty = this._heightReference !== HeightReference.NONE; this._removeUpdateHeightCallback = undefined; - this._allowVerticalExaggeration = defaultValue( - options.allowVerticalExaggeration, + this._enableVerticalExaggeration = defaultValue( + options.enableVerticalExaggeration, true ); - this._verticalExaggerationOn = false; + this._hasVerticalExaggeration = false; this._clampedModelMatrix = undefined; // For use with height reference @@ -1345,34 +1345,41 @@ Object.defineProperties(Model.prototype, { }, /** - * Enable Models to participate in scene verticalExaggeration. + * If true, the model is exaggerated along the ellipsoid normal when {@link Scene.verticalExaggeration} is set to a value other than 1.0. * * @memberof Model.prototype - * * @type {boolean} + * @default true + * + * @example + * // Exaggerate terrain by a factor of 2, but prevent model exaggeration + * scene.verticalExaggeration = 2.0; + * model.enableVerticalExaggeration = false; */ - allowVerticalExaggeration: { + enableVerticalExaggeration: { get: function () { - return this._allowVerticalExaggeration; + return this._enableVerticalExaggeration; }, set: function (value) { - if (value !== this._allowVerticalExaggeration) { + if (value !== this._enableVerticalExaggeration) { this.resetDrawCommands(); } - this._allowVerticalExaggeration = value; + this._enableVerticalExaggeration = value; }, }, /** - * State of VerticalExaggeration (true = enabled, false = disabled). + * If true, the model is vertically exaggerated along the ellipsoid normal. * * @memberof Model.prototype - * * @type {boolean} + * @default true + * @readonly + * @private */ - verticalExaggerationOn: { + hasVerticalExaggeration: { get: function () { - return this._verticalExaggerationOn; + return this._hasVerticalExaggeration; }, }, @@ -2099,15 +2106,15 @@ function updateFog(model, frameState) { } function updateVerticalExaggeration(model, frameState) { - if (model.allowVerticalExaggeration) { + if (model.enableVerticalExaggeration) { const verticalExaggerationNeeded = frameState.verticalExaggeration !== 1.0; - if (model.verticalExaggerationOn !== verticalExaggerationNeeded) { + if (model.hasVerticalExaggeration !== verticalExaggerationNeeded) { model.resetDrawCommands(); - model._verticalExaggerationOn = verticalExaggerationNeeded; + model._hasVerticalExaggeration = verticalExaggerationNeeded; } - } else if (model.verticalExaggerationOn) { + } else if (model.hasVerticalExaggeration) { model.resetDrawCommands(); //if verticalExaggeration was on, reset. - model._verticalExaggerationOn = false; + model._hasVerticalExaggeration = false; } } @@ -2790,7 +2797,7 @@ Model.prototype.destroyModelResources = function () { * @param {boolean} [options.show=true] Whether or not to render the model. * @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms the model from model to world coordinates. * @param {number} [options.scale=1.0] A uniform scale applied to this model. - * @param {boolean} [options.allowVerticalExaggeration=true] Allows the model to participate in Vertical Exaggeration + * @param {boolean} [options.enableVerticalExaggeration=true] If true, the model is exaggerated along the ellipsoid normal when {@link Scene.verticalExaggeration} is set to a value other than 1.0. * @param {number} [options.minimumPixelSize=0.0] The approximate minimum pixel size of the model regardless of zoom. * @param {number} [options.maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @param {object} [options.id] A user-defined object to return when the model is picked with {@link Scene#pick}. @@ -3159,7 +3166,7 @@ function makeModelOptions(loader, modelType, options) { show: options.show, modelMatrix: options.modelMatrix, scale: options.scale, - allowVerticalExaggeration: options.allowVerticalExaggeration, + enableVerticalExaggeration: options.enableVerticalExaggeration, minimumPixelSize: options.minimumPixelSize, maximumScale: options.maximumScale, id: options.id, diff --git a/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js b/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js index 1101a6c1d70..fb4b7b08324 100644 --- a/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js +++ b/packages/engine/Source/Scene/Model/ModelRuntimePrimitive.js @@ -199,8 +199,8 @@ ModelRuntimePrimitive.prototype.configurePipeline = function (frameState) { const mode = frameState.mode; const use2D = mode !== SceneMode.SCENE3D && !frameState.scene3DOnly && model._projectTo2D; - const exaggerationOn = - frameState.verticalExaggeration !== 1.0 && model.verticalExaggerationOn; + const hasVerticalExaggeration = + frameState.verticalExaggeration !== 1.0 && model.hasVerticalExaggeration; const hasMorphTargets = defined(primitive.morphTargets) && primitive.morphTargets.length > 0; @@ -284,7 +284,7 @@ ModelRuntimePrimitive.prototype.configurePipeline = function (frameState) { pipelineStages.push(CPUStylingPipelineStage); } - if (exaggerationOn) { + if (hasVerticalExaggeration) { pipelineStages.push(VerticalExaggerationPipelineStage); } diff --git a/packages/engine/Specs/Scene/Model/ModelSpec.js b/packages/engine/Specs/Scene/Model/ModelSpec.js index fe6dd71c6e6..7706b300837 100644 --- a/packages/engine/Specs/Scene/Model/ModelSpec.js +++ b/packages/engine/Specs/Scene/Model/ModelSpec.js @@ -517,7 +517,7 @@ describe( expect(model.id).toBeUndefined(); expect(model.allowPicking).toEqual(true); - expect(model.allowVerticalExaggeration).toEqual(true); + expect(model.enableVerticalExaggeration).toEqual(true); expect(model.activeAnimations).toBeDefined(); expect(model.clampAnimations).toEqual(true); From 3341fa6ab6253c398f62054520d21e5ab8f061d3 Mon Sep 17 00:00:00 2001 From: ggetz Date: Tue, 3 Sep 2024 11:56:20 -0400 Subject: [PATCH 12/12] Spec updates, move to 1.122 release --- CHANGES.md | 5 +++- .../Source/DataSources/ModelGraphics.js | 4 +-- .../Scene/Model/ModelRuntimePrimitiveSpec.js | 28 +++++++++++++++++++ .../engine/Specs/Scene/Model/ModelSpec.js | 23 ++++++++++++++- 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8a6b41fe4a8..e95dd136a39 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,12 +1,15 @@ # Change Log +### 1.122 - 2024-10-01 + +- Added `enableVerticalExaggeration` option to models. Set this value to `false` to prevent model exaggeration when `Scene.verticalExaggeration` is set to a value other than `1.0`. [#12141](https://github.com/CesiumGS/cesium/pull/12141) + ### 1.121 - 2024-09-01 #### @cesium/engine ##### Additions :tada: -- Added `enableVerticalExaggeration` option to models. Set this value to `false` to prevent model exaggeration when `Scene.verticalExaggeration` is set to a value other than `1.0`. [#12141](https://github.com/CesiumGS/cesium/pull/12141) - Enable MSAA by default with 4 samples. To turn MSAA off set `scene.msaaSamples = 1` [#12158](https://github.com/CesiumGS/cesium/pull/12158) - Made the `time` parameter optional for `Property`, using `JulianDate.now()` as default. [#12099](https://github.com/CesiumGS/cesium/pull/12099) - Exposes `ScreenSpaceCameraController.zoomFactor` to allow adjusting the zoom factor (speed). [#9145](https://github.com/CesiumGS/cesium/pull/9145) diff --git a/packages/engine/Source/DataSources/ModelGraphics.js b/packages/engine/Source/DataSources/ModelGraphics.js index 480028cc15f..1814566bad1 100644 --- a/packages/engine/Source/DataSources/ModelGraphics.js +++ b/packages/engine/Source/DataSources/ModelGraphics.js @@ -71,8 +71,8 @@ function ModelGraphics(options) { this._uriSubscription = undefined; this._scale = undefined; this._scaleSubscription = undefined; - this._verticalExaggerationOn = undefined; - this._verticalExaggerationOnSubscription = undefined; + this._hasVerticalExaggeration = undefined; + this._hasVerticalExaggerationSubscription = undefined; this._enableVerticalExaggeration = undefined; this._enableVerticalExaggerationSubscription = undefined; this._minimumPixelSize = undefined; diff --git a/packages/engine/Specs/Scene/Model/ModelRuntimePrimitiveSpec.js b/packages/engine/Specs/Scene/Model/ModelRuntimePrimitiveSpec.js index 6e73cc3fbc8..273a138e3dc 100644 --- a/packages/engine/Specs/Scene/Model/ModelRuntimePrimitiveSpec.js +++ b/packages/engine/Specs/Scene/Model/ModelRuntimePrimitiveSpec.js @@ -44,6 +44,7 @@ describe("Scene/Model/ModelRuntimePrimitive", function () { type: ModelType.GLTF, allowPicking: true, featureIdLabel: "featureId_0", + hasVerticalExaggeration: true, }; const mockWebgl1Context = { webgl2: false, @@ -992,4 +993,31 @@ describe("Scene/Model/ModelRuntimePrimitive", function () { primitive.configurePipeline(frameState); verifyExpectedStages(primitive.pipelineStages, expectedStages); }); + + it("configures pipeline stages for vertical exaggeration when enableVerticalExaggeration is false", function () { + const primitive = new ModelRuntimePrimitive({ + primitive: mockPrimitive, + node: mockNode, + model: { + ...mockModel, + hasVerticalExaggeration: false, + }, + }); + const frameState = createFrameState(mockWebgl2Context); + frameState.verticalExaggeration = 2.0; + + const expectedStages = [ + GeometryPipelineStage, + MaterialPipelineStage, + FeatureIdPipelineStage, + MetadataPipelineStage, + LightingPipelineStage, + PickingPipelineStage, + AlphaPipelineStage, + PrimitiveStatisticsPipelineStage, + ]; + + primitive.configurePipeline(frameState); + verifyExpectedStages(primitive.pipelineStages, expectedStages); + }); }); diff --git a/packages/engine/Specs/Scene/Model/ModelSpec.js b/packages/engine/Specs/Scene/Model/ModelSpec.js index 7706b300837..8a6386bd7c1 100644 --- a/packages/engine/Specs/Scene/Model/ModelSpec.js +++ b/packages/engine/Specs/Scene/Model/ModelSpec.js @@ -3771,7 +3771,28 @@ describe( scene.verticalExaggeration = 2.0; scene.renderForSpecs(); expect(resetDrawCommands).toHaveBeenCalled(); - scene.verticalExaggeration = 1.0; + }); + + it("resets draw commands when enableVerticalExaggeration changes", async function () { + scene.verticalExaggeration = 2.0; + const model = await loadAndZoomToModelAsync( + { + gltf: boxTexturedGltfUrl, + }, + scene + ); + const resetDrawCommands = spyOn( + model, + "resetDrawCommands" + ).and.callThrough(); + expect(model.ready).toBe(true); + expect(model.hasVerticalExaggeration).toBe(true); + + model.enableVerticalExaggeration = false; + + scene.renderForSpecs(); + expect(resetDrawCommands).toHaveBeenCalled(); + expect(model.hasVerticalExaggeration).toBe(false); }); it("does not issue draw commands when ignoreCommands is true", async function () {