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 for models, tilesets, point clouds #5913

Merged
merged 20 commits into from
Nov 2, 2017
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
29 changes: 19 additions & 10 deletions Apps/Sandcastle/gallery/Clipping Planes.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@
var viewer = new Cesium.Viewer('cesiumContainer');

var defaultClippingPlanes = [
new Cesium.Plane(Cesium.Cartesian3.UNIT_X, 0),
new Cesium.Plane(Cesium.Cartesian3.UNIT_Y, 0),
new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0)
new Cesium.Plane(new Cesium.Cartesian3(-1, 0, 0), 0.0),
Copy link
Contributor

Choose a reason for hiding this comment

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

Throughout, add .0 to numbers that are intended to be floating point.

new Cesium.Plane(new Cesium.Cartesian3(0, -1, 0), 100.0),
new Cesium.Plane(new Cesium.Cartesian3(0, 0, 1), 100.0)
];

function loadTileset (url) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Throughout, no space before (.

viewer.entities.removeAll();
viewer.scene.primitives.removeAll();
reset();

var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url : url
Expand All @@ -98,10 +97,9 @@
}

function loadModel (url) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It is an awkward design to have the load functions return the clipping planes array.

In getObservable, perhaps create a new array and pass it to the load function. Basically defaultClippingPlanes becomes a local.

viewer.entities.removeAll();
viewer.scene.primitives.removeAll();
reset();

var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 1.0);
var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 100.0);
var heading = Cesium.Math.toRadians(135);
var pitch = 0;
var roll = 0;
Expand Down Expand Up @@ -136,8 +134,8 @@
exampleType : 'BIM',
exampleTypes : ['BIM', 'Model', 'Point Cloud'],
xOffset : 0.0,
yOffset: 0.0,
zOffset: 0.0
yOffset: 100.0,
zOffset: 100.0
};
var toolbar = document.getElementById('toolbar');
Cesium.knockout.track(viewModel);
Expand Down Expand Up @@ -167,6 +165,17 @@
}
);

function reset () {
viewer.entities.removeAll();
viewer.scene.primitives.removeAll();

if (Cesium.defined(viewModel)) {
viewModel.xOffset = 0.0;
viewModel.yOffset = 100.0;
viewModel.zOffset = 100.0;
}
}

//Sandcastle_End
Sandcastle.finishedLoading();
}
Expand Down
Binary file added Apps/Sandcastle/gallery/Clipping Planes.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions Source/Shaders/Builtin/Constants/maxClippingPlanes.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* 6
Copy link
Contributor

Choose a reason for hiding this comment

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

Provide a description here instead of just the number.

*
* @name czm_maxClippingPlanes
* @glslConstant
Copy link
Contributor

Choose a reason for hiding this comment

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

Add @see czm_clipPlanes

*/
const int czm_maxClippingPlanes = 6;
4 changes: 1 addition & 3 deletions Source/Shaders/Builtin/Functions/clipPlanes.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* @name czm_clipPlanes
* @glslFunction
*
* @param {vec4[]} clippingPlanes The array of planes used to clip, defined in in eyespace.
* @param {vec4[]} clippingPlanes The array of planes used to clip, defined in eyespace.
* @param {int} clippingPlanesLength The number of planes in the array of clipping planes.
*/
const int czm_maxClippingPlanes = 6;

void czm_clipPlanes (vec4[czm_maxClippingPlanes] clippingPlanes, int clippingPlanesLength)
Copy link
Contributor

Choose a reason for hiding this comment

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

Name this a verb, e.g., discardIfClipped.

{
if (clippingPlanesLength > 0)
Expand Down