Skip to content
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

Clipping planes support cleanup #6084

Merged
merged 2 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Source/Core/ClippingPlaneCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define([
'./defined',
'./defineProperties',
'./DeveloperError',
'./FeatureDetection',
'./Intersect',
'./Matrix4',
'./Plane'
Expand All @@ -19,6 +20,7 @@ define([
defined,
defineProperties,
DeveloperError,
FeatureDetection,
Intersect,
Matrix4,
Plane) {
Expand Down Expand Up @@ -362,6 +364,15 @@ define([
return intersection;
};

/**
* Determines if rendering with clipping planes is supported.
*
* @returns {Boolean} <code>true</code> if ClippingPlaneCollections are supported; otherwise, returns <code>false</code>
*/
ClippingPlaneCollection.isSupported = function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this warrant an update to CHANGES.md, or too minor? @pjcozzi?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything that changes the public API always warrants a CHANGEs.md update.

return !FeatureDetection.isInternetExplorer();
};

/**
* The maximum number of supported clipping planes.
*
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/ModelGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ define([
* @param {Property} [options.color=Color.WHITE] A Property specifying the {@link Color} that blends with the model's rendered color.
* @param {Property} [options.colorBlendMode=ColorBlendMode.HIGHLIGHT] An enum Property specifying how the color blends with the model.
* @param {Property} [options.colorBlendAmount=0.5] A numeric Property specifying the color strength when the <code>colorBlendMode</code> is <code>MIX</code>. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.
* @param {Property} [options.clippingPlanes] A property specifying the {@link ClippingPlaneCollection} used to selectively disable rendering the model.
* @param {Property} [options.clippingPlanes] A property specifying the {@link ClippingPlaneCollection} used to selectively disable rendering the model. Clipping planes are not currently supported in Internet Explorer.
*
* @see {@link http://cesiumjs.org/2014/03/03/Cesium-3D-Models-Tutorial/|3D Models Tutorial}
* @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Models.html|Cesium Sandcastle 3D Models Demo}
Expand Down
6 changes: 3 additions & 3 deletions Source/Scene/GlobeSurfaceTileProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define([
'../Core/Cartesian2',
'../Core/Cartesian3',
'../Core/Cartesian4',
'../Core/ClippingPlaneCollection',
'../Core/Color',
'../Core/ColorGeometryInstanceAttribute',
'../Core/combine',
Expand All @@ -13,7 +14,6 @@ define([
'../Core/destroyObject',
'../Core/DeveloperError',
'../Core/Event',
'../Core/FeatureDetection',
'../Core/GeometryInstance',
'../Core/GeometryPipeline',
'../Core/IndexDatatype',
Expand Down Expand Up @@ -51,6 +51,7 @@ define([
Cartesian2,
Cartesian3,
Cartesian4,
ClippingPlaneCollection,
Color,
ColorGeometryInstanceAttribute,
combine,
Expand All @@ -60,7 +61,6 @@ define([
destroyObject,
DeveloperError,
Event,
FeatureDetection,
GeometryInstance,
GeometryPipeline,
IndexDatatype,
Expand Down Expand Up @@ -1322,7 +1322,7 @@ define([
uniformMapProperties.clippingPlanesEdgeWidth = clippingPlanes.edgeWidth;
}

var clippingPlanesEnabled = defined(clippingPlanes) && clippingPlanes.enabled && (uniformMapProperties.clippingPlanes.length > 0) && !FeatureDetection.isInternetExplorer();
var clippingPlanesEnabled = defined(clippingPlanes) && clippingPlanes.enabled && (uniformMapProperties.clippingPlanes.length > 0) && ClippingPlaneCollection.isSupported();
var unionClippingRegions = clippingPlanesEnabled ? clippingPlanes.unionClippingRegions : false;

if (defined(tileProvider.uniformMap)) {
Expand Down
13 changes: 12 additions & 1 deletion Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define([
'../Core/Cartesian3',
'../Core/Cartesian4',
'../Core/Cartographic',
'../Core/ClippingPlaneCollection',
'../Core/clone',
'../Core/Color',
'../Core/combine',
Expand Down Expand Up @@ -81,6 +82,7 @@ define([
Cartesian3,
Cartesian4,
Cartographic,
ClippingPlaneCollection,
clone,
Color,
combine,
Expand Down Expand Up @@ -1135,6 +1137,15 @@ define([
* @param {ShadowMode} [options.shadows=ShadowMode.ENABLED] Determines whether the model casts or receives shadows from each light source.
* @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Draws the bounding sphere for each {@link DrawCommand} in the model.
* @param {Boolean} [options.debugWireframe=false] For debugging only. Draws the model in wireframe.
* @param {HeightReference} [options.heightReference] Determines how the model is drawn relative to terrain.
* @param {Scene} [options.scene] Must be passed in for models that use the height reference property.
* @param {DistanceDisplayCondition} [options.distanceDisplayCondition] The condition specifying at what distance from the camera that this model will be displayed.
* @param {Color} [options.color=Color.WHITE] A color that blends with the model's rendered color.
* @param {ColorBlendMode} [options.colorBlendMode=ColorBlendMode.HIGHLIGHT] Defines how the color blends with the model.
* @param {Number} [options.colorBlendAmount=0.5] Value used to determine the color strength when the <code>colorBlendMode</code> is <code>MIX</code>. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.
* @param {Color} [options.silhouetteColor=Color.RED] The silhouette color. If more than 256 models have silhouettes enabled, there is a small chance that overlapping models will have minor artifacts.
* @param {Number} [options.silhouetteSize=0.0] The size of the silhouette in pixels.
* @param {ClippingPlaneCollection} [options.clippingPlanes] The {@link ClippingPlaneCollection} used to selectively disable rendering the model. Clipping planes are not currently supported in Internet Explorer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks... I didn't realize so many options were missing.

*
* @returns {Model} The newly created model.
*
Expand Down Expand Up @@ -2116,7 +2127,7 @@ define([

var premultipliedAlpha = hasPremultipliedAlpha(model);
var finalFS = modifyShaderForColor(fs, premultipliedAlpha);
if (!FeatureDetection.isInternetExplorer()) {
if (ClippingPlaneCollection.isSupported()) {
finalFS = modifyShaderForClippingPlanes(finalFS);
}

Expand Down
4 changes: 3 additions & 1 deletion Source/Scene/PointCloud3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define([
'../Core/Cartesian2',
'../Core/Cartesian3',
'../Core/Cartesian4',
'../Core/ClippingPlaneCollection',
'../Core/Color',
'../Core/combine',
'../Core/ComponentDatatype',
Expand Down Expand Up @@ -38,6 +39,7 @@ define([
Cartesian2,
Cartesian3,
Cartesian4,
ClippingPlaneCollection,
Color,
combine,
ComponentDatatype,
Expand Down Expand Up @@ -844,7 +846,7 @@ define([
var hasColorStyle = defined(colorStyleFunction);
var hasShowStyle = defined(showStyleFunction);
var hasPointSizeStyle = defined(pointSizeStyleFunction);
var hasClippedContent = defined(clippingPlanes) && clippingPlanes.enabled && content._tile._isClipped && !FeatureDetection.isInternetExplorer();
var hasClippedContent = defined(clippingPlanes) && clippingPlanes.enabled && content._tile._isClipped && ClippingPlaneCollection.isSupported();

// Get the properties in use by the style
var styleableProperties = [];
Expand Down