-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #11940 : add VerticalExaggeration option to models #12141
Changes from 11 commits
379362d
94ee958
91ff9c3
04eabed
abf6afe
7419df4
8e6adc9
fef11cf
77bfabd
85523e7
82a2725
76f1cad
d09ceb8
3ddfaa0
4918730
fbbbe1d
3341fa6
c0fa214
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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=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}. | ||
|
@@ -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,10 @@ 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 +1344,39 @@ 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._verticalExaggerationDirty = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume we can drop this commented line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
} | ||
this._allowVerticalExaggeration = value; | ||
}, | ||
}, | ||
|
||
/** | ||
* 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 <code>undefined</code> the scene's light color is used instead. | ||
* <p> | ||
|
@@ -2062,10 +2100,15 @@ function updateFog(model, frameState) { | |
} | ||
|
||
function updateVerticalExaggeration(model, frameState) { | ||
const verticalExaggerationNeeded = frameState.verticalExaggeration !== 1.0; | ||
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; | ||
} | ||
} else if (model.verticalExaggerationOn) { | ||
model.resetDrawCommands(); //if verticalExaggeration was on, reset. | ||
model._verticalExaggerationOn = false; | ||
} | ||
} | ||
|
||
|
@@ -2748,6 +2791,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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another place to change the default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. complete |
||
* @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 +3160,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, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we rename this variable to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. complete |
||
frameState.verticalExaggeration !== 1.0 && model.verticalExaggerationOn; | ||
|
||
const hasMorphTargets = | ||
defined(primitive.morphTargets) && primitive.morphTargets.length > 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will also want this class to default to
true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
complete.