-
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
Add property for extruding polygon entities down to terrain #6214
Conversation
@hpinkos, thanks for the pull request! Maintainers, we have a signed CLA from @hpinkos, so you can review this at any time.
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
27f8071
to
c0fc209
Compare
@mramato can you review this? |
Will check it out tonight. |
/** | ||
* @private | ||
*/ | ||
MinimumTerrainHeightProperty.prototype._getValue = function(time) { |
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.
Is there a reason this is not just inline in getValue
?
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.
Yes, because I blindly copied VelocityVectorProperty
=P
It's probably not needed
'use strict'; | ||
|
||
/** | ||
* A {@link Property} which evaluates to a {@link Number} based on the minimum height of terrain |
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.
Number doesn't need a @link
here.
Eventually, |
requestWaterMask : true, | ||
requestVertexNormals : true | ||
}); | ||
viewer.terrainProvider = terrainProvider; |
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.
Disable the baselayer picker and pass the terrainProvider directly to the Viewer constructor, it avoid creating and immediately throwing out an Ellipsoid provider.
if (!isArray(positions)) { | ||
positions = positions.positions; //positions is a PolygonHierarchy, just use the outer ring | ||
} | ||
var rectangle = Rectangle.fromCartesianArray(positions); |
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.
This should use a scratch parameter for the result rectangle.
*/ | ||
MinimumTerrainHeightProperty.prototype.getValue = function(time) { | ||
//>>includeStart('debug', pragmas.debug); | ||
if (!defined(time)) { |
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.
Use Check
for new code.
I think that's all I have. |
@mramato ready |
@mramato can you review my I updated the Sandcastle example to use this property too |
* } | ||
* }); | ||
*/ | ||
function RelativeToTerrainHeightProperty(terrainProvider, positions, heightRelativeToTerrain) { |
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.
Since the name is generic, it might be easy to adapt this to work with a single position as well.
|
||
if (defined(value)) { | ||
if (!value.isConstant) { | ||
throw new RuntimeError('positions must be a constant property'); |
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.
Shouldn't this be a developer error?
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.
We actually could support time-dynamic values if we just made it "best effort", i.e. it would only call sampleTerrain
if a current request wasn't already in flight.
} | ||
this._subscription = value._definitionChanged.addEventListener(function() { | ||
this._fetchTerrainHeight(); | ||
this._definitionChanged.raiseEvent(this); |
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.
It might be better to remove this line (and below) and just let _fetchTerrainHeight
raise definitionChanged as soon as it's complete.
}); | ||
|
||
var centroidScratch = new Cartesian3(); | ||
function computeCentroid(positions) { |
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 know we discussed this offline, but if I were doing this I would make a CentroidProperty
that computes this value and then RelativeToTerrainHeightProperty
can just always take a PositionProperty.
* @returns {Number} The height relative to terrain | ||
*/ | ||
RelativeToTerrainHeightProperty.prototype.getValue = function(time) { | ||
return this._terrainHeight + this.heightRelativeToTerrain.getValue(time); |
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.
Always use Property.getValue
when accessing values in our code. Probably Property.getValueOrDefault
in this case to avoid NaN
Nothing crazy jumped out at me, I still have reservations as to how specific or general these properties should be. I'm leaning towards more general (as I'm sure you can tell by my comments). |
GroundPrimitive
min/max terrain height code out intoApproximateTerrainHeights
static classMinimumTerrainHeightProperty
, which takes a property for the positions and computes the height based on those positions