Skip to content

Commit

Permalink
Merge pull request #6084 from AnalyticalGraphicsInc/clip-planes-fix
Browse files Browse the repository at this point in the history
Clipping planes support cleanup
  • Loading branch information
lilleyse authored Jan 3, 2018
2 parents 7f9abdd + c8948f3 commit 588d98b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
==========

### 1.42 - 2018-02-01

* Added `ClippingPlaneCollection.isSupported` function for checking if rendering with clipping planes is supported.

### 1.41 - 2018-01-02

* Breaking changes
Expand Down
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() {
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.
*
* @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

0 comments on commit 588d98b

Please sign in to comment.